Return-Path: X-Original-To: apmail-corinthia-commits-archive@minotaur.apache.org Delivered-To: apmail-corinthia-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 98759CD3F for ; Tue, 30 Dec 2014 14:45:19 +0000 (UTC) Received: (qmail 83110 invoked by uid 500); 30 Dec 2014 14:45:20 -0000 Delivered-To: apmail-corinthia-commits-archive@corinthia.apache.org Received: (qmail 83077 invoked by uid 500); 30 Dec 2014 14:45:20 -0000 Mailing-List: contact commits-help@corinthia.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@corinthia.incubator.apache.org Delivered-To: mailing list commits@corinthia.incubator.apache.org Received: (qmail 82978 invoked by uid 99); 30 Dec 2014 14:45:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Dec 2014 14:45:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 30 Dec 2014 14:44:46 +0000 Received: (qmail 81808 invoked by uid 99); 30 Dec 2014 14:44:26 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Dec 2014 14:44:26 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 398DDA39B62; Tue, 30 Dec 2014 14:44:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pmkelly@apache.org To: commits@corinthia.incubator.apache.org Date: Tue, 30 Dec 2014 14:44:46 -0000 Message-Id: In-Reply-To: <37b7c4a06d7b497db8bc2e76f585a136@git.apache.org> References: <37b7c4a06d7b497db8bc2e76f585a136@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [22/63] [abbrv] [partial] incubator-corinthia git commit: Moved 3rdparty to platform This is the first part of isolating 3rdparty within platform. The idea is that only platform.h should be used outside platform platform.h might contain includes to inter X-Virus-Checked: Checked by ClamAV on apache.org http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/config.c ---------------------------------------------------------------------- diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/config.c b/DocFormats/3rdparty/external/w3c-tidy-html5/src/config.c deleted file mode 100644 index 19073ab..0000000 --- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/config.c +++ /dev/null @@ -1,1746 +0,0 @@ -/* - config.c -- read config file and manage config properties - - (c) 1998-2008 (W3C) MIT, ERCIM, Keio University - See tidy.h for the copyright notice. - - config files associate a property name with a value. - - // comments can start at the beginning of a line - # comments can start at the beginning of a line - name: short values fit onto one line - name: a really long value that - continues on the next line - - property names are case insensitive and should be less than - 60 characters in length and must start at the begining of - the line, as whitespace at the start of a line signifies a - line continuation. -*/ - -#include "config.h" -#include "tidy-int.h" -#include "message.h" -#include "tmbstr.h" -#include "tags.h" - -#ifdef WINDOWS_OS -#include -#else -#ifdef DMALLOC -/* - macro for valloc() in dmalloc.h may conflict with declaration for valloc() in unistd.h - - we don't need (debugging for) valloc() here. dmalloc.h should come last but it doesn't. -*/ -#ifdef valloc -#undef valloc -#endif -#endif -#include -#endif - -#ifdef TIDY_WIN32_MLANG_SUPPORT -#include "win32tc.h" -#endif - -void TY_(InitConfig)( TidyDocImpl* doc ) -{ - TidyClearMemory( &doc->config, sizeof(TidyConfigImpl) ); - TY_(ResetConfigToDefault)( doc ); -} - -void TY_(FreeConfig)( TidyDocImpl* doc ) -{ - TY_(ResetConfigToDefault)( doc ); - TY_(TakeConfigSnapshot)( doc ); -} - - -/* Arrange so index can be cast to enum -*/ -static const ctmbstr boolPicks[] = -{ - "no", - "yes", - NULL -}; - -static const ctmbstr autoBoolPicks[] = -{ - "no", - "yes", - "auto", - NULL -}; - -static const ctmbstr repeatAttrPicks[] = -{ - "keep-first", - "keep-last", - NULL -}; - -static const ctmbstr accessPicks[] = -{ - "0 (Tidy Classic)", - "1 (Priority 1 Checks)", - "2 (Priority 2 Checks)", - "3 (Priority 3 Checks)", - NULL -}; - -static const ctmbstr charEncPicks[] = -{ - "raw", - "ascii", - "latin0", - "latin1", - "utf8", -#ifndef NO_NATIVE_ISO2022_SUPPORT - "iso2022", -#endif - "mac", - "win1252", - "ibm858", - -#if SUPPORT_UTF16_ENCODINGS - "utf16le", - "utf16be", - "utf16", -#endif - -#if SUPPORT_ASIAN_ENCODINGS - "big5", - "shiftjis", -#endif - - NULL -}; - -static const ctmbstr newlinePicks[] = -{ - "LF", - "CRLF", - "CR", - NULL -}; - -static const ctmbstr doctypePicks[] = -{ - "html5", - "omit", - "auto", - "strict", - "transitional", - "user", - NULL -}; - -static const ctmbstr sorterPicks[] = -{ - "none", - "alpha", - NULL -}; - -#define MU TidyMarkup -#define DG TidyDiagnostics -#define PP TidyPrettyPrint -#define CE TidyEncoding -#define MS TidyMiscellaneous - -#define IN TidyInteger -#define BL TidyBoolean -#define ST TidyString - -#define XX (TidyConfigCategory)-1 -#define XY (TidyOptionType)-1 - -#define DLF DEFAULT_NL_CONFIG - -/* If Accessibility checks not supported, make config setting read-only */ -#if SUPPORT_ACCESSIBILITY_CHECKS -#define ParseAcc ParseInt -#else -#define ParseAcc NULL -#endif - -static void AdjustConfig( TidyDocImpl* doc ); - -/* parser for integer values */ -static ParseProperty ParseInt; - -/* parser for 't'/'f', 'true'/'false', 'y'/'n', 'yes'/'no' or '1'/'0' */ -static ParseProperty ParseBool; - -/* parser for 't'/'f', 'true'/'false', 'y'/'n', 'yes'/'no', '1'/'0' - or 'auto' */ -static ParseProperty ParseAutoBool; - -/* a string excluding whitespace */ -static ParseProperty ParseName; - -/* a CSS1 selector - CSS class naming for -clean option */ -static ParseProperty ParseCSS1Selector; - -/* a string including whitespace */ -static ParseProperty ParseString; - -/* a space or comma separated list of tag names */ -static ParseProperty ParseTagNames; - -/* alpha */ -static ParseProperty ParseSorter; - -/* RAW, ASCII, LATIN0, LATIN1, UTF8, ISO2022, MACROMAN, - WIN1252, IBM858, UTF16LE, UTF16BE, UTF16, BIG5, SHIFTJIS -*/ -static ParseProperty ParseCharEnc; -static ParseProperty ParseNewline; - -/* html5 | omit | auto | strict | loose | */ -static ParseProperty ParseDocType; - -/* keep-first or keep-last? */ -static ParseProperty ParseRepeatAttr; - - -static const TidyOptionImpl option_defs[] = -{ - { TidyUnknownOption, MS, "unknown!", IN, 0, NULL, NULL }, - { TidyIndentSpaces, PP, "indent-spaces", IN, 2, ParseInt, NULL }, - { TidyWrapLen, PP, "wrap", IN, 68, ParseInt, NULL }, - { TidyTabSize, PP, "tab-size", IN, 8, ParseInt, NULL }, - { TidyCharEncoding, CE, "char-encoding", IN, UTF8, ParseCharEnc, charEncPicks }, - { TidyInCharEncoding, CE, "input-encoding", IN, UTF8, ParseCharEnc, charEncPicks }, - { TidyOutCharEncoding, CE, "output-encoding", IN, UTF8, ParseCharEnc, charEncPicks }, - { TidyNewline, CE, "newline", IN, DLF, ParseNewline, newlinePicks }, - { TidyDoctypeMode, MU, "doctype-mode", IN, TidyDoctypeAuto, NULL, doctypePicks }, - { TidyDoctype, MU, "doctype", ST, 0, ParseDocType, doctypePicks }, - { TidyDuplicateAttrs, MU, "repeated-attributes", IN, TidyKeepLast, ParseRepeatAttr, repeatAttrPicks }, - { TidyAltText, MU, "alt-text", ST, 0, ParseString, NULL }, - - /* obsolete */ - { TidySlideStyle, MS, "slide-style", ST, 0, ParseName, NULL }, - - { TidyErrFile, MS, "error-file", ST, 0, ParseString, NULL }, - { TidyOutFile, MS, "output-file", ST, 0, ParseString, NULL }, - { TidyWriteBack, MS, "write-back", BL, no, ParseBool, boolPicks }, - { TidyShowMarkup, PP, "markup", BL, yes, ParseBool, boolPicks }, - { TidyShowInfo, DG, "show-info", BL, yes, ParseBool, boolPicks }, - { TidyShowWarnings, DG, "show-warnings", BL, yes, ParseBool, boolPicks }, - { TidyQuiet, MS, "quiet", BL, no, ParseBool, boolPicks }, - { TidyIndentContent, PP, "indent", IN, TidyNoState, ParseAutoBool, autoBoolPicks }, - { TidyCoerceEndTags, MU, "coerce-endtags", BL, yes, ParseBool, boolPicks }, - { TidyOmitOptionalTags, MU, "omit-optional-tags", BL, no, ParseBool, boolPicks }, - { TidyHideEndTags, MU, "hide-endtags", BL, no, ParseBool, boolPicks }, - { TidyXmlTags, MU, "input-xml", BL, no, ParseBool, boolPicks }, - { TidyXmlOut, MU, "output-xml", BL, no, ParseBool, boolPicks }, - { TidyXhtmlOut, MU, "output-xhtml", BL, no, ParseBool, boolPicks }, - { TidyHtmlOut, MU, "output-html", BL, no, ParseBool, boolPicks }, - { TidyXmlDecl, MU, "add-xml-decl", BL, no, ParseBool, boolPicks }, - { TidyUpperCaseTags, MU, "uppercase-tags", BL, no, ParseBool, boolPicks }, - { TidyUpperCaseAttrs, MU, "uppercase-attributes", BL, no, ParseBool, boolPicks }, - { TidyMakeBare, MU, "bare", BL, no, ParseBool, boolPicks }, - { TidyMakeClean, MU, "clean", BL, no, ParseBool, boolPicks }, - { TidyGDocClean, MU, "gdoc", BL, no, ParseBool, boolPicks }, - { TidyLogicalEmphasis, MU, "logical-emphasis", BL, no, ParseBool, boolPicks }, - { TidyDropPropAttrs, MU, "drop-proprietary-attributes", BL, no, ParseBool, boolPicks }, - { TidyDropFontTags, MU, "drop-font-tags", BL, no, ParseBool, boolPicks }, - { TidyDropEmptyElems, MU, "drop-empty-elements", BL, yes, ParseBool, boolPicks }, - { TidyDropEmptyParas, MU, "drop-empty-paras", BL, yes, ParseBool, boolPicks }, - { TidyFixComments, MU, "fix-bad-comments", BL, yes, ParseBool, boolPicks }, - { TidyBreakBeforeBR, PP, "break-before-br", BL, no, ParseBool, boolPicks }, - - /* obsolete */ - { TidyBurstSlides, PP, "split", BL, no, ParseBool, boolPicks }, - - { TidyNumEntities, MU, "numeric-entities", BL, no, ParseBool, boolPicks }, - { TidyQuoteMarks, MU, "quote-marks", BL, no, ParseBool, boolPicks }, - { TidyQuoteNbsp, MU, "quote-nbsp", BL, yes, ParseBool, boolPicks }, - { TidyQuoteAmpersand, MU, "quote-ampersand", BL, yes, ParseBool, boolPicks }, - { TidyWrapAttVals, PP, "wrap-attributes", BL, no, ParseBool, boolPicks }, - { TidyWrapScriptlets, PP, "wrap-script-literals", BL, no, ParseBool, boolPicks }, - { TidyWrapSection, PP, "wrap-sections", BL, yes, ParseBool, boolPicks }, - { TidyWrapAsp, PP, "wrap-asp", BL, yes, ParseBool, boolPicks }, - { TidyWrapJste, PP, "wrap-jste", BL, yes, ParseBool, boolPicks }, - { TidyWrapPhp, PP, "wrap-php", BL, yes, ParseBool, boolPicks }, - { TidyFixBackslash, MU, "fix-backslash", BL, yes, ParseBool, boolPicks }, - { TidyIndentAttributes, PP, "indent-attributes", BL, no, ParseBool, boolPicks }, - { TidyXmlPIs, MU, "assume-xml-procins", BL, no, ParseBool, boolPicks }, - { TidyXmlSpace, MU, "add-xml-space", BL, no, ParseBool, boolPicks }, - { TidyEncloseBodyText, MU, "enclose-text", BL, no, ParseBool, boolPicks }, - { TidyEncloseBlockText, MU, "enclose-block-text", BL, no, ParseBool, boolPicks }, - { TidyKeepFileTimes, MS, "keep-time", BL, no, ParseBool, boolPicks }, - { TidyWord2000, MU, "word-2000", BL, no, ParseBool, boolPicks }, - { TidyMark, MS, "tidy-mark", BL, yes, ParseBool, boolPicks }, - { TidyEmacs, MS, "gnu-emacs", BL, no, ParseBool, boolPicks }, - { TidyEmacsFile, MS, "gnu-emacs-file", ST, 0, ParseString, NULL }, - { TidyLiteralAttribs, MU, "literal-attributes", BL, no, ParseBool, boolPicks }, - { TidyBodyOnly, MU, "show-body-only", IN, no, ParseAutoBool, autoBoolPicks }, - { TidyFixUri, MU, "fix-uri", BL, yes, ParseBool, boolPicks }, - { TidyLowerLiterals, MU, "lower-literals", BL, yes, ParseBool, boolPicks }, - { TidyHideComments, MU, "hide-comments", BL, no, ParseBool, boolPicks }, - { TidyIndentCdata, MU, "indent-cdata", BL, no, ParseBool, boolPicks }, - { TidyForceOutput, MS, "force-output", BL, no, ParseBool, boolPicks }, - { TidyShowErrors, DG, "show-errors", IN, 6, ParseInt, NULL }, - { TidyAsciiChars, CE, "ascii-chars", BL, no, ParseBool, boolPicks }, - { TidyJoinClasses, MU, "join-classes", BL, no, ParseBool, boolPicks }, - { TidyJoinStyles, MU, "join-styles", BL, yes, ParseBool, boolPicks }, - { TidyEscapeCdata, MU, "escape-cdata", BL, no, ParseBool, boolPicks }, -#if SUPPORT_ASIAN_ENCODINGS - { TidyLanguage, CE, "language", ST, 0, ParseName, NULL }, - { TidyNCR, MU, "ncr", BL, yes, ParseBool, boolPicks }, -#endif -#if SUPPORT_UTF16_ENCODINGS - { TidyOutputBOM, CE, "output-bom", IN, TidyAutoState, ParseAutoBool, autoBoolPicks }, -#endif - { TidyReplaceColor, MU, "replace-color", BL, no, ParseBool, boolPicks }, - { TidyCSSPrefix, MU, "css-prefix", ST, 0, ParseCSS1Selector, NULL }, - { TidyInlineTags, MU, "new-inline-tags", ST, 0, ParseTagNames, NULL }, - { TidyBlockTags, MU, "new-blocklevel-tags", ST, 0, ParseTagNames, NULL }, - { TidyEmptyTags, MU, "new-empty-tags", ST, 0, ParseTagNames, NULL }, - { TidyPreTags, MU, "new-pre-tags", ST, 0, ParseTagNames, NULL }, - { TidyAccessibilityCheckLevel, DG, "accessibility-check", IN, 0, ParseAcc, accessPicks }, - { TidyVertSpace, PP, "vertical-space", BL, no, ParseBool, boolPicks }, -#if SUPPORT_ASIAN_ENCODINGS - { TidyPunctWrap, PP, "punctuation-wrap", BL, no, ParseBool, boolPicks }, -#endif - { TidyMergeEmphasis, MU, "merge-emphasis", BL, yes, ParseBool, boolPicks }, - { TidyMergeDivs, MU, "merge-divs", IN, TidyAutoState, ParseAutoBool, autoBoolPicks }, - { TidyDecorateInferredUL, MU, "decorate-inferred-ul", BL, no, ParseBool, boolPicks }, - { TidyPreserveEntities, MU, "preserve-entities", BL, no, ParseBool, boolPicks }, - { TidySortAttributes, PP, "sort-attributes", IN, TidySortAttrNone,ParseSorter, sorterPicks }, - { TidyMergeSpans, MU, "merge-spans", IN, TidyAutoState, ParseAutoBool, autoBoolPicks }, - { TidyAnchorAsName, MU, "anchor-as-name", BL, yes, ParseBool, boolPicks }, - { N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL } -}; - -/* Should only be called by options set by name -** thus, it is cheaper to do a few scans than set -** up every option in a hash table. -*/ -const TidyOptionImpl* TY_(lookupOption)( ctmbstr s ) -{ - const TidyOptionImpl* np = option_defs; - for ( /**/; np < option_defs + N_TIDY_OPTIONS; ++np ) - { - if ( TY_(tmbstrcasecmp)(s, np->name) == 0 ) - return np; - } - return NULL; -} - -const TidyOptionImpl* TY_(getOption)( TidyOptionId optId ) -{ - if ( optId < N_TIDY_OPTIONS ) - return option_defs + optId; - return NULL; -} - - -static void FreeOptionValue( TidyDocImpl* doc, const TidyOptionImpl* option, TidyOptionValue* value ) -{ - if ( option->type == TidyString && value->p && value->p != option->pdflt ) - TidyDocFree( doc, value->p ); -} - -static void CopyOptionValue( TidyDocImpl* doc, const TidyOptionImpl* option, - TidyOptionValue* oldval, const TidyOptionValue* newval ) -{ - assert( oldval != NULL ); - FreeOptionValue( doc, option, oldval ); - - if ( option->type == TidyString ) - { - if ( newval->p && newval->p != option->pdflt ) - oldval->p = TY_(tmbstrdup)( doc->allocator, newval->p ); - else - oldval->p = newval->p; - } - else - oldval->v = newval->v; -} - - -static Bool SetOptionValue( TidyDocImpl* doc, TidyOptionId optId, ctmbstr val ) -{ - const TidyOptionImpl* option = &option_defs[ optId ]; - Bool status = ( optId < N_TIDY_OPTIONS ); - if ( status ) - { - assert( option->id == optId && option->type == TidyString ); - FreeOptionValue( doc, option, &doc->config.value[ optId ] ); - doc->config.value[ optId ].p = TY_(tmbstrdup)( doc->allocator, val ); - } - return status; -} - -Bool TY_(SetOptionInt)( TidyDocImpl* doc, TidyOptionId optId, uint val ) -{ - Bool status = ( optId < N_TIDY_OPTIONS ); - if ( status ) - { - assert( option_defs[ optId ].type == TidyInteger ); - doc->config.value[ optId ].v = val; - } - return status; -} - -Bool TY_(SetOptionBool)( TidyDocImpl* doc, TidyOptionId optId, Bool val ) -{ - Bool status = ( optId < N_TIDY_OPTIONS ); - if ( status ) - { - assert( option_defs[ optId ].type == TidyBoolean ); - doc->config.value[ optId ].v = val; - } - return status; -} - -static void GetOptionDefault( const TidyOptionImpl* option, - TidyOptionValue* dflt ) -{ - if ( option->type == TidyString ) - dflt->p = (char*)option->pdflt; - else - dflt->v = (uint)option->dflt; -} - -static Bool OptionValueEqDefault( const TidyOptionImpl* option, - const TidyOptionValue* val ) -{ - return ( option->type == TidyString ) ? - val->p == option->pdflt : - val->v == option->dflt; -} - -Bool TY_(ResetOptionToDefault)( TidyDocImpl* doc, TidyOptionId optId ) -{ - Bool status = ( optId > 0 && optId < N_TIDY_OPTIONS ); - if ( status ) - { - TidyOptionValue dflt; - const TidyOptionImpl* option = option_defs + optId; - TidyOptionValue* value = &doc->config.value[ optId ]; - assert( optId == option->id ); - GetOptionDefault( option, &dflt ); - CopyOptionValue( doc, option, value, &dflt ); - } - return status; -} - -static void ReparseTagType( TidyDocImpl* doc, TidyOptionId optId ) -{ - ctmbstr tagdecl = cfgStr( doc, optId ); - tmbstr dupdecl = TY_(tmbstrdup)( doc->allocator, tagdecl ); - TY_(ParseConfigValue)( doc, optId, dupdecl ); - TidyDocFree( doc, dupdecl ); -} - -static Bool OptionValueIdentical( const TidyOptionImpl* option, - const TidyOptionValue* val1, - const TidyOptionValue* val2 ) -{ - if ( option->type == TidyString ) - { - if ( val1->p == val2->p ) - return yes; - if ( !val1->p || !val2->p ) - return no; - return TY_(tmbstrcmp)( val1->p, val2->p ) == 0; - } - else - return val1->v == val2->v; -} - -static Bool NeedReparseTagDecls( const TidyOptionValue* current, - const TidyOptionValue* new, - uint *changedUserTags ) -{ - Bool ret = no; - uint ixVal; - const TidyOptionImpl* option = option_defs; - *changedUserTags = tagtype_null; - - for ( ixVal=0; ixVal < N_TIDY_OPTIONS; ++option, ++ixVal ) - { - assert( ixVal == (uint) option->id ); - switch (option->id) - { -#define TEST_USERTAGS(USERTAGOPTION,USERTAGTYPE) \ - case USERTAGOPTION: \ - if (!OptionValueIdentical(option,¤t[ixVal],&new[ixVal])) \ - { \ - *changedUserTags |= USERTAGTYPE; \ - ret = yes; \ - } \ - break - TEST_USERTAGS(TidyInlineTags,tagtype_inline); - TEST_USERTAGS(TidyBlockTags,tagtype_block); - TEST_USERTAGS(TidyEmptyTags,tagtype_empty); - TEST_USERTAGS(TidyPreTags,tagtype_pre); - default: - break; - } - } - return ret; -} - -static void ReparseTagDecls( TidyDocImpl* doc, uint changedUserTags ) -{ -#define REPARSE_USERTAGS(USERTAGOPTION,USERTAGTYPE) \ - if ( changedUserTags & USERTAGTYPE ) \ - { \ - TY_(FreeDeclaredTags)( doc, USERTAGTYPE ); \ - ReparseTagType( doc, USERTAGOPTION ); \ - } - REPARSE_USERTAGS(TidyInlineTags,tagtype_inline); - REPARSE_USERTAGS(TidyBlockTags,tagtype_block); - REPARSE_USERTAGS(TidyEmptyTags,tagtype_empty); - REPARSE_USERTAGS(TidyPreTags,tagtype_pre); -} - -void TY_(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( doc, option, &value[ixVal], &dflt ); - } - TY_(FreeDeclaredTags)( doc, tagtype_null ); -} - -void TY_(TakeConfigSnapshot)( TidyDocImpl* doc ) -{ - uint ixVal; - const TidyOptionImpl* option = option_defs; - const TidyOptionValue* value = &doc->config.value[ 0 ]; - TidyOptionValue* snap = &doc->config.snapshot[ 0 ]; - - AdjustConfig( doc ); /* Make sure it's consistent */ - for ( ixVal=0; ixVal < N_TIDY_OPTIONS; ++option, ++ixVal ) - { - assert( ixVal == (uint) option->id ); - CopyOptionValue( doc, option, &snap[ixVal], &value[ixVal] ); - } -} - -void TY_(ResetConfigToSnapshot)( TidyDocImpl* doc ) -{ - uint ixVal; - const TidyOptionImpl* option = option_defs; - TidyOptionValue* value = &doc->config.value[ 0 ]; - const TidyOptionValue* snap = &doc->config.snapshot[ 0 ]; - uint changedUserTags; - Bool needReparseTagsDecls = NeedReparseTagDecls( value, snap, - &changedUserTags ); - - for ( ixVal=0; ixVal < N_TIDY_OPTIONS; ++option, ++ixVal ) - { - assert( ixVal == (uint) option->id ); - CopyOptionValue( doc, option, &value[ixVal], &snap[ixVal] ); - } - if ( needReparseTagsDecls ) - ReparseTagDecls( doc, changedUserTags ); -} - -void TY_(CopyConfig)( TidyDocImpl* docTo, TidyDocImpl* docFrom ) -{ - if ( docTo != docFrom ) - { - uint ixVal; - const TidyOptionImpl* option = option_defs; - const TidyOptionValue* from = &docFrom->config.value[ 0 ]; - TidyOptionValue* to = &docTo->config.value[ 0 ]; - uint changedUserTags; - Bool needReparseTagsDecls = NeedReparseTagDecls( to, from, - &changedUserTags ); - - TY_(TakeConfigSnapshot)( docTo ); - for ( ixVal=0; ixVal < N_TIDY_OPTIONS; ++option, ++ixVal ) - { - assert( ixVal == (uint) option->id ); - CopyOptionValue( docTo, option, &to[ixVal], &from[ixVal] ); - } - if ( needReparseTagsDecls ) - ReparseTagDecls( docTo, changedUserTags ); - AdjustConfig( docTo ); /* Make sure it's consistent */ - } -} - - -#ifdef _DEBUG - -/* Debug accessor functions will be type-safe and assert option type match */ -uint TY_(_cfgGet)( TidyDocImpl* doc, TidyOptionId optId ) -{ - assert( optId < N_TIDY_OPTIONS ); - return doc->config.value[ optId ].v; -} - -Bool TY_(_cfgGetBool)( TidyDocImpl* doc, TidyOptionId optId ) -{ - uint val = TY_(_cfgGet)( doc, optId ); - const TidyOptionImpl* opt = &option_defs[ optId ]; - assert( opt && opt->type == TidyBoolean ); - return (Bool) val; -} - -TidyTriState TY_(_cfgGetAutoBool)( TidyDocImpl* doc, TidyOptionId optId ) -{ - uint val = TY_(_cfgGet)( doc, optId ); - const TidyOptionImpl* opt = &option_defs[ optId ]; - assert( opt && opt->type == TidyInteger - && opt->parser == ParseAutoBool ); - return (TidyTriState) val; -} - -ctmbstr TY_(_cfgGetString)( TidyDocImpl* doc, TidyOptionId optId ) -{ - const TidyOptionImpl* opt; - - assert( optId < N_TIDY_OPTIONS ); - opt = &option_defs[ optId ]; - assert( opt && opt->type == TidyString ); - return doc->config.value[ optId ].p; -} -#endif - - -#if 0 -/* for use with Gnu Emacs */ -void SetEmacsFilename( TidyDocImpl* doc, ctmbstr filename ) -{ - SetOptionValue( doc, TidyEmacsFile, filename ); -} -#endif - -static tchar GetC( TidyConfigImpl* config ) -{ - if ( config->cfgIn ) - return TY_(ReadChar)( config->cfgIn ); - return EndOfStream; -} - -static tchar FirstChar( TidyConfigImpl* config ) -{ - config->c = GetC( config ); - return config->c; -} - -static tchar AdvanceChar( TidyConfigImpl* config ) -{ - if ( config->c != EndOfStream ) - config->c = GetC( config ); - return config->c; -} - -static tchar SkipWhite( TidyConfigImpl* config ) -{ - while ( TY_(IsWhite)(config->c) && !TY_(IsNewline)(config->c) ) - config->c = GetC( config ); - return config->c; -} - -/* skip until end of line -static tchar SkipToEndofLine( TidyConfigImpl* config ) -{ - while ( config->c != EndOfStream ) - { - config->c = GetC( config ); - if ( config->c == '\n' || config->c == '\r' ) - break; - } - return config->c; -} -*/ - -/* - skip over line continuations - to start of next property -*/ -static uint NextProperty( TidyConfigImpl* config ) -{ - do - { - /* skip to end of line */ - while ( config->c != '\n' && config->c != '\r' && config->c != EndOfStream ) - config->c = GetC( config ); - - /* treat \r\n \r or \n as line ends */ - if ( config->c == '\r' ) - config->c = GetC( config ); - - if ( config->c == '\n' ) - config->c = GetC( config ); - } - while ( TY_(IsWhite)(config->c) ); /* line continuation? */ - - return config->c; -} - -/* - Todd Lewis contributed this code for expanding - ~/foo or ~your/foo according to $HOME and your - user name. This will work partially on any system - which defines $HOME. Support for ~user/foo will - work on systems that support getpwnam(userid), - namely Unix/Linux. -*/ -static ctmbstr ExpandTilde( TidyDocImpl* doc, ctmbstr filename ) -{ - char *home_dir = NULL; - - if ( !filename ) - return NULL; - - if ( filename[0] != '~' ) - return filename; - - if (filename[1] == '/') - { - home_dir = getenv("HOME"); - if ( home_dir ) - ++filename; - } -#ifdef SUPPORT_GETPWNAM - else - { - struct passwd *passwd = NULL; - ctmbstr s = filename + 1; - tmbstr t; - - while ( *s && *s != '/' ) - s++; - - if ( t = TidyDocAlloc(doc, s - filename) ) - { - memcpy(t, filename+1, s-filename-1); - t[s-filename-1] = 0; - - passwd = getpwnam(t); - - TidyDocFree(doc, t); - } - - if ( passwd ) - { - filename = s; - home_dir = passwd->pw_dir; - } - } -#endif /* SUPPORT_GETPWNAM */ - - if ( home_dir ) - { - uint len = TY_(tmbstrlen)(filename) + TY_(tmbstrlen)(home_dir) + 1; - tmbstr p = (tmbstr)TidyDocAlloc( doc, len ); - TY_(tmbstrcpy)( p, home_dir ); - TY_(tmbstrcat)( p, filename ); - return (ctmbstr) p; - } - return (ctmbstr) filename; -} - -Bool TIDY_CALL tidyFileExists( TidyDoc tdoc, ctmbstr filename ) -{ - TidyDocImpl* doc = tidyDocToImpl( tdoc ); - ctmbstr fname = (tmbstr) ExpandTilde( doc, filename ); -#ifndef NO_ACCESS_SUPPORT - Bool exists = ( access(fname, 0) == 0 ); -#else - Bool exists; - /* at present */ - FILE* fin = fopen(fname, "r"); - if (fin != NULL) - fclose(fin); - exists = ( fin != NULL ); -#endif - if ( fname != filename ) - TidyDocFree( doc, (tmbstr) fname ); - return exists; -} - - -#ifndef TIDY_MAX_NAME -#define TIDY_MAX_NAME 64 -#endif - -int TY_(ParseConfigFile)( TidyDocImpl* doc, ctmbstr file ) -{ - return TY_(ParseConfigFileEnc)( doc, file, "ascii" ); -} - -/* open the file and parse its contents -*/ -int TY_(ParseConfigFileEnc)( TidyDocImpl* doc, ctmbstr file, ctmbstr charenc ) -{ - uint opterrs = doc->optionErrors; - tmbstr fname = (tmbstr) ExpandTilde( doc, file ); - TidyConfigImpl* cfg = &doc->config; - FILE* fin = fopen( fname, "r" ); - int enc = TY_(CharEncodingId)( doc, charenc ); - - if ( fin == NULL || enc < 0 ) - { - TY_(FileError)( doc, fname, TidyConfig ); - return -1; - } - else - { - tchar c; - cfg->cfgIn = TY_(FileInput)( doc, fin, enc ); - c = FirstChar( cfg ); - - for ( c = SkipWhite(cfg); c != EndOfStream; c = NextProperty(cfg) ) - { - uint ix = 0; - tmbchar name[ TIDY_MAX_NAME ] = {0}; - - /* // or # start a comment */ - if ( c == '/' || c == '#' ) - continue; - - while ( ix < sizeof(name)-1 && c != '\n' && c != EndOfStream && c != ':' ) - { - name[ ix++ ] = (tmbchar) c; /* Option names all ASCII */ - c = AdvanceChar( cfg ); - } - - if ( c == ':' ) - { - const TidyOptionImpl* option = TY_(lookupOption)( name ); - c = AdvanceChar( cfg ); - if ( option ) - option->parser( doc, option ); - else - { - if (NULL != doc->pOptCallback) - { - TidyConfigImpl* cfg = &doc->config; - tmbchar buf[8192]; - uint i = 0; - tchar delim = 0; - Bool waswhite = yes; - - tchar c = SkipWhite( cfg ); - - if ( c == '"' || c == '\'' ) - { - delim = c; - c = AdvanceChar( cfg ); - } - - while ( i < sizeof(buf)-2 && c != EndOfStream && c != '\r' && c != '\n' ) - { - if ( delim && c == delim ) - break; - - if ( TY_(IsWhite)(c) ) - { - if ( waswhite ) - { - c = AdvanceChar( cfg ); - continue; - } - c = ' '; - } - else - waswhite = no; - - buf[i++] = (tmbchar) c; - c = AdvanceChar( cfg ); - } - buf[i] = '\0'; - if (no == (*doc->pOptCallback)( name, buf )) - TY_(ReportUnknownOption)( doc, name ); - } - else - TY_(ReportUnknownOption)( doc, name ); - } - } - } - - TY_(freeFileSource)(&cfg->cfgIn->source, yes); - TY_(freeStreamIn)( cfg->cfgIn ); - cfg->cfgIn = NULL; - } - - if ( fname != (tmbstr) file ) - TidyDocFree( doc, fname ); - - AdjustConfig( doc ); - - /* any new config errors? If so, return warning status. */ - return (doc->optionErrors > opterrs ? 1 : 0); -} - -/* returns false if unknown option, missing parameter, -** or option doesn't use parameter -*/ -Bool TY_(ParseConfigOption)( TidyDocImpl* doc, ctmbstr optnam, ctmbstr optval ) -{ - const TidyOptionImpl* option = TY_(lookupOption)( optnam ); - Bool status = ( option != NULL ); - if ( !status ) - { - /* Not a standard tidy option. Check to see if the user application - recognizes it */ - if (NULL != doc->pOptCallback) - status = (*doc->pOptCallback)( optnam, optval ); - if (!status) - TY_(ReportUnknownOption)( doc, optnam ); - } - else - status = TY_(ParseConfigValue)( doc, option->id, optval ); - return status; -} - -/* returns false if unknown option, missing parameter, -** or option doesn't use parameter -*/ -Bool TY_(ParseConfigValue)( TidyDocImpl* doc, TidyOptionId optId, ctmbstr optval ) -{ - const TidyOptionImpl* option = option_defs + optId; - Bool status = ( optId < N_TIDY_OPTIONS && optval != NULL ); - - if ( !status ) - TY_(ReportBadArgument)( doc, option->name ); - else - { - TidyBuffer inbuf; /* Set up input source */ - tidyBufInitWithAllocator( &inbuf, doc->allocator ); - tidyBufAttach( &inbuf, (byte*)optval, TY_(tmbstrlen)(optval)+1 ); - doc->config.cfgIn = TY_(BufferInput)( doc, &inbuf, ASCII ); - doc->config.c = GetC( &doc->config ); - - status = option->parser( doc, option ); - - TY_(freeStreamIn)(doc->config.cfgIn); /* Release input source */ - doc->config.cfgIn = NULL; - tidyBufDetach( &inbuf ); - } - return status; -} - - -/* ensure that char encodings are self consistent */ -Bool TY_(AdjustCharEncoding)( TidyDocImpl* doc, int encoding ) -{ - int outenc = -1; - int inenc = -1; - - switch( encoding ) - { - case MACROMAN: - inenc = MACROMAN; - outenc = ASCII; - break; - - case WIN1252: - inenc = WIN1252; - outenc = ASCII; - break; - - case IBM858: - inenc = IBM858; - outenc = ASCII; - break; - - case ASCII: - inenc = LATIN1; - outenc = ASCII; - break; - - case LATIN0: - inenc = LATIN0; - outenc = ASCII; - break; - - case RAW: - case LATIN1: - case UTF8: -#ifndef NO_NATIVE_ISO2022_SUPPORT - case ISO2022: -#endif - -#if SUPPORT_UTF16_ENCODINGS - case UTF16LE: - case UTF16BE: - case UTF16: -#endif -#if SUPPORT_ASIAN_ENCODINGS - case SHIFTJIS: - case BIG5: -#endif - inenc = outenc = encoding; - break; - } - - if ( inenc >= 0 ) - { - TY_(SetOptionInt)( doc, TidyCharEncoding, encoding ); - TY_(SetOptionInt)( doc, TidyInCharEncoding, inenc ); - TY_(SetOptionInt)( doc, TidyOutCharEncoding, outenc ); - return yes; - } - return no; -} - -/* ensure that config is self consistent */ -void AdjustConfig( TidyDocImpl* doc ) -{ - if ( cfgBool(doc, TidyEncloseBlockText) ) - TY_(SetOptionBool)( doc, TidyEncloseBodyText, yes ); - - if ( cfgAutoBool(doc, TidyIndentContent) == TidyNoState ) - TY_(SetOptionInt)( doc, TidyIndentSpaces, 0 ); - - /* disable wrapping */ - if ( cfg(doc, TidyWrapLen) == 0 ) - TY_(SetOptionInt)( doc, TidyWrapLen, 0x7FFFFFFF ); - - /* Word 2000 needs o:p to be declared as inline */ - if ( cfgBool(doc, TidyWord2000) ) - { - doc->config.defined_tags |= tagtype_inline; - TY_(DefineTag)( doc, tagtype_inline, "o:p" ); - } - - /* #480701 disable XHTML output flag if both output-xhtml and xml input are set */ - if ( cfgBool(doc, TidyXmlTags) ) - TY_(SetOptionBool)( doc, TidyXhtmlOut, no ); - - /* XHTML is written in lower case */ - if ( cfgBool(doc, TidyXhtmlOut) ) - { - TY_(SetOptionBool)( doc, TidyXmlOut, yes ); - TY_(SetOptionBool)( doc, TidyUpperCaseTags, no ); - TY_(SetOptionBool)( doc, TidyUpperCaseAttrs, no ); - /* TY_(SetOptionBool)( doc, TidyXmlPIs, yes ); */ - } - - /* if XML in, then XML out */ - if ( cfgBool(doc, TidyXmlTags) ) - { - TY_(SetOptionBool)( doc, TidyXmlOut, yes ); - TY_(SetOptionBool)( doc, TidyXmlPIs, yes ); - } - - /* #427837 - fix by Dave Raggett 02 Jun 01 - ** generate - ** if the output character encoding is Latin-1 etc. - */ - if ( cfg(doc, TidyOutCharEncoding) != ASCII && - cfg(doc, TidyOutCharEncoding) != UTF8 && -#if SUPPORT_UTF16_ENCODINGS - cfg(doc, TidyOutCharEncoding) != UTF16 && - cfg(doc, TidyOutCharEncoding) != UTF16BE && - cfg(doc, TidyOutCharEncoding) != UTF16LE && -#endif - cfg(doc, TidyOutCharEncoding) != RAW && - cfgBool(doc, TidyXmlOut) ) - { - TY_(SetOptionBool)( doc, TidyXmlDecl, yes ); - } - - /* XML requires end tags */ - if ( cfgBool(doc, TidyXmlOut) ) - { -#if SUPPORT_UTF16_ENCODINGS - /* XML requires a BOM on output if using UTF-16 encoding */ - uint enc = cfg( doc, TidyOutCharEncoding ); - if ( enc == UTF16LE || enc == UTF16BE || enc == UTF16 ) - TY_(SetOptionInt)( doc, TidyOutputBOM, yes ); -#endif - TY_(SetOptionBool)( doc, TidyQuoteAmpersand, yes ); - TY_(SetOptionBool)( doc, TidyHideEndTags, no ); - } -} - -/* unsigned integers */ -Bool ParseInt( TidyDocImpl* doc, const TidyOptionImpl* entry ) -{ - uint number = 0; - Bool digits = no; - TidyConfigImpl* cfg = &doc->config; - tchar c = SkipWhite( cfg ); - - while ( TY_(IsDigit)(c) ) - { - number = c - '0' + (10 * number); - digits = yes; - c = AdvanceChar( cfg ); - } - - if ( !digits ) - TY_(ReportBadArgument)( doc, entry->name ); - else - TY_(SetOptionInt)( doc, entry->id, number ); - return digits; -} - -/* true/false or yes/no or 0/1 or "auto" only looks at 1st char */ -static Bool ParseTriState( TidyTriState theState, TidyDocImpl* doc, - const TidyOptionImpl* entry, uint* flag ) -{ - TidyConfigImpl* cfg = &doc->config; - tchar c = SkipWhite( cfg ); - - if (c == 't' || c == 'T' || c == 'y' || c == 'Y' || c == '1') - *flag = yes; - else if (c == 'f' || c == 'F' || c == 'n' || c == 'N' || c == '0') - *flag = no; - else if (theState == TidyAutoState && (c == 'a' || c =='A')) - *flag = TidyAutoState; - else - { - TY_(ReportBadArgument)( doc, entry->name ); - return no; - } - - return yes; -} - -/* cr, lf or crlf */ -Bool ParseNewline( TidyDocImpl* doc, const TidyOptionImpl* entry ) -{ - int nl = -1; - tmbchar work[ 16 ] = {0}; - tmbstr cp = work, end = work + sizeof(work); - TidyConfigImpl* cfg = &doc->config; - tchar c = SkipWhite( cfg ); - - while ( c!=EndOfStream && cp < end && !TY_(IsWhite)(c) && c != '\r' && c != '\n' ) - { - *cp++ = (tmbchar) c; - c = AdvanceChar( cfg ); - } - *cp = 0; - - if ( TY_(tmbstrcasecmp)(work, "lf") == 0 ) - nl = TidyLF; - else if ( TY_(tmbstrcasecmp)(work, "crlf") == 0 ) - nl = TidyCRLF; - else if ( TY_(tmbstrcasecmp)(work, "cr") == 0 ) - nl = TidyCR; - - if ( nl < TidyLF || nl > TidyCR ) - TY_(ReportBadArgument)( doc, entry->name ); - else - TY_(SetOptionInt)( doc, entry->id, nl ); - return ( nl >= TidyLF && nl <= TidyCR ); -} - -Bool ParseBool( TidyDocImpl* doc, const TidyOptionImpl* entry ) -{ - uint flag = 0; - Bool status = ParseTriState( TidyNoState, doc, entry, &flag ); - if ( status ) - TY_(SetOptionBool)( doc, entry->id, flag != 0 ); - return status; -} - -Bool ParseAutoBool( TidyDocImpl* doc, const TidyOptionImpl* entry ) -{ - uint flag = 0; - Bool status = ParseTriState( TidyAutoState, doc, entry, &flag ); - if ( status ) - TY_(SetOptionInt)( doc, entry->id, flag ); - return status; -} - -/* a string excluding whitespace */ -Bool ParseName( TidyDocImpl* doc, const TidyOptionImpl* option ) -{ - tmbchar buf[ 1024 ] = {0}; - uint i = 0; - uint c = SkipWhite( &doc->config ); - - while ( i < sizeof(buf)-2 && c != EndOfStream && !TY_(IsWhite)(c) ) - { - buf[i++] = (tmbchar) c; - c = AdvanceChar( &doc->config ); - } - buf[i] = 0; - - if ( i == 0 ) - TY_(ReportBadArgument)( doc, option->name ); - else - SetOptionValue( doc, option->id, buf ); - return ( i > 0 ); -} - -/* #508936 - CSS class naming for -clean option */ -Bool ParseCSS1Selector( TidyDocImpl* doc, const TidyOptionImpl* option ) -{ - char buf[256] = {0}; - uint i = 0; - uint c = SkipWhite( &doc->config ); - - while ( i < sizeof(buf)-2 && c != EndOfStream && !TY_(IsWhite)(c) ) - { - buf[i++] = (tmbchar) c; - c = AdvanceChar( &doc->config ); - } - buf[i] = '\0'; - - if ( i == 0 || !TY_(IsCSS1Selector)(buf) ) { - TY_(ReportBadArgument)( doc, option->name ); - return no; - } - - buf[i++] = '-'; /* Make sure any escaped Unicode is terminated */ - buf[i] = 0; /* so valid class names are generated after */ - /* Tidy appends last digits. */ - - SetOptionValue( doc, option->id, buf ); - return yes; -} - -/* Coordinates Config update and Tags data */ -static void DeclareUserTag( TidyDocImpl* doc, TidyOptionId optId, - UserTagType tagType, ctmbstr name ) -{ - ctmbstr prvval = cfgStr( doc, optId ); - tmbstr catval = NULL; - ctmbstr theval = name; - if ( prvval ) - { - uint len = TY_(tmbstrlen)(name) + TY_(tmbstrlen)(prvval) + 3; - catval = TY_(tmbstrndup)( doc->allocator, prvval, len ); - TY_(tmbstrcat)( catval, ", " ); - TY_(tmbstrcat)( catval, name ); - theval = catval; - } - TY_(DefineTag)( doc, tagType, name ); - SetOptionValue( doc, optId, theval ); - if ( catval ) - TidyDocFree( doc, catval ); -} - -/* 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: - TY_(ReportUnknownOption)( doc, option->name ); - return no; - } - - SetOptionValue( doc, option->id, NULL ); - TY_(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 ( !TY_(IsWhite)(c) ) - { - buf[i] = 0; - TY_(UngetChar)( c, cfg->cfgIn ); - TY_(UngetChar)( '\n', cfg->cfgIn ); - break; - } - } - - /* - if ( c == '\n' ) - { - c = AdvanceChar( cfg ); - if ( !TY_(IsWhite)(c) ) - { - buf[i] = 0; - TY_(UngetChar)( c, cfg->cfgIn ); - TY_(UngetChar)( '\n', cfg->cfgIn ); - break; - } - } - */ - - while ( i < sizeof(buf)-2 && c != EndOfStream && !TY_(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 ); -} - -/* a string including whitespace */ -/* munges whitespace sequences */ - -Bool ParseString( TidyDocImpl* doc, const TidyOptionImpl* option ) -{ - TidyConfigImpl* cfg = &doc->config; - tmbchar buf[8192]; - uint i = 0; - tchar delim = 0; - Bool waswhite = yes; - - tchar c = SkipWhite( cfg ); - - if ( c == '"' || c == '\'' ) - { - delim = c; - c = AdvanceChar( cfg ); - } - - while ( i < sizeof(buf)-2 && c != EndOfStream && c != '\r' && c != '\n' ) - { - if ( delim && c == delim ) - break; - - if ( TY_(IsWhite)(c) ) - { - if ( waswhite ) - { - c = AdvanceChar( cfg ); - continue; - } - c = ' '; - } - else - waswhite = no; - - buf[i++] = (tmbchar) c; - c = AdvanceChar( cfg ); - } - buf[i] = '\0'; - - SetOptionValue( doc, option->id, buf ); - return yes; -} - -Bool ParseCharEnc( TidyDocImpl* doc, const TidyOptionImpl* option ) -{ - tmbchar buf[64] = {0}; - uint i = 0; - int enc = ASCII; - Bool validEncoding = yes; - tchar c = SkipWhite( &doc->config ); - - while ( i < sizeof(buf)-2 && c != EndOfStream && !TY_(IsWhite)(c) ) - { - buf[i++] = (tmbchar) TY_(ToLower)( c ); - c = AdvanceChar( &doc->config ); - } - buf[i] = 0; - - enc = TY_(CharEncodingId)( doc, buf ); - -#ifdef TIDY_WIN32_MLANG_SUPPORT - /* limit support to --input-encoding */ - if (option->id != TidyInCharEncoding && enc > WIN32MLANG) - enc = -1; -#endif - - if ( enc < 0 ) - { - validEncoding = no; - TY_(ReportBadArgument)( doc, option->name ); - } - else - TY_(SetOptionInt)( doc, option->id, enc ); - - if ( validEncoding && option->id == TidyCharEncoding ) - TY_(AdjustCharEncoding)( doc, enc ); - return validEncoding; -} - - -int TY_(CharEncodingId)( TidyDocImpl* ARG_UNUSED(doc), ctmbstr charenc ) -{ - int enc = TY_(GetCharEncodingFromOptName)( charenc ); - -#ifdef TIDY_WIN32_MLANG_SUPPORT - if (enc == -1) - { - uint wincp = TY_(Win32MLangGetCPFromName)(doc->allocator, charenc); - if (wincp) - enc = wincp; - } -#endif - - return enc; -} - -ctmbstr TY_(CharEncodingName)( int encoding ) -{ - ctmbstr encodingName = TY_(GetEncodingNameFromTidyId)(encoding); - - if (!encodingName) - encodingName = "unknown"; - - return encodingName; -} - -ctmbstr TY_(CharEncodingOptName)( int encoding ) -{ - ctmbstr encodingName = TY_(GetEncodingOptNameFromTidyId)(encoding); - - if (!encodingName) - encodingName = "unknown"; - - return encodingName; -} - -/* - doctype: html5 | omit | auto | strict | loose | - - where the fpi is a string similar to - - "-//ACME//DTD HTML 3.14159//EN" -*/ -Bool ParseDocType( TidyDocImpl* doc, const TidyOptionImpl* option ) -{ - tmbchar buf[ 32 ] = {0}; - uint i = 0; - Bool status = yes; - TidyDoctypeModes dtmode = TidyDoctypeAuto; - - TidyConfigImpl* cfg = &doc->config; - tchar c = SkipWhite( cfg ); - - /* "-//ACME//DTD HTML 3.14159//EN" or similar */ - - if ( c == '"' || c == '\'' ) - { - status = ParseString(doc, option); - if (status) - TY_(SetOptionInt)( doc, TidyDoctypeMode, TidyDoctypeUser ); - - return status; - } - - /* read first word */ - while ( i < sizeof(buf)-1 && c != EndOfStream && !TY_(IsWhite)(c) ) - { - buf[i++] = (tmbchar) c; - c = AdvanceChar( cfg ); - } - buf[i] = '\0'; - - if ( TY_(tmbstrcasecmp)(buf, "auto") == 0 ) - dtmode = TidyDoctypeAuto; - else if ( TY_(tmbstrcasecmp)(buf, "html5") == 0 ) - dtmode = TidyDoctypeHtml5; - else if ( TY_(tmbstrcasecmp)(buf, "omit") == 0 ) - dtmode = TidyDoctypeOmit; - else if ( TY_(tmbstrcasecmp)(buf, "strict") == 0 ) - dtmode = TidyDoctypeStrict; - else if ( TY_(tmbstrcasecmp)(buf, "loose") == 0 || - TY_(tmbstrcasecmp)(buf, "transitional") == 0 ) - dtmode = TidyDoctypeLoose; - else - { - TY_(ReportBadArgument)( doc, option->name ); - status = no; - } - - if ( status ) - TY_(SetOptionInt)( doc, TidyDoctypeMode, dtmode ); - return status; -} - -Bool ParseRepeatAttr( TidyDocImpl* doc, const TidyOptionImpl* option ) -{ - Bool status = yes; - tmbchar buf[64] = {0}; - uint i = 0; - - TidyConfigImpl* cfg = &doc->config; - tchar c = SkipWhite( cfg ); - - while (i < sizeof(buf)-1 && c != EndOfStream && !TY_(IsWhite)(c)) - { - buf[i++] = (tmbchar) c; - c = AdvanceChar( cfg ); - } - buf[i] = '\0'; - - if ( TY_(tmbstrcasecmp)(buf, "keep-first") == 0 ) - cfg->value[ TidyDuplicateAttrs ].v = TidyKeepFirst; - else if ( TY_(tmbstrcasecmp)(buf, "keep-last") == 0 ) - cfg->value[ TidyDuplicateAttrs ].v = TidyKeepLast; - else - { - TY_(ReportBadArgument)( doc, option->name ); - status = no; - } - return status; -} - -Bool ParseSorter( TidyDocImpl* doc, const TidyOptionImpl* option ) -{ - Bool status = yes; - tmbchar buf[64] = {0}; - uint i = 0; - - TidyConfigImpl* cfg = &doc->config; - tchar c = SkipWhite( cfg ); - - while (i < sizeof(buf)-1 && c != EndOfStream && !TY_(IsWhite)(c)) - { - buf[i++] = (tmbchar) c; - c = AdvanceChar( cfg ); - } - buf[i] = '\0'; - - if ( TY_(tmbstrcasecmp)(buf, "alpha") == 0 ) - cfg->value[ TidySortAttributes ].v = TidySortAttrAlpha; - else if ( TY_(tmbstrcasecmp)(buf, "none") == 0) - cfg->value[ TidySortAttributes ].v = TidySortAttrNone; - else - { - TY_(ReportBadArgument)( doc, option->name ); - status = no; - } - return status; -} - -/* Use TidyOptionId as iterator. -** Send index of 1st option after TidyOptionUnknown as start of list. -*/ -TidyIterator TY_(getOptionList)( TidyDocImpl* ARG_UNUSED(doc) ) -{ - return (TidyIterator) (size_t)1; -} - -/* Check if this item is last valid option. -** If so, zero out iterator. -*/ -const TidyOptionImpl* TY_(getNextOption)( TidyDocImpl* ARG_UNUSED(doc), - TidyIterator* iter ) -{ - const TidyOptionImpl* option = NULL; - size_t optId; - assert( iter != NULL ); - optId = (size_t) *iter; - if ( optId > TidyUnknownOption && optId < N_TIDY_OPTIONS ) - { - option = &option_defs[ optId ]; - optId++; - } - *iter = (TidyIterator) ( optId < N_TIDY_OPTIONS ? optId : (size_t)0 ); - return option; -} - -/* Use a 1-based array index as iterator: 0 == end-of-list -*/ -TidyIterator TY_(getOptionPickList)( const TidyOptionImpl* option ) -{ - size_t ix = 0; - if ( option && option->pickList ) - ix = 1; - return (TidyIterator) ix; -} - -ctmbstr TY_(getNextOptionPick)( const TidyOptionImpl* option, - TidyIterator* iter ) -{ - size_t ix; - ctmbstr val = NULL; - assert( option!=NULL && iter != NULL ); - - ix = (size_t) *iter; - if ( ix > 0 && ix < 16 && option->pickList ) - val = option->pickList[ ix-1 ]; - *iter = (TidyIterator) ( val && option->pickList[ix] ? ix + 1 : (size_t)0 ); - return val; -} - -static int WriteOptionString( const TidyOptionImpl* option, - ctmbstr sval, StreamOut* out ) -{ - ctmbstr cp = option->name; - while ( *cp ) - TY_(WriteChar)( *cp++, out ); - TY_(WriteChar)( ':', out ); - TY_(WriteChar)( ' ', out ); - cp = sval; - while ( *cp ) - TY_(WriteChar)( *cp++, out ); - TY_(WriteChar)( '\n', out ); - return 0; -} - -static int WriteOptionInt( const TidyOptionImpl* option, uint ival, StreamOut* out ) -{ - tmbchar sval[ 32 ] = {0}; - TY_(tmbsnprintf)(sval, sizeof(sval), "%u", ival ); - return WriteOptionString( option, sval, out ); -} - -static int WriteOptionBool( const TidyOptionImpl* option, Bool bval, StreamOut* out ) -{ - ctmbstr sval = bval ? "yes" : "no"; - return WriteOptionString( option, sval, out ); -} - -static int WriteOptionPick( const TidyOptionImpl* option, uint ival, StreamOut* out ) -{ - uint ix; - const ctmbstr* val = option->pickList; - for ( ix=0; val[ix] && ixconfig.value, &doc->config.snapshot, - N_TIDY_OPTIONS * sizeof(uint) ); - return ( diff != 0 ); -} - -Bool TY_(ConfigDiffThanDefault)( TidyDocImpl* doc ) -{ - Bool diff = no; - const TidyOptionImpl* option = option_defs + 1; - const TidyOptionValue* val = doc->config.value; - for ( /**/; !diff && option && option->name; ++option, ++val ) - { - diff = !OptionValueEqDefault( option, val ); - } - return diff; -} - - -static int SaveConfigToStream( TidyDocImpl* doc, StreamOut* out ) -{ - int rc = 0; - const TidyOptionImpl* option; - for ( option=option_defs+1; 0==rc && option && option->name; ++option ) - { - const TidyOptionValue* val = &doc->config.value[ option->id ]; - if ( option->parser == NULL ) - continue; - if ( OptionValueEqDefault( option, val ) && option->id != TidyDoctype) - continue; - - if ( option->id == TidyDoctype ) /* Special case */ - { - uint dtmode = cfg( doc, TidyDoctypeMode ); - if ( dtmode == TidyDoctypeUser ) - { - tmbstr t; - - /* add 2 double quotes */ - if (( t = (tmbstr)TidyDocAlloc( doc, TY_(tmbstrlen)( val->p ) + 2 ) )) - { - t[0] = '\"'; t[1] = 0; - - TY_(tmbstrcat)( t, val->p ); - TY_(tmbstrcat)( t, "\"" ); - rc = WriteOptionString( option, t, out ); - - TidyDocFree( doc, t ); - } - } - else if ( dtmode == option_defs[TidyDoctypeMode].dflt ) - continue; - else - rc = WriteOptionPick( option, dtmode, out ); - } - else if ( option->pickList ) - rc = WriteOptionPick( option, val->v, out ); - else - { - switch ( option->type ) - { - case TidyString: - rc = WriteOptionString( option, val->p, out ); - break; - case TidyInteger: - rc = WriteOptionInt( option, val->v, out ); - break; - case TidyBoolean: - rc = WriteOptionBool( option, val->v ? yes : no, out ); - break; - } - } - } - return rc; -} - -int TY_(SaveConfigFile)( TidyDocImpl* doc, ctmbstr cfgfil ) -{ - int status = -1; - StreamOut* out = NULL; - uint outenc = cfg( doc, TidyOutCharEncoding ); - uint nl = cfg( doc, TidyNewline ); - FILE* fout = fopen( cfgfil, "wb" ); - if ( fout ) - { - out = TY_(FileOutput)( doc, fout, outenc, nl ); - status = SaveConfigToStream( doc, out ); - fclose( fout ); - TidyDocFree( doc, out ); - } - return status; -} - -int TY_(SaveConfigSink)( TidyDocImpl* doc, TidyOutputSink* sink ) -{ - uint outenc = cfg( doc, TidyOutCharEncoding ); - uint nl = cfg( doc, TidyNewline ); - StreamOut* out = TY_(UserOutput)( doc, sink, outenc, nl ); - int status = SaveConfigToStream( doc, out ); - TidyDocFree( doc, out ); - return status; -} - -/* - * local variables: - * mode: c - * indent-tabs-mode: nil - * c-basic-offset: 4 - * eval: (c-set-offset 'substatement-open 0) - * end: - */ http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/config.h ---------------------------------------------------------------------- diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/config.h b/DocFormats/3rdparty/external/w3c-tidy-html5/src/config.h deleted file mode 100644 index 9132308..0000000 --- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/config.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -/* config.h -- read config file and manage config properties - - (c) 1998-2006 (W3C) MIT, ERCIM, Keio University - See tidy.h for the copyright notice. - - config files associate a property name with a value. - - // comments can start at the beginning of a line - # comments can start at the beginning of a line - name: short values fit onto one line - name: a really long value that - continues on the next line - - property names are case insensitive and should be less than - 60 characters in length and must start at the begining of - the line, as whitespace at the start of a line signifies a - line continuation. - -*/ - -#include "forward.h" -#include "tidy.h" -#include "streamio.h" - -struct _tidy_option; -typedef struct _tidy_option TidyOptionImpl; - -typedef Bool (ParseProperty)( TidyDocImpl* doc, const TidyOptionImpl* opt ); - -struct _tidy_option -{ - TidyOptionId id; - TidyConfigCategory category; /* put 'em in groups */ - ctmbstr name; /* property name */ - TidyOptionType type; /* string, int or bool */ - unsigned long long dflt; /* default for TidyInteger and TidyBoolean */ - ParseProperty* parser; /* parsing method, read-only if NULL */ - const ctmbstr* pickList; /* pick list */ - ctmbstr pdflt; /* default for TidyString */ -}; - -typedef union -{ - uint v; /* Value for TidyInteger and TidyBoolean */ - char *p; /* Value for TidyString */ -} TidyOptionValue; - -typedef struct _tidy_config -{ - TidyOptionValue value[ N_TIDY_OPTIONS + 1 ]; /* current config values */ - TidyOptionValue snapshot[ N_TIDY_OPTIONS + 1 ]; /* Snapshot of values to be restored later */ - - /* track what tags user has defined to eliminate unnecessary searches */ - uint defined_tags; - - uint c; /* current char in input stream */ - StreamIn* cfgIn; /* current input source */ - -} TidyConfigImpl; - - -typedef struct { - TidyOptionId opt; /**< Identifier. */ - ctmbstr doc; /**< HTML text */ - TidyOptionId const *links; /**< Cross references. - Last element must be 'TidyUnknownOption'. */ -} TidyOptionDoc; - - -const TidyOptionImpl* TY_(lookupOption)( ctmbstr optnam ); -const TidyOptionImpl* TY_(getOption)( TidyOptionId optId ); - -TidyIterator TY_(getOptionList)( TidyDocImpl* doc ); -const TidyOptionImpl* TY_(getNextOption)( TidyDocImpl* doc, TidyIterator* iter ); - -TidyIterator TY_(getOptionPickList)( const TidyOptionImpl* option ); -ctmbstr TY_(getNextOptionPick)( const TidyOptionImpl* option, TidyIterator* iter ); - -const TidyOptionDoc* TY_(OptGetDocDesc)( TidyOptionId optId ); - -void TY_(InitConfig)( TidyDocImpl* doc ); -void TY_(FreeConfig)( TidyDocImpl* doc ); - -/* Bool SetOptionValue( TidyDocImpl* doc, TidyOptionId optId, ctmbstr val ); */ -Bool TY_(SetOptionInt)( TidyDocImpl* doc, TidyOptionId optId, uint val ); -Bool TY_(SetOptionBool)( TidyDocImpl* doc, TidyOptionId optId, Bool val ); - -Bool TY_(ResetOptionToDefault)( TidyDocImpl* doc, TidyOptionId optId ); -void TY_(ResetConfigToDefault)( TidyDocImpl* doc ); -void TY_(TakeConfigSnapshot)( TidyDocImpl* doc ); -void TY_(ResetConfigToSnapshot)( TidyDocImpl* doc ); - -void TY_(CopyConfig)( TidyDocImpl* docTo, TidyDocImpl* docFrom ); - -int TY_(ParseConfigFile)( TidyDocImpl* doc, ctmbstr cfgfil ); -int TY_(ParseConfigFileEnc)( TidyDocImpl* doc, - ctmbstr cfgfil, ctmbstr charenc ); - -int TY_(SaveConfigFile)( TidyDocImpl* doc, ctmbstr cfgfil ); -int TY_(SaveConfigSink)( TidyDocImpl* doc, TidyOutputSink* sink ); - -/* returns false if unknown option, missing parameter, or - option doesn't use parameter -*/ -Bool TY_(ParseConfigOption)( TidyDocImpl* doc, ctmbstr optnam, ctmbstr optVal ); -Bool TY_(ParseConfigValue)( TidyDocImpl* doc, TidyOptionId optId, ctmbstr optVal ); - -/* ensure that char encodings are self consistent */ -Bool TY_(AdjustCharEncoding)( TidyDocImpl* doc, int encoding ); - -Bool TY_(ConfigDiffThanDefault)( TidyDocImpl* doc ); -Bool TY_(ConfigDiffThanSnapshot)( TidyDocImpl* doc ); - -int TY_(CharEncodingId)( TidyDocImpl* doc, ctmbstr charenc ); -ctmbstr TY_(CharEncodingName)( int encoding ); -ctmbstr TY_(CharEncodingOptName)( int encoding ); - -/* void SetEmacsFilename( TidyDocImpl* doc, ctmbstr filename ); */ - - -#ifdef _DEBUG - -/* Debug lookup functions will be type-safe and assert option type match */ -uint TY_(_cfgGet)( TidyDocImpl* doc, TidyOptionId optId ); -Bool TY_(_cfgGetBool)( TidyDocImpl* doc, TidyOptionId optId ); -TidyTriState TY_(_cfgGetAutoBool)( TidyDocImpl* doc, TidyOptionId optId ); -ctmbstr TY_(_cfgGetString)( TidyDocImpl* doc, TidyOptionId optId ); - -#define cfg(doc, id) TY_(_cfgGet)( (doc), (id) ) -#define cfgBool(doc, id) TY_(_cfgGetBool)( (doc), (id) ) -#define cfgAutoBool(doc, id) TY_(_cfgGetAutoBool)( (doc), (id) ) -#define cfgStr(doc, id) TY_(_cfgGetString)( (doc), (id) ) - -#else - -/* Release build macros for speed */ -#define cfg(doc, id) ((doc)->config.value[ (id) ].v) -#define cfgBool(doc, id) ((Bool) cfg(doc, id)) -#define cfgAutoBool(doc, id) ((TidyTriState) cfg(doc, id)) -#define cfgStr(doc, id) ((ctmbstr) (doc)->config.value[ (id) ].p) - -#endif /* _DEBUG */ - -#endif /* __CONFIG_H__ */ http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/entities.c ---------------------------------------------------------------------- diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/entities.c b/DocFormats/3rdparty/external/w3c-tidy-html5/src/entities.c deleted file mode 100644 index 591d040..0000000 --- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/entities.c +++ /dev/null @@ -1,413 +0,0 @@ -/* entities.c -- recognize HTML ISO entities - - (c) 1998-2008 (W3C) MIT, ERCIM, Keio University - See tidy.h for the copyright notice. - - Entity handling can be static because there are no config or - document-specific values. Lookup table is 100% defined at - compile time. - -*/ - -#include -#include "entities.h" -#include "tidy-int.h" -#include "tmbstr.h" - -struct _entity; -typedef struct _entity entity; - -struct _entity -{ - ctmbstr name; - uint versions; - uint code; -}; - - -static const entity entities[] = -{ - /* - ** Markup pre-defined character entities - */ - { "quot", VERS_ALL|VERS_XML, 34 }, - { "amp", VERS_ALL|VERS_XML, 38 }, - { "apos", VERS_FROM40|VERS_XML, 39 }, - { "lt", VERS_ALL|VERS_XML, 60 }, - { "gt", VERS_ALL|VERS_XML, 62 }, - - /* - ** Latin-1 character entities - */ - { "nbsp", VERS_ALL, 160 }, - { "iexcl", VERS_ALL, 161 }, - { "cent", VERS_ALL, 162 }, - { "pound", VERS_ALL, 163 }, - { "curren", VERS_ALL, 164 }, - { "yen", VERS_ALL, 165 }, - { "brvbar", VERS_ALL, 166 }, - { "sect", VERS_ALL, 167 }, - { "uml", VERS_ALL, 168 }, - { "copy", VERS_ALL, 169 }, - { "ordf", VERS_ALL, 170 }, - { "laquo", VERS_ALL, 171 }, - { "not", VERS_ALL, 172 }, - { "shy", VERS_ALL, 173 }, - { "reg", VERS_ALL, 174 }, - { "macr", VERS_ALL, 175 }, - { "deg", VERS_ALL, 176 }, - { "plusmn", VERS_ALL, 177 }, - { "sup2", VERS_ALL, 178 }, - { "sup3", VERS_ALL, 179 }, - { "acute", VERS_ALL, 180 }, - { "micro", VERS_ALL, 181 }, - { "para", VERS_ALL, 182 }, - { "middot", VERS_ALL, 183 }, - { "cedil", VERS_ALL, 184 }, - { "sup1", VERS_ALL, 185 }, - { "ordm", VERS_ALL, 186 }, - { "raquo", VERS_ALL, 187 }, - { "frac14", VERS_ALL, 188 }, - { "frac12", VERS_ALL, 189 }, - { "frac34", VERS_ALL, 190 }, - { "iquest", VERS_ALL, 191 }, - { "Agrave", VERS_ALL, 192 }, - { "Aacute", VERS_ALL, 193 }, - { "Acirc", VERS_ALL, 194 }, - { "Atilde", VERS_ALL, 195 }, - { "Auml", VERS_ALL, 196 }, - { "Aring", VERS_ALL, 197 }, - { "AElig", VERS_ALL, 198 }, - { "Ccedil", VERS_ALL, 199 }, - { "Egrave", VERS_ALL, 200 }, - { "Eacute", VERS_ALL, 201 }, - { "Ecirc", VERS_ALL, 202 }, - { "Euml", VERS_ALL, 203 }, - { "Igrave", VERS_ALL, 204 }, - { "Iacute", VERS_ALL, 205 }, - { "Icirc", VERS_ALL, 206 }, - { "Iuml", VERS_ALL, 207 }, - { "ETH", VERS_ALL, 208 }, - { "Ntilde", VERS_ALL, 209 }, - { "Ograve", VERS_ALL, 210 }, - { "Oacute", VERS_ALL, 211 }, - { "Ocirc", VERS_ALL, 212 }, - { "Otilde", VERS_ALL, 213 }, - { "Ouml", VERS_ALL, 214 }, - { "times", VERS_ALL, 215 }, - { "Oslash", VERS_ALL, 216 }, - { "Ugrave", VERS_ALL, 217 }, - { "Uacute", VERS_ALL, 218 }, - { "Ucirc", VERS_ALL, 219 }, - { "Uuml", VERS_ALL, 220 }, - { "Yacute", VERS_ALL, 221 }, - { "THORN", VERS_ALL, 222 }, - { "szlig", VERS_ALL, 223 }, - { "agrave", VERS_ALL, 224 }, - { "aacute", VERS_ALL, 225 }, - { "acirc", VERS_ALL, 226 }, - { "atilde", VERS_ALL, 227 }, - { "auml", VERS_ALL, 228 }, - { "aring", VERS_ALL, 229 }, - { "aelig", VERS_ALL, 230 }, - { "ccedil", VERS_ALL, 231 }, - { "egrave", VERS_ALL, 232 }, - { "eacute", VERS_ALL, 233 }, - { "ecirc", VERS_ALL, 234 }, - { "euml", VERS_ALL, 235 }, - { "igrave", VERS_ALL, 236 }, - { "iacute", VERS_ALL, 237 }, - { "icirc", VERS_ALL, 238 }, - { "iuml", VERS_ALL, 239 }, - { "eth", VERS_ALL, 240 }, - { "ntilde", VERS_ALL, 241 }, - { "ograve", VERS_ALL, 242 }, - { "oacute", VERS_ALL, 243 }, - { "ocirc", VERS_ALL, 244 }, - { "otilde", VERS_ALL, 245 }, - { "ouml", VERS_ALL, 246 }, - { "divide", VERS_ALL, 247 }, - { "oslash", VERS_ALL, 248 }, - { "ugrave", VERS_ALL, 249 }, - { "uacute", VERS_ALL, 250 }, - { "ucirc", VERS_ALL, 251 }, - { "uuml", VERS_ALL, 252 }, - { "yacute", VERS_ALL, 253 }, - { "thorn", VERS_ALL, 254 }, - { "yuml", VERS_ALL, 255 }, - - /* - ** Extended Entities defined in HTML 4: Symbols - */ - { "fnof", VERS_FROM40, 402 }, - { "Alpha", VERS_FROM40, 913 }, - { "Beta", VERS_FROM40, 914 }, - { "Gamma", VERS_FROM40, 915 }, - { "Delta", VERS_FROM40, 916 }, - { "Epsilon", VERS_FROM40, 917 }, - { "Zeta", VERS_FROM40, 918 }, - { "Eta", VERS_FROM40, 919 }, - { "Theta", VERS_FROM40, 920 }, - { "Iota", VERS_FROM40, 921 }, - { "Kappa", VERS_FROM40, 922 }, - { "Lambda", VERS_FROM40, 923 }, - { "Mu", VERS_FROM40, 924 }, - { "Nu", VERS_FROM40, 925 }, - { "Xi", VERS_FROM40, 926 }, - { "Omicron", VERS_FROM40, 927 }, - { "Pi", VERS_FROM40, 928 }, - { "Rho", VERS_FROM40, 929 }, - { "Sigma", VERS_FROM40, 931 }, - { "Tau", VERS_FROM40, 932 }, - { "Upsilon", VERS_FROM40, 933 }, - { "Phi", VERS_FROM40, 934 }, - { "Chi", VERS_FROM40, 935 }, - { "Psi", VERS_FROM40, 936 }, - { "Omega", VERS_FROM40, 937 }, - { "alpha", VERS_FROM40, 945 }, - { "beta", VERS_FROM40, 946 }, - { "gamma", VERS_FROM40, 947 }, - { "delta", VERS_FROM40, 948 }, - { "epsilon", VERS_FROM40, 949 }, - { "zeta", VERS_FROM40, 950 }, - { "eta", VERS_FROM40, 951 }, - { "theta", VERS_FROM40, 952 }, - { "iota", VERS_FROM40, 953 }, - { "kappa", VERS_FROM40, 954 }, - { "lambda", VERS_FROM40, 955 }, - { "mu", VERS_FROM40, 956 }, - { "nu", VERS_FROM40, 957 }, - { "xi", VERS_FROM40, 958 }, - { "omicron", VERS_FROM40, 959 }, - { "pi", VERS_FROM40, 960 }, - { "rho", VERS_FROM40, 961 }, - { "sigmaf", VERS_FROM40, 962 }, - { "sigma", VERS_FROM40, 963 }, - { "tau", VERS_FROM40, 964 }, - { "upsilon", VERS_FROM40, 965 }, - { "phi", VERS_FROM40, 966 }, - { "chi", VERS_FROM40, 967 }, - { "psi", VERS_FROM40, 968 }, - { "omega", VERS_FROM40, 969 }, - { "thetasym", VERS_FROM40, 977 }, - { "upsih", VERS_FROM40, 978 }, - { "piv", VERS_FROM40, 982 }, - { "bull", VERS_FROM40, 8226 }, - { "hellip", VERS_FROM40, 8230 }, - { "prime", VERS_FROM40, 8242 }, - { "Prime", VERS_FROM40, 8243 }, - { "oline", VERS_FROM40, 8254 }, - { "frasl", VERS_FROM40, 8260 }, - { "weierp", VERS_FROM40, 8472 }, - { "image", VERS_FROM40, 8465 }, - { "real", VERS_FROM40, 8476 }, - { "trade", VERS_FROM40, 8482 }, - { "alefsym", VERS_FROM40, 8501 }, - { "larr", VERS_FROM40, 8592 }, - { "uarr", VERS_FROM40, 8593 }, - { "rarr", VERS_FROM40, 8594 }, - { "darr", VERS_FROM40, 8595 }, - { "harr", VERS_FROM40, 8596 }, - { "crarr", VERS_FROM40, 8629 }, - { "lArr", VERS_FROM40, 8656 }, - { "uArr", VERS_FROM40, 8657 }, - { "rArr", VERS_FROM40, 8658 }, - { "dArr", VERS_FROM40, 8659 }, - { "hArr", VERS_FROM40, 8660 }, - { "forall", VERS_FROM40, 8704 }, - { "part", VERS_FROM40, 8706 }, - { "exist", VERS_FROM40, 8707 }, - { "empty", VERS_FROM40, 8709 }, - { "nabla", VERS_FROM40, 8711 }, - { "isin", VERS_FROM40, 8712 }, - { "notin", VERS_FROM40, 8713 }, - { "ni", VERS_FROM40, 8715 }, - { "prod", VERS_FROM40, 8719 }, - { "sum", VERS_FROM40, 8721 }, - { "minus", VERS_FROM40, 8722 }, - { "lowast", VERS_FROM40, 8727 }, - { "radic", VERS_FROM40, 8730 }, - { "prop", VERS_FROM40, 8733 }, - { "infin", VERS_FROM40, 8734 }, - { "ang", VERS_FROM40, 8736 }, - { "and", VERS_FROM40, 8743 }, - { "or", VERS_FROM40, 8744 }, - { "cap", VERS_FROM40, 8745 }, - { "cup", VERS_FROM40, 8746 }, - { "int", VERS_FROM40, 8747 }, - { "there4", VERS_FROM40, 8756 }, - { "sim", VERS_FROM40, 8764 }, - { "cong", VERS_FROM40, 8773 }, - { "asymp", VERS_FROM40, 8776 }, - { "ne", VERS_FROM40, 8800 }, - { "equiv", VERS_FROM40, 8801 }, - { "le", VERS_FROM40, 8804 }, - { "ge", VERS_FROM40, 8805 }, - { "sub", VERS_FROM40, 8834 }, - { "sup", VERS_FROM40, 8835 }, - { "nsub", VERS_FROM40, 8836 }, - { "sube", VERS_FROM40, 8838 }, - { "supe", VERS_FROM40, 8839 }, - { "oplus", VERS_FROM40, 8853 }, - { "otimes", VERS_FROM40, 8855 }, - { "perp", VERS_FROM40, 8869 }, - { "sdot", VERS_FROM40, 8901 }, - { "lceil", VERS_FROM40, 8968 }, - { "rceil", VERS_FROM40, 8969 }, - { "lfloor", VERS_FROM40, 8970 }, - { "rfloor", VERS_FROM40, 8971 }, - { "lang", VERS_FROM40, 9001 }, - { "rang", VERS_FROM40, 9002 }, - { "loz", VERS_FROM40, 9674 }, - { "spades", VERS_FROM40, 9824 }, - { "clubs", VERS_FROM40, 9827 }, - { "hearts", VERS_FROM40, 9829 }, - { "diams", VERS_FROM40, 9830 }, - - /* - ** Extended Entities defined in HTML 4: Special (less Markup at top) - */ - { "OElig", VERS_FROM40, 338 }, - { "oelig", VERS_FROM40, 339 }, - { "Scaron", VERS_FROM40, 352 }, - { "scaron", VERS_FROM40, 353 }, - { "Yuml", VERS_FROM40, 376 }, - { "circ", VERS_FROM40, 710 }, - { "tilde", VERS_FROM40, 732 }, - { "ensp", VERS_FROM40, 8194 }, - { "emsp", VERS_FROM40, 8195 }, - { "thinsp", VERS_FROM40, 8201 }, - { "zwnj", VERS_FROM40, 8204 }, - { "zwj", VERS_FROM40, 8205 }, - { "lrm", VERS_FROM40, 8206 }, - { "rlm", VERS_FROM40, 8207 }, - { "ndash", VERS_FROM40, 8211 }, - { "mdash", VERS_FROM40, 8212 }, - { "lsquo", VERS_FROM40, 8216 }, - { "rsquo", VERS_FROM40, 8217 }, - { "sbquo", VERS_FROM40, 8218 }, - { "ldquo", VERS_FROM40, 8220 }, - { "rdquo", VERS_FROM40, 8221 }, - { "bdquo", VERS_FROM40, 8222 }, - { "dagger", VERS_FROM40, 8224 }, - { "Dagger", VERS_FROM40, 8225 }, - { "permil", VERS_FROM40, 8240 }, - { "lsaquo", VERS_FROM40, 8249 }, - { "rsaquo", VERS_FROM40, 8250 }, - { "euro", VERS_FROM40, 8364 }, - { NULL, VERS_UNKNOWN, 0 } -}; - - -/* Pure static implementation. Trades off lookup speed -** for faster setup time (well, none actually). -** Optimization of comparing 1st character buys enough -** speed that hash doesn't improve things without > 500 -** items in list. -*/ -static const entity* entitiesLookup( ctmbstr s ) -{ - tmbchar ch = (tmbchar)( s ? *s : 0 ); - const entity *np; - for ( np = entities; ch && np && np->name; ++np ) - if ( ch == *np->name && TY_(tmbstrcmp)(s, np->name) == 0 ) - return np; - return NULL; -} - -#if 0 -/* entity starting with "&" returns zero on error */ -uint EntityCode( ctmbstr name, uint versions ) -{ - const entity* np; - assert( name && name[0] == '&' ); - - /* numeric entitity: name = "&#" followed by number */ - if ( name[1] == '#' ) - { - uint c = 0; /* zero on missing/bad number */ - Bool isXml = ( (versions & VERS_XML) == VERS_XML ); - - /* 'x' prefix denotes hexadecimal number format */ - if ( name[2] == 'x' || (!isXml && name[2] == 'X') ) - sscanf( name+3, "%x", &c ); - else - sscanf( name+2, "%u", &c ); - - return (uint) c; - } - - /* Named entity: name ="&" followed by a name */ - if ( NULL != (np = entitiesLookup(name+1)) ) - { - /* Only recognize entity name if version supports it. */ - if ( np->versions & versions ) - return np->code; - } - - return 0; /* zero signifies unknown entity name */ -} -#endif - -Bool TY_(EntityInfo)( ctmbstr name, Bool isXml, uint* code, uint* versions ) -{ - const entity* np; - assert( name && name[0] == '&' ); - assert( code != NULL ); - assert( versions != NULL ); - - /* numeric entitity: name = "&#" followed by number */ - if ( name[1] == '#' ) - { - uint c = 0; /* zero on missing/bad number */ - - /* 'x' prefix denotes hexadecimal number format */ - if ( name[2] == 'x' || (!isXml && name[2] == 'X') ) - sscanf( name+3, "%x", &c ); - else - sscanf( name+2, "%u", &c ); - - *code = c; - *versions = VERS_ALL; - return yes; - } - - /* Named entity: name ="&" followed by a name */ - if ( NULL != (np = entitiesLookup(name+1)) ) - { - *code = np->code; - *versions = np->versions; - return yes; - } - - *code = 0; - *versions = ( isXml ? VERS_XML : VERS_PROPRIETARY ); - return no; -} - - -ctmbstr TY_(EntityName)( uint ch, uint versions ) -{ - ctmbstr entnam = NULL; - const entity *ep; - - for ( ep = entities; ep->name != NULL; ++ep ) - { - if ( ep->code == ch ) - { - if ( ep->versions & versions ) - entnam = ep->name; - break; /* Found code. Stop search. */ - } - } - return entnam; -} - -/* - * local variables: - * mode: c - * indent-tabs-mode: nil - * c-basic-offset: 4 - * eval: (c-set-offset 'substatement-open 0) - * end: - */ http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/entities.h ---------------------------------------------------------------------- diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/entities.h b/DocFormats/3rdparty/external/w3c-tidy-html5/src/entities.h deleted file mode 100644 index 95533e4..0000000 --- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/entities.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ENTITIES_H__ -#define __ENTITIES_H__ - -/* entities.h -- recognize character entities - - (c) 1998-2006 (W3C) MIT, ERCIM, Keio University - See tidy.h for the copyright notice. - -*/ - -#include "forward.h" - -/* entity starting with "&" returns zero on error */ -/* uint EntityCode( ctmbstr name, uint versions ); */ -ctmbstr TY_(EntityName)( uint charCode, uint versions ); -Bool TY_(EntityInfo)( ctmbstr name, Bool isXml, uint* code, uint* versions ); - -#endif /* __ENTITIES_H__ */ http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/fileio.c ---------------------------------------------------------------------- diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/fileio.c b/DocFormats/3rdparty/external/w3c-tidy-html5/src/fileio.c deleted file mode 100644 index ae003a4..0000000 --- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/fileio.c +++ /dev/null @@ -1,100 +0,0 @@ -/* fileio.c -- does standard I/O - - (c) 1998-2007 (W3C) MIT, ERCIM, Keio University - See tidy.h for the copyright notice. - - Default implementations of Tidy input sources - and output sinks based on standard C FILE*. - -*/ - -#include - -#include "forward.h" -#include "fileio.h" -#include "tidy.h" - -typedef struct _fp_input_source -{ - FILE* fp; - TidyBuffer unget; -} FileSource; - -static int TIDY_CALL filesrc_getByte( void* sourceData ) -{ - FileSource* fin = (FileSource*) sourceData; - int bv; - if ( fin->unget.size > 0 ) - bv = tidyBufPopByte( &fin->unget ); - else - bv = fgetc( fin->fp ); - return bv; -} - -static Bool TIDY_CALL filesrc_eof( void* sourceData ) -{ - FileSource* fin = (FileSource*) sourceData; - Bool isEOF = ( fin->unget.size == 0 ); - if ( isEOF ) - isEOF = feof( fin->fp ) != 0; - return isEOF; -} - -static void TIDY_CALL filesrc_ungetByte( void* sourceData, byte bv ) -{ - FileSource* fin = (FileSource*) sourceData; - tidyBufPutByte( &fin->unget, bv ); -} - -#if SUPPORT_POSIX_MAPPED_FILES -#define initFileSource initStdIOFileSource -#define freeFileSource freeStdIOFileSource -#endif -int TY_(initFileSource)( TidyAllocator *allocator, TidyInputSource* inp, FILE* fp ) -{ - FileSource* fin = NULL; - - fin = (FileSource*) TidyAlloc( allocator, sizeof(FileSource) ); - if ( !fin ) - return -1; - TidyClearMemory( fin, sizeof(FileSource) ); - fin->unget.allocator = allocator; - fin->fp = fp; - - inp->getByte = filesrc_getByte; - inp->eof = filesrc_eof; - inp->ungetByte = filesrc_ungetByte; - inp->sourceData = fin; - - return 0; -} - -void TY_(freeFileSource)( TidyInputSource* inp, Bool closeIt ) -{ - FileSource* fin = (FileSource*) inp->sourceData; - if ( closeIt && fin && fin->fp ) - fclose( fin->fp ); - tidyBufFree( &fin->unget ); - TidyFree( fin->unget.allocator, fin ); -} - -void TIDY_CALL TY_(filesink_putByte)( void* sinkData, byte bv ) -{ - FILE* fout = (FILE*) sinkData; - fputc( bv, fout ); -} - -void TY_(initFileSink)( TidyOutputSink* outp, FILE* fp ) -{ - outp->putByte = TY_(filesink_putByte); - outp->sinkData = fp; -} - -/* - * local variables: - * mode: c - * indent-tabs-mode: nil - * c-basic-offset: 4 - * eval: (c-set-offset 'substatement-open 0) - * end: - */ http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/fileio.h ---------------------------------------------------------------------- diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/fileio.h b/DocFormats/3rdparty/external/w3c-tidy-html5/src/fileio.h deleted file mode 100644 index c44afb4..0000000 --- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/fileio.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __FILEIO_H__ -#define __FILEIO_H__ - -/** @file fileio.h - does standard C I/O - - Implementation of a FILE* based TidyInputSource and - TidyOutputSink. - - (c) 1998-2007 (W3C) MIT, ERCIM, Keio University - See tidy.h for the copyright notice. - -*/ - -#include "buffio.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** Allocate and initialize file input source */ -int TY_(initFileSource)( TidyAllocator *allocator, TidyInputSource* source, FILE* fp ); - -/** Free file input source */ -void TY_(freeFileSource)( TidyInputSource* source, Bool closeIt ); - -#if SUPPORT_POSIX_MAPPED_FILES -/** Allocate and initialize file input source using Standard C I/O */ -int TY_(initStdIOFileSource)( TidyAllocator *allocator, TidyInputSource* source, FILE* fp ); - -/** Free file input source using Standard C I/O */ -void TY_(freeStdIOFileSource)( TidyInputSource* source, Bool closeIt ); -#endif - -/** Initialize file output sink */ -void TY_(initFileSink)( TidyOutputSink* sink, FILE* fp ); - -/* Needed for internal declarations */ -void TIDY_CALL TY_(filesink_putByte)( void* sinkData, byte bv ); - -#ifdef __cplusplus -} -#endif -#endif /* __FILEIO_H__ */ http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ac70cb0e/DocFormats/3rdparty/external/w3c-tidy-html5/src/forward.h ---------------------------------------------------------------------- diff --git a/DocFormats/3rdparty/external/w3c-tidy-html5/src/forward.h b/DocFormats/3rdparty/external/w3c-tidy-html5/src/forward.h deleted file mode 100644 index cb6ad94..0000000 --- a/DocFormats/3rdparty/external/w3c-tidy-html5/src/forward.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __FORWARD_H__ -#define __FORWARD_H__ - -/* forward.h -- Forward declarations for major Tidy structures - - (c) 1998-2007 (W3C) MIT, ERCIM, Keio University - See tidy.h for the copyright notice. - - Avoids many include file circular dependencies. - - Try to keep this file down to the minimum to avoid - cross-talk between modules. - - Header files include this file. C files include tidy-int.h. - -*/ - -#include "platform.h" -#include "tidy.h" - -/* Internal symbols are prefixed to avoid clashes with other libraries */ -#define TYDYAPPEND(str1,str2) str1##str2 -#define TY_(str) TYDYAPPEND(prvTidy,str) - -struct _StreamIn; -typedef struct _StreamIn StreamIn; - -struct _StreamOut; -typedef struct _StreamOut StreamOut; - -struct _TidyDocImpl; -typedef struct _TidyDocImpl TidyDocImpl; - - -struct _Dict; -typedef struct _Dict Dict; - -struct _Attribute; -typedef struct _Attribute Attribute; - -struct _AttVal; -typedef struct _AttVal AttVal; - -struct _Node; -typedef struct _Node Node; - -struct _IStack; -typedef struct _IStack IStack; - -struct _Lexer; -typedef struct _Lexer Lexer; - -extern TidyAllocator TY_(g_default_allocator); - -/** Wrappers for easy memory allocation using an allocator */ -#define TidyAlloc(allocator, size) ((allocator)->vtbl->alloc((allocator), (size))) -#define TidyRealloc(allocator, block, size) ((allocator)->vtbl->realloc((allocator), (block), (size))) -#define TidyFree(allocator, block) ((allocator)->vtbl->free((allocator), (block))) -#define TidyPanic(allocator, msg) ((allocator)->vtbl->panic((allocator), (msg))) -#define TidyClearMemory(block, size) memset((block), 0, (size)) - - -#endif /* __FORWARD_H__ */