diff options
Diffstat (limited to '3rdparty/expat/xmlwf/ct.c')
-rw-r--r-- | 3rdparty/expat/xmlwf/ct.c | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/3rdparty/expat/xmlwf/ct.c b/3rdparty/expat/xmlwf/ct.c index 95903a34500..dcf92bab568 100644 --- a/3rdparty/expat/xmlwf/ct.c +++ b/3rdparty/expat/xmlwf/ct.c @@ -1,8 +1,39 @@ +/* + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 1997-2000 Thai Open Source Software Center Ltd + Copyright (c) 2000-2017 Expat development team + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + #define CHARSET_MAX 41 static const char * -getTok(const char **pp) -{ +getTok(const char **pp) { enum { inAtom, inString, init, inComment }; int state = init; const char *tokStart = 0; @@ -70,9 +101,8 @@ getTok(const char **pp) /* key must be lowercase ASCII */ static int -matchkey(const char *start, const char *end, const char *key) -{ - if (!start) +matchkey(const char *start, const char *end, const char *key) { + if (! start) return 0; for (; start != end; start++, key++) if (*start != *key && *start != 'A' + (*key - 'a')) @@ -81,8 +111,7 @@ matchkey(const char *start, const char *end, const char *key) } void -getXMLCharset(const char *buf, char *charset) -{ +getXMLCharset(const char *buf, char *charset) { const char *next, *p; charset[0] = '\0'; @@ -90,10 +119,10 @@ getXMLCharset(const char *buf, char *charset) p = getTok(&next); if (matchkey(p, next, "text")) strcpy(charset, "us-ascii"); - else if (!matchkey(p, next, "application")) + else if (! matchkey(p, next, "application")) return; p = getTok(&next); - if (!p || *p != '/') + if (! p || *p != '/') return; p = getTok(&next); if (matchkey(p, next, "xml")) @@ -119,8 +148,7 @@ getXMLCharset(const char *buf, char *charset) *s++ = *p; } *s++ = '\0'; - } - else { + } else { if (next - p > CHARSET_MAX - 1) break; while (p != next) @@ -131,15 +159,13 @@ getXMLCharset(const char *buf, char *charset) } } } - } - else - p = getTok(&next); + } else + p = getTok(&next); } } int -main(int argc, char **argv) -{ +main(int argc, char **argv) { char buf[CHARSET_MAX]; getXMLCharset(argv[1], buf); printf("charset = \"%s\"\n", buf); |