⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 localize.c

📁 我搜集到的一个java常用类库的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  localize.c  (c) 1998-2000 (W3C) MIT, INRIA, Keio University  See tidy.c for the copyright notice.  You should only need to edit this file and tidy.c  to localize HTML tidy.*/#include "platform.h"#include "html.h"#define ACCESS_URL  "http://www.w3.org/WAI/GL"char *release_date = "13th January 2000";extern uint optionerrors;/* This routine is the single point via which all output is written and as such is a good way to interface Tidy to other code when embedding Tidy in a GUI application.*/void tidy_out(FILE *fp, const char* msg, ...){    va_list args;    va_start(args, msg);    vfprintf(fp, msg, args);    va_end(args);}void ReadingFromStdin(){    fprintf(stderr, "Reading markup from standard input ...\n");}void ShowVersion(FILE *fp){    tidy_out(fp, "HTML Tidy release date: %s\n"            "See http://www.w3.org/People/Raggett for details\n", release_date);}void FileError(FILE *fp, const char *file){    tidy_out(fp, "Can't open \"%s\"\n", file);}void ReportTag(Lexer *lexer, Node *tag){    if (tag)    {        if (tag->type == StartTag)            tidy_out(lexer->errout, "<%s>", tag->element);        else if (tag->type == EndTag)            tidy_out(lexer->errout, "</%s>", tag->element);        else if (tag->type == DocTypeTag)            tidy_out(lexer->errout, "<!DOCTYPE>");        else if (tag->type == TextNode)            tidy_out(lexer->errout, "plain text");        else            tidy_out(lexer->errout, "%s", tag->element);    }}/* lexer is not defined when this is called */void ReportUnknownOption(char *option){    optionerrors++;    fprintf(stderr, "Warning - unknown option: %s\n", option);}/* lexer is not defined when this is called */void ReportBadArgument(char *option){    optionerrors++;    fprintf(stderr, "Warning - missing or malformed argument for option: %s\n", option);}void NtoS(int n, char *str){    char buf[40];    int i;    for (i = 0;; ++i)    {        buf[i] = (n % 10) + '0';        n = n /10;        if (n == 0)            break;    }    n = i;    while (i >= 0)    {        str[n-i] = buf[i];        --i;    }    str[n+1] = '\0';}void ReportPosition(Lexer *lexer){    tidy_out(lexer->errout, "line %d", lexer->lines);    tidy_out(lexer->errout, " column %d - ", lexer->columns);}void ReportEncodingError(Lexer *lexer, uint code, uint c){    char buf[32];    lexer->warnings++;    if (ShowWarnings)    {        ReportPosition(lexer);        if (code == WINDOWS_CHARS)        {            NtoS(c, buf);            lexer->badChars |= WINDOWS_CHARS;            tidy_out(lexer->errout, "Warning: replacing illegal character code %s", buf);        }        tidy_out(lexer->errout, "\n");    }}void ReportEntityError(Lexer *lexer, uint code, char *entity, int c){    lexer->warnings++;    if (ShowWarnings)    {        ReportPosition(lexer);        if (code == MISSING_SEMICOLON)        {            tidy_out(lexer->errout, "Warning: entity \"%s\" doesn't end in ';'", entity);        }        else if (code == UNKNOWN_ENTITY)        {            tidy_out(lexer->errout, "Warning: unescaped & or unknown entity \"%s\"", entity);        }        else if (code == UNESCAPED_AMPERSAND)        {            tidy_out(lexer->errout, "Warning: unescaped & which should be written as &amp;");        }        tidy_out(lexer->errout, "\n");    }}void ReportAttrError(Lexer *lexer, Node *node, char *attr, uint code){    lexer->warnings++;    /* keep quiet after 6 errors */    if (lexer->errors > 6)        return;    if (ShowWarnings)    {        /* on end of file adjust reported position to end of input */        if (code == UNEXPECTED_END_OF_FILE)        {            lexer->lines = lexer->in->curline;            lexer->columns = lexer->in->curcol;        }        ReportPosition(lexer);        if (code == UNKNOWN_ATTRIBUTE)            tidy_out(lexer->errout, "Warning: unknown attribute \"%s\"", attr);        else if (code == MISSING_ATTRIBUTE)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " lacks \"%s\" attribute", attr);        }        else if (code == MISSING_ATTR_VALUE)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " attribute \"%s\" lacks value", attr);        }        else if (code == MISSING_IMAGEMAP)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " should use client-side image map");            lexer->badAccess |= MISSING_IMAGE_MAP;        }        else if (code == BAD_ATTRIBUTE_VALUE)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " unknown attribute value \"%s\"", attr);        }        else if (code == XML_ATTRIBUTE_VALUE)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " has XML attribute \"%s\"", attr);        }        else if (code == UNEXPECTED_GT)        {            tidy_out(lexer->errout, "Error: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " missing '>' for end of tag");            lexer->errors++;;        }        else if (code == UNEXPECTED_QUOTEMARK)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " unexpected or duplicate quote mark");        }        else if (code == REPEATED_ATTRIBUTE)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " repeated attribute \"%s\"", attr);        }        else if (code == PROPRIETARY_ATTR_VALUE)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " proprietary attribute value \"%s\"", attr);        }        else if (code == UNEXPECTED_END_OF_FILE)        {            tidy_out(lexer->errout, "Warning: end of file while parsing attributes");        }        else if (code == ID_NAME_MISMATCH)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " id and name attribute value mismatch");        }        tidy_out(lexer->errout, "\n");    }    else if (code == UNEXPECTED_GT)    {        ReportPosition(lexer);        tidy_out(lexer->errout, "Error: ");        ReportTag(lexer, node);        tidy_out(lexer->errout, " missing '>' for end of tag\n");        lexer->errors++;;    }}void ReportWarning(Lexer *lexer, Node *element, Node *node, uint code){    lexer->warnings++;    /* keep quiet after 6 errors */    if (lexer->errors > 6)        return;    if (ShowWarnings)    {        /* on end of file adjust reported position to end of input */        if (code == UNEXPECTED_END_OF_FILE)        {            lexer->lines = lexer->in->curline;            lexer->columns = lexer->in->curcol;        }        ReportPosition(lexer);        if (code == MISSING_ENDTAG_FOR)            tidy_out(lexer->errout, "Warning: missing </%s>", element->element);        else if (code == MISSING_ENDTAG_BEFORE)        {            tidy_out(lexer->errout, "Warning: missing </%s> before ", element->element);            ReportTag(lexer, node);        }        else if (code == DISCARDING_UNEXPECTED)        {            tidy_out(lexer->errout, "Warning: discarding unexpected ");            ReportTag(lexer, node);        }        else if (code == NESTED_EMPHASIS)        {            tidy_out(lexer->errout, "Warning: nested emphasis ");            ReportTag(lexer, node);        }        else if (code == COERCE_TO_ENDTAG)        {            tidy_out(lexer->errout, "Warning: <%s> is probably intended as </%s>",                node->element, node->element);        }        else if (code == NON_MATCHING_ENDTAG)        {            tidy_out(lexer->errout, "Warning: replacing unexpected ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " by </%s>", element->element);        }        else if (code == TAG_NOT_ALLOWED_IN)        {            tidy_out(lexer->errout, "Warning: ");            ReportTag(lexer, node);            tidy_out(lexer->errout, " isn't allowed in <%s> elements", element->element);        }        else if (code == DOCTYPE_AFTER_TAGS)        {            tidy_out(lexer->errout, "Warning: <!DOCTYPE> isn't allowed after elements");        }        else if (code == MISSING_STARTTAG)            tidy_out(lexer->errout, "Warning: missing <%s>", node->element);        else if (code == UNEXPECTED_ENDTAG)        {            tidy_out(lexer->errout, "Warning: unexpected </%s>", node->element);            if (element)                tidy_out(lexer->errout, " in <%s>", element->element);        }        else if (code == USING_BR_INPLACE_OF)        {            tidy_out(lexer->errout, "Warning: using <br> in place of ");            ReportTag(lexer, node);        }        else if (code == INSERTING_TAG)            tidy_out(lexer->errout, "Warning: inserting implicit <%s>", node->element);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -