ยปCore Development>Code coverage>Modules/expat/xmltok_ns.c

Python code coverage for Modules/expat/xmltok_ns.c

#countcontent
1n/a/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2n/a See the file COPYING for copying permission.
3n/a*/
4n/a
5n/a/* This file is included! */
6n/a#ifdef XML_TOK_NS_C
7n/a
8n/aconst ENCODING *
9n/aNS(XmlGetUtf8InternalEncoding)(void)
10n/a{
11n/a return &ns(internal_utf8_encoding).enc;
12n/a}
13n/a
14n/aconst ENCODING *
15n/aNS(XmlGetUtf16InternalEncoding)(void)
16n/a{
17n/a#if BYTEORDER == 1234
18n/a return &ns(internal_little2_encoding).enc;
19n/a#elif BYTEORDER == 4321
20n/a return &ns(internal_big2_encoding).enc;
21n/a#else
22n/a const short n = 1;
23n/a return (*(const char *)&n
24n/a ? &ns(internal_little2_encoding).enc
25n/a : &ns(internal_big2_encoding).enc);
26n/a#endif
27n/a}
28n/a
29n/astatic const ENCODING * const NS(encodings)[] = {
30n/a &ns(latin1_encoding).enc,
31n/a &ns(ascii_encoding).enc,
32n/a &ns(utf8_encoding).enc,
33n/a &ns(big2_encoding).enc,
34n/a &ns(big2_encoding).enc,
35n/a &ns(little2_encoding).enc,
36n/a &ns(utf8_encoding).enc /* NO_ENC */
37n/a};
38n/a
39n/astatic int PTRCALL
40n/aNS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
41n/a const char **nextTokPtr)
42n/a{
43n/a return initScan(NS(encodings), (const INIT_ENCODING *)enc,
44n/a XML_PROLOG_STATE, ptr, end, nextTokPtr);
45n/a}
46n/a
47n/astatic int PTRCALL
48n/aNS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
49n/a const char **nextTokPtr)
50n/a{
51n/a return initScan(NS(encodings), (const INIT_ENCODING *)enc,
52n/a XML_CONTENT_STATE, ptr, end, nextTokPtr);
53n/a}
54n/a
55n/aint
56n/aNS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
57n/a const char *name)
58n/a{
59n/a int i = getEncodingIndex(name);
60n/a if (i == UNKNOWN_ENC)
61n/a return 0;
62n/a SET_INIT_ENC_INDEX(p, i);
63n/a p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
64n/a p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
65n/a p->initEnc.updatePosition = initUpdatePosition;
66n/a p->encPtr = encPtr;
67n/a *encPtr = &(p->initEnc);
68n/a return 1;
69n/a}
70n/a
71n/astatic const ENCODING *
72n/aNS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
73n/a{
74n/a#define ENCODING_MAX 128
75n/a char buf[ENCODING_MAX];
76n/a char *p = buf;
77n/a int i;
78n/a XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
79n/a if (ptr != end)
80n/a return 0;
81n/a *p = 0;
82n/a if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
83n/a return enc;
84n/a i = getEncodingIndex(buf);
85n/a if (i == UNKNOWN_ENC)
86n/a return 0;
87n/a return NS(encodings)[i];
88n/a}
89n/a
90n/aint
91n/aNS(XmlParseXmlDecl)(int isGeneralTextEntity,
92n/a const ENCODING *enc,
93n/a const char *ptr,
94n/a const char *end,
95n/a const char **badPtr,
96n/a const char **versionPtr,
97n/a const char **versionEndPtr,
98n/a const char **encodingName,
99n/a const ENCODING **encoding,
100n/a int *standalone)
101n/a{
102n/a return doParseXmlDecl(NS(findEncoding),
103n/a isGeneralTextEntity,
104n/a enc,
105n/a ptr,
106n/a end,
107n/a badPtr,
108n/a versionPtr,
109n/a versionEndPtr,
110n/a encodingName,
111n/a encoding,
112n/a standalone);
113n/a}
114n/a
115n/a#endif /* XML_TOK_NS_C */