diff options
Diffstat (limited to '3rdParty/Expat/src/xmltok_impl.c')
| -rw-r--r-- | 3rdParty/Expat/src/xmltok_impl.c | 132 |
1 files changed, 58 insertions, 74 deletions
diff --git a/3rdParty/Expat/src/xmltok_impl.c b/3rdParty/Expat/src/xmltok_impl.c index 5f779c0..4d9ae7d 100644 --- a/3rdParty/Expat/src/xmltok_impl.c +++ b/3rdParty/Expat/src/xmltok_impl.c | |||
| @@ -1,8 +1,35 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* This file is included! |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | /* This file is included! */ | ||
| 6 | #ifdef XML_TOK_IMPL_C | 33 | #ifdef XML_TOK_IMPL_C |
| 7 | 34 | ||
| 8 | #ifndef IS_INVALID_CHAR | 35 | #ifndef IS_INVALID_CHAR |
| @@ -47,6 +74,7 @@ | |||
| 47 | *nextTokPtr = ptr; \ | 74 | *nextTokPtr = ptr; \ |
| 48 | return XML_TOK_INVALID; \ | 75 | return XML_TOK_INVALID; \ |
| 49 | } \ | 76 | } \ |
| 77 | /* fall through */ \ | ||
| 50 | case BT_NMSTRT: \ | 78 | case BT_NMSTRT: \ |
| 51 | case BT_HEX: \ | 79 | case BT_HEX: \ |
| 52 | case BT_DIGIT: \ | 80 | case BT_DIGIT: \ |
| @@ -75,6 +103,7 @@ | |||
| 75 | *nextTokPtr = ptr; \ | 103 | *nextTokPtr = ptr; \ |
| 76 | return XML_TOK_INVALID; \ | 104 | return XML_TOK_INVALID; \ |
| 77 | } \ | 105 | } \ |
| 106 | /* fall through */ \ | ||
| 78 | case BT_NMSTRT: \ | 107 | case BT_NMSTRT: \ |
| 79 | case BT_HEX: \ | 108 | case BT_HEX: \ |
| 80 | ptr += MINBPC(enc); \ | 109 | ptr += MINBPC(enc); \ |
| @@ -575,7 +604,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, | |||
| 575 | return XML_TOK_INVALID; | 604 | return XML_TOK_INVALID; |
| 576 | } | 605 | } |
| 577 | } | 606 | } |
| 578 | /* fall through */ | 607 | /* fall through */ |
| 579 | case BT_EQUALS: | 608 | case BT_EQUALS: |
| 580 | { | 609 | { |
| 581 | int open; | 610 | int open; |
| @@ -1198,8 +1227,14 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, | |||
| 1198 | const char *start; | 1227 | const char *start; |
| 1199 | if (ptr >= end) | 1228 | if (ptr >= end) |
| 1200 | return XML_TOK_NONE; | 1229 | return XML_TOK_NONE; |
| 1201 | else if (! HAS_CHAR(enc, ptr, end)) | 1230 | else if (! HAS_CHAR(enc, ptr, end)) { |
| 1202 | return XML_TOK_PARTIAL; | 1231 | /* This line cannot be executed. The incoming data has already |
| 1232 | * been tokenized once, so incomplete characters like this have | ||
| 1233 | * already been eliminated from the input. Retaining the paranoia | ||
| 1234 | * check is still valuable, however. | ||
| 1235 | */ | ||
| 1236 | return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */ | ||
| 1237 | } | ||
| 1203 | start = ptr; | 1238 | start = ptr; |
| 1204 | while (HAS_CHAR(enc, ptr, end)) { | 1239 | while (HAS_CHAR(enc, ptr, end)) { |
| 1205 | switch (BYTE_TYPE(enc, ptr)) { | 1240 | switch (BYTE_TYPE(enc, ptr)) { |
| @@ -1258,8 +1293,14 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, | |||
| 1258 | const char *start; | 1293 | const char *start; |
| 1259 | if (ptr >= end) | 1294 | if (ptr >= end) |
| 1260 | return XML_TOK_NONE; | 1295 | return XML_TOK_NONE; |
| 1261 | else if (! HAS_CHAR(enc, ptr, end)) | 1296 | else if (! HAS_CHAR(enc, ptr, end)) { |
| 1262 | return XML_TOK_PARTIAL; | 1297 | /* This line cannot be executed. The incoming data has already |
| 1298 | * been tokenized once, so incomplete characters like this have | ||
| 1299 | * already been eliminated from the input. Retaining the paranoia | ||
| 1300 | * check is still valuable, however. | ||
| 1301 | */ | ||
| 1302 | return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */ | ||
| 1303 | } | ||
| 1263 | start = ptr; | 1304 | start = ptr; |
| 1264 | while (HAS_CHAR(enc, ptr, end)) { | 1305 | while (HAS_CHAR(enc, ptr, end)) { |
| 1265 | switch (BYTE_TYPE(enc, ptr)) { | 1306 | switch (BYTE_TYPE(enc, ptr)) { |
| @@ -1403,6 +1444,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, | |||
| 1403 | case BT_NMSTRT: | 1444 | case BT_NMSTRT: |
| 1404 | if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) | 1445 | if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) |
| 1405 | break; | 1446 | break; |
| 1447 | /* fall through */ | ||
| 1406 | default: | 1448 | default: |
| 1407 | switch (BYTE_TO_ASCII(enc, ptr)) { | 1449 | switch (BYTE_TO_ASCII(enc, ptr)) { |
| 1408 | case 0x24: /* $ */ | 1450 | case 0x24: /* $ */ |
| @@ -1615,76 +1657,18 @@ PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr, | |||
| 1615 | } | 1657 | } |
| 1616 | 1658 | ||
| 1617 | static int PTRCALL | 1659 | static int PTRCALL |
| 1618 | PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) | ||
| 1619 | { | ||
| 1620 | for (;;) { | ||
| 1621 | switch (BYTE_TYPE(enc, ptr1)) { | ||
| 1622 | #define LEAD_CASE(n) \ | ||
| 1623 | case BT_LEAD ## n: \ | ||
| 1624 | if (*ptr1++ != *ptr2++) \ | ||
| 1625 | return 0; | ||
| 1626 | LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2) | ||
| 1627 | #undef LEAD_CASE | ||
| 1628 | /* fall through */ | ||
| 1629 | if (*ptr1++ != *ptr2++) | ||
| 1630 | return 0; | ||
| 1631 | break; | ||
| 1632 | case BT_NONASCII: | ||
| 1633 | case BT_NMSTRT: | ||
| 1634 | #ifdef XML_NS | ||
| 1635 | case BT_COLON: | ||
| 1636 | #endif | ||
| 1637 | case BT_HEX: | ||
| 1638 | case BT_DIGIT: | ||
| 1639 | case BT_NAME: | ||
| 1640 | case BT_MINUS: | ||
| 1641 | if (*ptr2++ != *ptr1++) | ||
| 1642 | return 0; | ||
| 1643 | if (MINBPC(enc) > 1) { | ||
| 1644 | if (*ptr2++ != *ptr1++) | ||
| 1645 | return 0; | ||
| 1646 | if (MINBPC(enc) > 2) { | ||
| 1647 | if (*ptr2++ != *ptr1++) | ||
| 1648 | return 0; | ||
| 1649 | if (MINBPC(enc) > 3) { | ||
| 1650 | if (*ptr2++ != *ptr1++) | ||
| 1651 | return 0; | ||
| 1652 | } | ||
| 1653 | } | ||
| 1654 | } | ||
| 1655 | break; | ||
| 1656 | default: | ||
| 1657 | if (MINBPC(enc) == 1 && *ptr1 == *ptr2) | ||
| 1658 | return 1; | ||
| 1659 | switch (BYTE_TYPE(enc, ptr2)) { | ||
| 1660 | case BT_LEAD2: | ||
| 1661 | case BT_LEAD3: | ||
| 1662 | case BT_LEAD4: | ||
| 1663 | case BT_NONASCII: | ||
| 1664 | case BT_NMSTRT: | ||
| 1665 | #ifdef XML_NS | ||
| 1666 | case BT_COLON: | ||
| 1667 | #endif | ||
| 1668 | case BT_HEX: | ||
| 1669 | case BT_DIGIT: | ||
| 1670 | case BT_NAME: | ||
| 1671 | case BT_MINUS: | ||
| 1672 | return 0; | ||
| 1673 | default: | ||
| 1674 | return 1; | ||
| 1675 | } | ||
| 1676 | } | ||
| 1677 | } | ||
| 1678 | /* not reached */ | ||
| 1679 | } | ||
| 1680 | |||
| 1681 | static int PTRCALL | ||
| 1682 | PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1, | 1660 | PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1, |
| 1683 | const char *end1, const char *ptr2) | 1661 | const char *end1, const char *ptr2) |
| 1684 | { | 1662 | { |
| 1685 | for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { | 1663 | for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { |
| 1686 | if (end1 - ptr1 < MINBPC(enc)) | 1664 | if (end1 - ptr1 < MINBPC(enc)) { |
| 1687 | return 0; | 1665 | /* This line cannot be executed. The incoming data has already |
| 1666 | * been tokenized once, so incomplete characters like this have | ||
| 1667 | * already been eliminated from the input. Retaining the | ||
| 1668 | * paranoia check is still valuable, however. | ||
| 1669 | */ | ||
| 1670 | return 0; /* LCOV_EXCL_LINE */ | ||
| 1671 | } | ||
| 1688 | if (!CHAR_MATCHES(enc, ptr1, *ptr2)) | 1672 | if (!CHAR_MATCHES(enc, ptr1, *ptr2)) |
| 1689 | return 0; | 1673 | return 0; |
| 1690 | } | 1674 | } |
Swift