void FreeTags( TidyDocImpl* doc ) { TidyTagImpl* tags = &doc->tags; FreeDeclaredTags( doc, 0 ); MemFree( tags->xml_tags ); /* get rid of dangling tag references */ ClearMemory( tags, sizeof(TidyTagImpl) ); }
/* Not efficient, but effective */ static void ReparseTagDecls( TidyDocImpl* doc ) { FreeDeclaredTags( doc, tagtype_null ); if ( cfg(doc, TidyInlineTags) ) ReparseTagType( doc, TidyInlineTags ); if ( cfg(doc, TidyBlockTags) ) ReparseTagType( doc, TidyBlockTags ); if ( cfg(doc, TidyEmptyTags) ) ReparseTagType( doc, TidyEmptyTags ); if ( cfg(doc, TidyPreTags) ) ReparseTagType( doc, TidyPreTags ); }
void ResetConfigToDefault( TidyDocImpl* doc ) { uint ixVal; const TidyOptionImpl* option = option_defs; TidyOptionValue* value = &doc->config.value[ 0 ]; for ( ixVal=0; ixVal < N_TIDY_OPTIONS; ++option, ++ixVal ) { TidyOptionValue dflt; assert( ixVal == (uint) option->id ); GetOptionDefault( option, &dflt ); CopyOptionValue( option, &value[ixVal], &dflt ); } FreeDeclaredTags( doc, tagtype_null ); }
void ResetConfigToSnapshot( TidyDocImpl* doc ) { uint ixVal; const TidyOptionImpl* option = option_defs; TidyOptionValue* value = &doc->config.value[ 0 ]; const TidyOptionValue* snap = &doc->config.snapshot[ 0 ]; for ( ixVal=0; ixVal < N_TIDY_OPTIONS; ++option, ++ixVal ) { assert( ixVal == (uint) option->id ); CopyOptionValue( option, &value[ixVal], &snap[ixVal] ); } FreeDeclaredTags( doc, tagtype_null ); ReparseTagDecls( doc ); }
/* a space or comma separated list of tag names */ Bool ParseTagNames( TidyDocImpl* doc, const TidyOptionImpl* option ) { TidyConfigImpl* cfg = &doc->config; tmbchar buf[1024]; uint i = 0, nTags = 0; uint c = SkipWhite( cfg ); UserTagType ttyp = tagtype_null; switch ( option->id ) { case TidyInlineTags: ttyp = tagtype_inline; break; case TidyBlockTags: ttyp = tagtype_block; break; case TidyEmptyTags: ttyp = tagtype_empty; break; case TidyPreTags: ttyp = tagtype_pre; break; default: ReportUnknownOption( doc, option->name ); return no; } SetOptionValue( doc, option->id, NULL ); FreeDeclaredTags( doc, ttyp ); cfg->defined_tags |= ttyp; do { if (c == ' ' || c == '\t' || c == ',') { c = AdvanceChar( cfg ); continue; } if ( c == '\r' || c == '\n' ) { uint c2 = AdvanceChar( cfg ); if ( c == '\r' && c2 == '\n' ) c = AdvanceChar( cfg ); else c = c2; if ( !IsWhite(c) ) { buf[i] = 0; UngetChar( c, cfg->cfgIn ); UngetChar( '\n', cfg->cfgIn ); break; } } /* if ( c == '\n' ) { c = AdvanceChar( cfg ); if ( !IsWhite(c) ) { buf[i] = 0; UngetChar( c, cfg->cfgIn ); UngetChar( '\n', cfg->cfgIn ); break; } } */ while ( i < sizeof(buf)-2 && c != EndOfStream && !IsWhite(c) && c != ',' ) { buf[i++] = (tmbchar) c; c = AdvanceChar( cfg ); } buf[i] = '\0'; if (i == 0) /* Skip empty tag definition. Possible when */ continue; /* there is a trailing space on the line. */ /* add tag to dictionary */ DeclareUserTag( doc, option->id, ttyp, buf ); i = 0; ++nTags; } while ( c != EndOfStream ); if ( i > 0 ) DeclareUserTag( doc, option->id, ttyp, buf ); return ( nTags > 0 ); }