Merge branch 'next' into issue-365
This commit is contained in:
commit
d18b21b94c
|
@ -101,6 +101,7 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define FOREACH_MSG_MISC(FN) \
|
#define FOREACH_MSG_MISC(FN) \
|
||||||
/** File can't be opened */ FN(FILE_CANT_OPEN) \
|
/** File can't be opened */ FN(FILE_CANT_OPEN) \
|
||||||
|
/** Not a file */ FN(FILE_NOT_FILE) \
|
||||||
/** line %d column %d */ FN(LINE_COLUMN_STRING) \
|
/** line %d column %d */ FN(LINE_COLUMN_STRING) \
|
||||||
/** Document content looks like %s */ FN(STRING_CONTENT_LOOKS) \
|
/** Document content looks like %s */ FN(STRING_CONTENT_LOOKS) \
|
||||||
/** discarding */ FN(STRING_DISCARDING) \
|
/** discarding */ FN(STRING_DISCARDING) \
|
||||||
|
|
|
@ -601,7 +601,7 @@ TidyTriState TY_(_cfgGetAutoBool)( TidyDocImpl* doc, TidyOptionId optId )
|
||||||
ulong val = TY_(_cfgGet)( doc, optId );
|
ulong val = TY_(_cfgGet)( doc, optId );
|
||||||
const TidyOptionImpl* opt = &option_defs[ optId ];
|
const TidyOptionImpl* opt = &option_defs[ optId ];
|
||||||
assert( opt && opt->type == TidyInteger
|
assert( opt && opt->type == TidyInteger
|
||||||
&& opt->parser == ParseAutoBool );
|
&& opt->parser == ParsePickList );
|
||||||
return (TidyTriState) val;
|
return (TidyTriState) val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ int TY_(ParseConfigFileEnc)( TidyDocImpl* doc, ctmbstr file, ctmbstr charenc )
|
||||||
|
|
||||||
if ( fin == NULL || enc < 0 )
|
if ( fin == NULL || enc < 0 )
|
||||||
{
|
{
|
||||||
TY_(FileError)( doc, fname, TidyConfig );
|
TY_(FileError)( doc, fname, TidyConfig, FILE_CANT_OPEN );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1549,6 +1549,7 @@ static languageDefinition language_en = { whichPluralForm_en, {
|
||||||
** @rename enum generator FOREACH_MSG_MISC
|
** @rename enum generator FOREACH_MSG_MISC
|
||||||
********************************************/
|
********************************************/
|
||||||
{ FILE_CANT_OPEN, 0, "Can't open \"%s\"\n" },
|
{ FILE_CANT_OPEN, 0, "Can't open \"%s\"\n" },
|
||||||
|
{ FILE_NOT_FILE, 0, "\"%s\" is not a file!\n" },
|
||||||
{ LINE_COLUMN_STRING, 0, "line %d column %d - " },
|
{ LINE_COLUMN_STRING, 0, "line %d column %d - " },
|
||||||
{ STRING_CONTENT_LOOKS, 0, "Document content looks like %s" },
|
{ STRING_CONTENT_LOOKS, 0, "Document content looks like %s" },
|
||||||
{/* For example, "discarding invalid UTF-16 surrogate pair" */
|
{/* For example, "discarding invalid UTF-16 surrogate pair" */
|
||||||
|
|
|
@ -326,7 +326,7 @@ int TY_(DocParseFileWithMappedFile)( TidyDocImpl* doc, ctmbstr filnam ) {
|
||||||
TY_(freeStreamIn)( in );
|
TY_(freeStreamIn)( in );
|
||||||
}
|
}
|
||||||
else /* Error message! */
|
else /* Error message! */
|
||||||
TY_(FileError)( doc, filnam, TidyError );
|
TY_(FileError)( doc, filnam, TidyError, FILE_CANT_OPEN );
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -459,9 +459,9 @@ void TY_(ReportFatal)( TidyDocImpl* doc, Node *element, Node *node, uint code)
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
void TY_(FileError)( TidyDocImpl* doc, ctmbstr file, TidyReportLevel level )
|
void TY_(FileError)( TidyDocImpl* doc, ctmbstr file, TidyReportLevel level, uint code )
|
||||||
{
|
{
|
||||||
TidyMessageImpl *message = TY_(tidyMessageCreate)( doc, FILE_CANT_OPEN, level, file);
|
TidyMessageImpl *message = TY_(tidyMessageCreate)( doc, code, level, file);
|
||||||
messageOut( message );
|
messageOut( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ void TY_(ReportFatal)(TidyDocImpl* doc, Node* element, Node* node, uint code);
|
||||||
/** @{ */
|
/** @{ */
|
||||||
|
|
||||||
|
|
||||||
void TY_(FileError)( TidyDocImpl* doc, ctmbstr file, TidyReportLevel level );
|
void TY_(FileError)( TidyDocImpl* doc, ctmbstr file, TidyReportLevel level, uint code );
|
||||||
void TY_(ReportAttrError)( TidyDocImpl* doc, Node* node, AttVal* av, uint code );
|
void TY_(ReportAttrError)( TidyDocImpl* doc, Node* node, AttVal* av, uint code );
|
||||||
void TY_(ReportBadArgument)( TidyDocImpl* doc, ctmbstr option );
|
void TY_(ReportBadArgument)( TidyDocImpl* doc, ctmbstr option );
|
||||||
void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarded);
|
void TY_(ReportEncodingError)(TidyDocImpl* doc, uint code, uint c, Bool discarded);
|
||||||
|
|
|
@ -910,7 +910,7 @@ FILE* TIDY_CALL tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam )
|
||||||
return errout;
|
return errout;
|
||||||
}
|
}
|
||||||
else /* Emit message to current error sink */
|
else /* Emit message to current error sink */
|
||||||
TY_(FileError)( impl, errfilnam, TidyError );
|
TY_(FileError)( impl, errfilnam, TidyError, FILE_CANT_OPEN );
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1075,11 +1075,22 @@ int TIDY_CALL tidyParseSource( TidyDoc tdoc, TidyInputSource* source )
|
||||||
|
|
||||||
int tidyDocParseFile( TidyDocImpl* doc, ctmbstr filnam )
|
int tidyDocParseFile( TidyDocImpl* doc, ctmbstr filnam )
|
||||||
{
|
{
|
||||||
|
int status = -ENOENT;
|
||||||
|
FILE* fin = fopen( filnam, "r+" );
|
||||||
|
|
||||||
|
if ( !fin )
|
||||||
|
{
|
||||||
|
TY_(FileError)( doc, filnam, TidyError, FILE_NOT_FILE );
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose( fin );
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return TY_(DocParseFileWithMappedFile)( doc, filnam );
|
return TY_(DocParseFileWithMappedFile)( doc, filnam );
|
||||||
#else
|
#else
|
||||||
int status = -ENOENT;
|
|
||||||
FILE* fin = fopen( filnam, "rb" );
|
fin = fopen( filnam, "rb" );
|
||||||
|
|
||||||
#if PRESERVE_FILE_TIMES
|
#if PRESERVE_FILE_TIMES
|
||||||
struct stat sbuf = {0};
|
struct stat sbuf = {0};
|
||||||
|
@ -1106,7 +1117,7 @@ int tidyDocParseFile( TidyDocImpl* doc, ctmbstr filnam )
|
||||||
TY_(freeStreamIn)(in);
|
TY_(freeStreamIn)(in);
|
||||||
}
|
}
|
||||||
else /* Error message! */
|
else /* Error message! */
|
||||||
TY_(FileError)( doc, filnam, TidyError );
|
TY_(FileError)( doc, filnam, TidyError, FILE_CANT_OPEN );
|
||||||
return status;
|
return status;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1220,7 +1231,7 @@ int tidyDocSaveFile( TidyDocImpl* doc, ctmbstr filnam )
|
||||||
#endif /* PRESERVFILETIMES */
|
#endif /* PRESERVFILETIMES */
|
||||||
}
|
}
|
||||||
if ( status < 0 ) /* Error message! */
|
if ( status < 0 ) /* Error message! */
|
||||||
TY_(FileError)( doc, filnam, TidyError );
|
TY_(FileError)( doc, filnam, TidyError, FILE_CANT_OPEN );
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
5.5.20
|
5.5.22
|
||||||
2017.05.07
|
2017.05.13
|
||||||
|
|
Loading…
Reference in a new issue