Works for -config files now, too.

This commit is contained in:
Jim Derry 2017-10-07 11:20:57 -04:00
parent 483d17e39b
commit 2e4393e37b

View file

@ -313,7 +313,7 @@ static const struct {
ctmbstr name; /**< name of the deprecated option */ ctmbstr name; /**< name of the deprecated option */
TidyOptionId replacementId; /**< Id of the replacement option, or 0 if none. */ TidyOptionId replacementId; /**< Id of the replacement option, or 0 if none. */
} deprecatedOptions[] = { } deprecatedOptions[] = {
{ "show-body-only", TidyBodyOnly }, /* WIP, for development purposes! */ // { "show-body-only", TidyBodyOnly }, /* WIP, for development purposes! */
{ NULL } { NULL }
}; };
@ -887,20 +887,21 @@ int TY_(ParseConfigFileEnc)( TidyDocImpl* doc, ctmbstr file, ctmbstr charenc )
if ( c == ':' ) if ( c == ':' )
{ {
Bool isDeprecated = isOptionDeprecated( name );
const TidyOptionImpl* option = TY_(lookupOption)( name ); const TidyOptionImpl* option = TY_(lookupOption)( name );
c = AdvanceChar( cfg ); c = AdvanceChar( cfg );
if ( option ) if ( option && !isDeprecated )
option->parser( doc, option ); option->parser( doc, option );
else else
{ {
if ( (NULL != doc->pOptCallback) || (NULL != doc->pConfigCallback) ) if ( (NULL != doc->pOptCallback) || (NULL != doc->pConfigCallback) || isDeprecated )
{ {
TidyConfigImpl* cfg = &doc->config; TidyConfigImpl* cfg = &doc->config;
tmbchar buf[8192]; tmbchar buf[8192];
uint i = 0; uint i = 0;
tchar delim = 0; tchar delim = 0;
Bool waswhite = yes; Bool waswhite = yes;
Bool response = yes; Bool response = no;
tchar c = SkipWhite( cfg ); tchar c = SkipWhite( cfg );
@ -933,12 +934,15 @@ int TY_(ParseConfigFileEnc)( TidyDocImpl* doc, ctmbstr file, ctmbstr charenc )
buf[i] = '\0'; buf[i] = '\0';
if ( doc->pOptCallback ) if ( doc->pOptCallback )
response = response && (*doc->pOptCallback)( name, buf ); response = (*doc->pOptCallback)( name, buf );
if ( doc->pConfigCallback ) if ( doc->pConfigCallback )
response = response && (*doc->pConfigCallback)( tidyImplToDoc(doc), name, buf ); response = response && (*doc->pConfigCallback)( tidyImplToDoc(doc), name, buf );
if (response == no) if ( !response && isDeprecated )
response = subDeprecatedOption( doc, name, buf);
if ( response == no )
TY_(ReportUnknownOption)( doc, name ); TY_(ReportUnknownOption)( doc, name );
} }
else else