ENH: set expected failure for tests
[cmake.git] / Utilities / cmexpat / xmltok_ns.c
blobfa78adffce1be1658ea7f899b81390e1085e590a
1 const ENCODING *NS(XmlGetUtf8InternalEncoding)(void)
3 return &ns(internal_utf8_encoding).enc;
6 const ENCODING *NS(XmlGetUtf16InternalEncoding)(void)
8 #if XML_BYTE_ORDER == 12
9 return &ns(internal_little2_encoding).enc;
10 #elif XML_BYTE_ORDER == 21
11 return &ns(internal_big2_encoding).enc;
12 #else
13 const short n = 1;
14 return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc;
15 #endif
18 static
19 const ENCODING *NS(encodings)[] = {
20 &ns(latin1_encoding).enc,
21 &ns(ascii_encoding).enc,
22 &ns(utf8_encoding).enc,
23 &ns(big2_encoding).enc,
24 &ns(big2_encoding).enc,
25 &ns(little2_encoding).enc,
26 &ns(utf8_encoding).enc /* NO_ENC */
29 static
30 int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
31 const char **nextTokPtr)
33 return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
36 static
37 int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
38 const char **nextTokPtr)
40 return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
43 int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
45 int i = getEncodingIndex(name);
46 if (i == UNKNOWN_ENC)
47 return 0;
48 SET_INIT_ENC_INDEX(p, i);
49 p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
50 p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
51 p->initEnc.updatePosition = initUpdatePosition;
52 p->encPtr = encPtr;
53 *encPtr = &(p->initEnc);
54 return 1;
57 static
58 const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
60 #define ENCODING_MAX 128
61 char buf[ENCODING_MAX];
62 char *p = buf;
63 int i;
64 XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
65 if (ptr != end)
66 return 0;
67 *p = 0;
68 if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
69 return enc;
70 i = getEncodingIndex(buf);
71 if (i == UNKNOWN_ENC)
72 return 0;
73 return NS(encodings)[i];
76 int NS(XmlParseXmlDecl)(int isGeneralTextEntity,
77 const ENCODING *enc,
78 const char *ptr,
79 const char *end,
80 const char **badPtr,
81 const char **versionPtr,
82 const char **versionEndPtr,
83 const char **encodingName,
84 const ENCODING **encoding,
85 int *standalone)
87 return doParseXmlDecl(NS(findEncoding),
88 isGeneralTextEntity,
89 enc,
90 ptr,
91 end,
92 badPtr,
93 versionPtr,
94 versionEndPtr,
95 encodingName,
96 encoding,
97 standalone);