Merge pull request #705 from htacg/issue-673

Is #673 - Revert 350f7b4 and 86e62db AdjustConfig logic - Is #704 PR #705
This commit is contained in:
Geoff McLane 2018-04-21 14:28:59 +02:00 committed by GitHub
commit 63f507b4e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 8 deletions

View file

@ -303,6 +303,7 @@ static const struct {
/* forward declarations */ /* forward declarations */
static void AdjustConfig( TidyDocImpl* doc );
static Bool GetPickListValue( ctmbstr value, PickListItems* pickList, uint *result ); static Bool GetPickListValue( ctmbstr value, PickListItems* pickList, uint *result );
@ -711,6 +712,7 @@ void TY_(TakeConfigSnapshot)( TidyDocImpl* doc )
const TidyOptionValue* value = &doc->config.value[ 0 ]; const TidyOptionValue* value = &doc->config.value[ 0 ];
TidyOptionValue* snap = &doc->config.snapshot[ 0 ]; TidyOptionValue* snap = &doc->config.snapshot[ 0 ];
AdjustConfig( doc ); /* Make sure it's consistent */
for ( ixVal=0; ixVal < N_TIDY_OPTIONS; ++option, ++ixVal ) for ( ixVal=0; ixVal < N_TIDY_OPTIONS; ++option, ++ixVal )
{ {
assert( ixVal == (uint) option->id ); assert( ixVal == (uint) option->id );
@ -759,6 +761,7 @@ void TY_(CopyConfig)( TidyDocImpl* docTo, TidyDocImpl* docFrom )
} }
if ( needReparseTagsDecls ) if ( needReparseTagsDecls )
ReparseTagDecls( docTo, changedUserTags ); ReparseTagDecls( docTo, changedUserTags );
AdjustConfig( docTo ); /* Make sure it's consistent */
} }
} }
@ -1052,6 +1055,8 @@ int TY_(ParseConfigFileEnc)( TidyDocImpl* doc, ctmbstr file, ctmbstr charenc )
if ( fname != (tmbstr) file ) if ( fname != (tmbstr) file )
TidyDocFree( doc, fname ); TidyDocFree( doc, fname );
AdjustConfig( doc );
/* any new config errors? If so, return warning status. */ /* any new config errors? If so, return warning status. */
return (doc->optionErrors > opterrs ? 1 : 0); return (doc->optionErrors > opterrs ? 1 : 0);
} }
@ -1190,7 +1195,7 @@ Bool TY_(AdjustCharEncoding)( TidyDocImpl* doc, int encoding )
/* ensure that config is self consistent */ /* ensure that config is self consistent */
void TY_(AdjustConfig)( TidyDocImpl* doc ) static void AdjustConfig( TidyDocImpl* doc )
{ {
if ( cfgBool(doc, TidyEncloseBlockText) ) if ( cfgBool(doc, TidyEncloseBlockText) )
TY_(SetOptionBool)( doc, TidyEncloseBodyText, yes ); TY_(SetOptionBool)( doc, TidyEncloseBodyText, yes );

View file

@ -335,12 +335,6 @@ Bool TY_(ParseConfigValue)( TidyDocImpl* doc, TidyOptionId optId, ctmbstr optVa
Bool TY_(AdjustCharEncoding)( TidyDocImpl* doc, int encoding ); Bool TY_(AdjustCharEncoding)( TidyDocImpl* doc, int encoding );
/** Ensure that the configuration options are self consistent.
** @param doc The Tidy document to adjust.
*/
void TY_(AdjustConfig)( TidyDocImpl* doc );
/** Indicates whether or not the current configuration is completely default. /** Indicates whether or not the current configuration is completely default.
** @param doc The Tidy document. ** @param doc The Tidy document.
** @returns The result. ** @returns The result.

View file

@ -1447,7 +1447,6 @@ int TY_(DocParseStream)( TidyDocImpl* doc, StreamIn* in )
TY_(ResetTags)(doc); /* reset table to html5 mode */ TY_(ResetTags)(doc); /* reset table to html5 mode */
TY_(TakeConfigSnapshot)( doc ); /* Save config state */ TY_(TakeConfigSnapshot)( doc ); /* Save config state */
TY_(AdjustConfig)( doc ); /* ensure config consistency */
TY_(FreeAnchors)( doc ); TY_(FreeAnchors)( doc );
TY_(FreeNode)(doc, &doc->root); TY_(FreeNode)(doc, &doc->root);