Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
xmltok.c File Reference
#include <expat_config.h>
#include <stddef.h>
#include <string.h>
#include <stdbool.h>
#include "expat_external.h"
#include "internal.h"
#include "xmltok.h"
#include "nametab.h"
#include "xmltok_impl.h"
#include "ascii.h"
#include "xmltok_impl.c"
#include "asciitab.h"
#include "utf8tab.h"
#include "iasciitab.h"
#include "latin1tab.h"
#include "xmltok_ns.c"

Go to the source code of this file.

Classes

struct  normal_encoding
 
struct  unknown_encoding
 

Macros

#define IGNORE_SECTION_TOK_VTABLE   /* as nothing */
 
#define VTABLE1
 
#define VTABLE   VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)
 
#define UCS2_GET_NAMING(pages, hi, lo)    (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo)&0x1F)))
 
#define UTF8_GET_NAMING2(pages, byte)
 
#define UTF8_GET_NAMING3(pages, byte)
 
#define UTF8_INVALID2(p)    ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0)
 
#define UTF8_INVALID3(p)
 
#define UTF8_INVALID4(p)
 
#define utf8_isName4   isNever
 
#define utf8_isNmstrt4   isNever
 
#define AS_NORMAL_ENCODING(enc)   ((const struct normal_encoding *)(enc))
 
#define STANDARD_VTABLE(E)   /* as nothing */
 
#define NORMAL_VTABLE(E)
 
#define NULL_VTABLE
 
#define MINBPC(enc)   1
 
#define SB_BYTE_TYPE(enc, p)    (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
 
#define BYTE_TYPE(enc, p)   SB_BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)   (*(p))
 
#define IS_NAME_CHAR(enc, p, n)   (AS_NORMAL_ENCODING(enc)->isName##n(enc, p))
 
#define IS_NMSTRT_CHAR(enc, p, n)   (AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p))
 
#define IS_INVALID_CHAR(enc, p, n)    (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
 
#define IS_NAME_CHAR_MINBPC(enc, p)   (0)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)   (0)
 
#define CHAR_MATCHES(enc, p, c)   (*(p) == (c))
 
#define PREFIX(ident)   normal_##ident
 
#define XML_TOK_IMPL_C
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define DEFINE_UTF16_TO_UTF8(E)
 
#define DEFINE_UTF16_TO_UTF16(E)
 
#define SET2(ptr, ch)   (((ptr)[0] = ((ch)&0xff)), ((ptr)[1] = ((ch) >> 8)))
 
#define GET_LO(ptr)   ((unsigned char)(ptr)[0])
 
#define GET_HI(ptr)   ((unsigned char)(ptr)[1])
 
#define SET2(ptr, ch)   (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch)&0xFF)))
 
#define GET_LO(ptr)   ((unsigned char)(ptr)[1])
 
#define GET_HI(ptr)   ((unsigned char)(ptr)[0])
 
#define LITTLE2_BYTE_TYPE(enc, p)
 
#define LITTLE2_BYTE_TO_ASCII(p)   ((p)[1] == 0 ? (p)[0] : -1)
 
#define LITTLE2_CHAR_MATCHES(p, c)   ((p)[1] == 0 && (p)[0] == (c))
 
#define LITTLE2_IS_NAME_CHAR_MINBPC(p)    UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
 
#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(p)    UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])
 
#define PREFIX(ident)   little2_##ident
 
#define MINBPC(enc)   2
 
#define BYTE_TYPE(enc, p)   LITTLE2_BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)   LITTLE2_BYTE_TO_ASCII(p)
 
#define CHAR_MATCHES(enc, p, c)   LITTLE2_CHAR_MATCHES(p, c)
 
#define IS_NAME_CHAR(enc, p, n)   0
 
#define IS_NAME_CHAR_MINBPC(enc, p)   LITTLE2_IS_NAME_CHAR_MINBPC(p)
 
#define IS_NMSTRT_CHAR(enc, p, n)   (0)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)   LITTLE2_IS_NMSTRT_CHAR_MINBPC(p)
 
#define XML_TOK_IMPL_C
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define BIG2_BYTE_TYPE(enc, p)
 
#define BIG2_BYTE_TO_ASCII(p)   ((p)[0] == 0 ? (p)[1] : -1)
 
#define BIG2_CHAR_MATCHES(p, c)   ((p)[0] == 0 && (p)[1] == (c))
 
#define BIG2_IS_NAME_CHAR_MINBPC(p)    UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
 
#define BIG2_IS_NMSTRT_CHAR_MINBPC(p)    UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])
 
#define PREFIX(ident)   big2_##ident
 
#define MINBPC(enc)   2
 
#define BYTE_TYPE(enc, p)   BIG2_BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)   BIG2_BYTE_TO_ASCII(p)
 
#define CHAR_MATCHES(enc, p, c)   BIG2_CHAR_MATCHES(p, c)
 
#define IS_NAME_CHAR(enc, p, n)   0
 
#define IS_NAME_CHAR_MINBPC(enc, p)   BIG2_IS_NAME_CHAR_MINBPC(p)
 
#define IS_NMSTRT_CHAR(enc, p, n)   (0)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)   BIG2_IS_NMSTRT_CHAR_MINBPC(p)
 
#define XML_TOK_IMPL_C
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define AS_UNKNOWN_ENCODING(enc)   ((const struct unknown_encoding *)(enc))
 
#define INIT_ENC_INDEX(enc)   ((int)(enc)->initEnc.isUtf16)
 
#define SET_INIT_ENC_INDEX(enc, i)   ((enc)->initEnc.isUtf16 = (char)i)
 
#define NS(x)   x
 
#define ns(x)   x
 
#define XML_TOK_NS_C
 

Enumerations

enum  { UTF8_cval1 = 0x00 , UTF8_cval2 = 0xc0 , UTF8_cval3 = 0xe0 , UTF8_cval4 = 0xf0 }
 
enum  {
  UNKNOWN_ENC = -1 , ISO_8859_1_ENC = 0 , US_ASCII_ENC , UTF_8_ENC ,
  UTF_16_ENC , UTF_16BE_ENC , UTF_16LE_ENC , NO_ENC
}
 

Functions

void _INTERNAL_trim_to_complete_utf8_characters (const char *from, const char **fromLimRef)
 
int FASTCALL XmlUtf8Encode (int c, char *buf)
 
int FASTCALL XmlUtf16Encode (int charNum, unsigned short *buf)
 
int XmlSizeOfUnknownEncoding (void)
 
ENCODINGXmlInitUnknownEncoding (void *mem, int *table, CONVERTER convert, void *userData)
 

Macro Definition Documentation

◆ AS_NORMAL_ENCODING

#define AS_NORMAL_ENCODING (   enc)    ((const struct normal_encoding *)(enc))

Definition at line 206 of file xmltok.c.

◆ AS_UNKNOWN_ENCODING

#define AS_UNKNOWN_ENCODING (   enc)    ((const struct unknown_encoding *)(enc))

Definition at line 1322 of file xmltok.c.

◆ BIG2_BYTE_TO_ASCII

#define BIG2_BYTE_TO_ASCII (   p)    ((p)[0] == 0 ? (p)[1] : -1)

Definition at line 878 of file xmltok.c.

◆ BIG2_BYTE_TYPE

#define BIG2_BYTE_TYPE (   enc,
 
)
Value:
((p)[0] == 0 \
? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
: unicode_byte_type((p)[0], (p)[1]))

Definition at line 874 of file xmltok.c.

◆ BIG2_CHAR_MATCHES

#define BIG2_CHAR_MATCHES (   p,
 
)    ((p)[0] == 0 && (p)[1] == (c))

Definition at line 879 of file xmltok.c.

◆ BIG2_IS_NAME_CHAR_MINBPC

#define BIG2_IS_NAME_CHAR_MINBPC (   p)     UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])

Definition at line 880 of file xmltok.c.

◆ BIG2_IS_NMSTRT_CHAR_MINBPC

#define BIG2_IS_NMSTRT_CHAR_MINBPC (   p)     UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])

Definition at line 882 of file xmltok.c.

◆ BT_COLON [1/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [2/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [3/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [4/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [5/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [6/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [7/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [8/8]

#define BT_COLON   BT_NMSTRT

◆ BYTE_TO_ASCII [1/3]

#define BYTE_TO_ASCII (   enc,
 
)    (*(p))

Definition at line 926 of file xmltok.c.

◆ BYTE_TO_ASCII [2/3]

#define BYTE_TO_ASCII (   enc,
 
)    LITTLE2_BYTE_TO_ASCII(p)

Definition at line 926 of file xmltok.c.

◆ BYTE_TO_ASCII [3/3]

#define BYTE_TO_ASCII (   enc,
 
)    BIG2_BYTE_TO_ASCII(p)

Definition at line 926 of file xmltok.c.

◆ BYTE_TYPE [1/3]

#define BYTE_TYPE (   enc,
 
)    SB_BYTE_TYPE(enc, p)

Definition at line 925 of file xmltok.c.

◆ BYTE_TYPE [2/3]

#define BYTE_TYPE (   enc,
 
)    LITTLE2_BYTE_TYPE(enc, p)

Definition at line 925 of file xmltok.c.

◆ BYTE_TYPE [3/3]

#define BYTE_TYPE (   enc,
 
)    BIG2_BYTE_TYPE(enc, p)

Definition at line 925 of file xmltok.c.

◆ CHAR_MATCHES [1/3]

#define CHAR_MATCHES (   enc,
  p,
 
)    (*(p) == (c))

Definition at line 927 of file xmltok.c.

◆ CHAR_MATCHES [2/3]

#define CHAR_MATCHES (   enc,
  p,
 
)    LITTLE2_CHAR_MATCHES(p, c)

Definition at line 927 of file xmltok.c.

◆ CHAR_MATCHES [3/3]

#define CHAR_MATCHES (   enc,
  p,
 
)    BIG2_CHAR_MATCHES(p, c)

Definition at line 927 of file xmltok.c.

◆ DEFINE_UTF16_TO_UTF16

#define DEFINE_UTF16_TO_UTF16 (   E)
Value:
static enum XML_Convert_Result PTRCALL E##toUtf16( \
const ENCODING *enc, const char **fromP, const char *fromLim, \
unsigned short **toP, const unsigned short *toLim) { \
UNUSED_P(enc); \
fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \
/* Avoid copying first half only of surrogate */ \
if (fromLim - *fromP > ((toLim - *toP) << 1) \
&& (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \
fromLim -= 2; \
} \
for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \
*(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
if ((*toP == toLim) && (*fromP < fromLim)) \
else \
return res; \
}
#define PTRCALL
Definition: internal.h:85
#define GET_HI(ptr)
Definition: xmltok.c:731
#define GET_LO(ptr)
Definition: xmltok.c:730
XML_Convert_Result
Definition: xmltok.h:163
@ XML_CONVERT_OUTPUT_EXHAUSTED
Definition: xmltok.h:166
@ XML_CONVERT_COMPLETED
Definition: xmltok.h:164
@ XML_CONVERT_INPUT_INCOMPLETE
Definition: xmltok.h:165

Definition at line 697 of file xmltok.c.

◆ DEFINE_UTF16_TO_UTF8

#define DEFINE_UTF16_TO_UTF8 (   E)

Definition at line 620 of file xmltok.c.

◆ GET_HI [1/2]

#define GET_HI (   ptr)    ((unsigned char)(ptr)[1])

Definition at line 731 of file xmltok.c.

◆ GET_HI [2/2]

#define GET_HI (   ptr)    ((unsigned char)(ptr)[0])

Definition at line 731 of file xmltok.c.

◆ GET_LO [1/2]

#define GET_LO (   ptr)    ((unsigned char)(ptr)[0])

Definition at line 730 of file xmltok.c.

◆ GET_LO [2/2]

#define GET_LO (   ptr)    ((unsigned char)(ptr)[1])

Definition at line 730 of file xmltok.c.

◆ IGNORE_SECTION_TOK_VTABLE

#define IGNORE_SECTION_TOK_VTABLE   /* as nothing */

Definition at line 65 of file xmltok.c.

◆ INIT_ENC_INDEX

#define INIT_ENC_INDEX (   enc)    ((int)(enc)->initEnc.isUtf16)

Definition at line 1526 of file xmltok.c.

◆ IS_INVALID_CHAR

#define IS_INVALID_CHAR (   enc,
  p,
 
)     (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))

Definition at line 276 of file xmltok.c.

◆ IS_NAME_CHAR [1/3]

#define IS_NAME_CHAR (   enc,
  p,
 
)    (AS_NORMAL_ENCODING(enc)->isName##n(enc, p))

Definition at line 928 of file xmltok.c.

◆ IS_NAME_CHAR [2/3]

#define IS_NAME_CHAR (   enc,
  p,
 
)    0

Definition at line 928 of file xmltok.c.

◆ IS_NAME_CHAR [3/3]

#define IS_NAME_CHAR (   enc,
  p,
 
)    0

Definition at line 928 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [1/3]

#define IS_NAME_CHAR_MINBPC (   enc,
 
)    (0)

Definition at line 929 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [2/3]

#define IS_NAME_CHAR_MINBPC (   enc,
 
)    LITTLE2_IS_NAME_CHAR_MINBPC(p)

Definition at line 929 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [3/3]

#define IS_NAME_CHAR_MINBPC (   enc,
 
)    BIG2_IS_NAME_CHAR_MINBPC(p)

Definition at line 929 of file xmltok.c.

◆ IS_NMSTRT_CHAR [1/3]

#define IS_NMSTRT_CHAR (   enc,
  p,
 
)    (AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p))

Definition at line 930 of file xmltok.c.

◆ IS_NMSTRT_CHAR [2/3]

#define IS_NMSTRT_CHAR (   enc,
  p,
 
)    (0)

Definition at line 930 of file xmltok.c.

◆ IS_NMSTRT_CHAR [3/3]

#define IS_NMSTRT_CHAR (   enc,
  p,
 
)    (0)

Definition at line 930 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [1/3]

#define IS_NMSTRT_CHAR_MINBPC (   enc,
 
)    (0)

Definition at line 931 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [2/3]

#define IS_NMSTRT_CHAR_MINBPC (   enc,
 
)    LITTLE2_IS_NMSTRT_CHAR_MINBPC(p)

Definition at line 931 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [3/3]

#define IS_NMSTRT_CHAR_MINBPC (   enc,
 
)    BIG2_IS_NMSTRT_CHAR_MINBPC(p)

Definition at line 931 of file xmltok.c.

◆ LITTLE2_BYTE_TO_ASCII

#define LITTLE2_BYTE_TO_ASCII (   p)    ((p)[1] == 0 ? (p)[0] : -1)

Definition at line 743 of file xmltok.c.

◆ LITTLE2_BYTE_TYPE

#define LITTLE2_BYTE_TYPE (   enc,
 
)
Value:
((p)[1] == 0 ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
: unicode_byte_type((p)[1], (p)[0]))

Definition at line 740 of file xmltok.c.

◆ LITTLE2_CHAR_MATCHES

#define LITTLE2_CHAR_MATCHES (   p,
 
)    ((p)[1] == 0 && (p)[0] == (c))

Definition at line 744 of file xmltok.c.

◆ LITTLE2_IS_NAME_CHAR_MINBPC

#define LITTLE2_IS_NAME_CHAR_MINBPC (   p)     UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])

Definition at line 745 of file xmltok.c.

◆ LITTLE2_IS_NMSTRT_CHAR_MINBPC

#define LITTLE2_IS_NMSTRT_CHAR_MINBPC (   p)     UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])

Definition at line 747 of file xmltok.c.

◆ MINBPC [1/3]

#define MINBPC (   enc)    1

Definition at line 923 of file xmltok.c.

◆ MINBPC [2/3]

#define MINBPC (   enc)    2

Definition at line 923 of file xmltok.c.

◆ MINBPC [3/3]

#define MINBPC (   enc)    2

Definition at line 923 of file xmltok.c.

◆ NORMAL_VTABLE

#define NORMAL_VTABLE (   E)
Value:
E##isName2, E##isName3, E##isName4, E##isNmstrt2, E##isNmstrt3, \
E##isNmstrt4, E##isInvalid2, E##isInvalid3, E##isInvalid4

Definition at line 219 of file xmltok.c.

◆ NS

#define NS (   x)    x

Definition at line 1648 of file xmltok.c.

◆ ns

#define ns (   x)    x

Definition at line 1649 of file xmltok.c.

◆ NULL_VTABLE

#define NULL_VTABLE
Value:
/* isName2 */ NULL, /* isName3 */ NULL, /* isName4 */ NULL, \
/* isNmstrt2 */ NULL, /* isNmstrt3 */ NULL, /* isNmstrt4 */ NULL, \
/* isInvalid2 */ NULL, /* isInvalid3 */ NULL, /* isInvalid4 */ NULL

Definition at line 223 of file xmltok.c.

◆ PREFIX [1/3]

#define PREFIX (   ident)    normal_##ident

Definition at line 922 of file xmltok.c.

◆ PREFIX [2/3]

#define PREFIX (   ident)    little2_##ident

Definition at line 922 of file xmltok.c.

◆ PREFIX [3/3]

#define PREFIX (   ident)    big2_##ident

Definition at line 922 of file xmltok.c.

◆ SB_BYTE_TYPE

#define SB_BYTE_TYPE (   enc,
 
)     (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])

Definition at line 245 of file xmltok.c.

◆ SET2 [1/2]

#define SET2 (   ptr,
  ch 
)    (((ptr)[0] = ((ch)&0xff)), ((ptr)[1] = ((ch) >> 8)))

Definition at line 729 of file xmltok.c.

◆ SET2 [2/2]

#define SET2 (   ptr,
  ch 
)    (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch)&0xFF)))

Definition at line 729 of file xmltok.c.

◆ SET_INIT_ENC_INDEX

#define SET_INIT_ENC_INDEX (   enc,
 
)    ((enc)->initEnc.isUtf16 = (char)i)

Definition at line 1527 of file xmltok.c.

◆ STANDARD_VTABLE

#define STANDARD_VTABLE (   E)    /* as nothing */

Definition at line 215 of file xmltok.c.

◆ UCS2_GET_NAMING

#define UCS2_GET_NAMING (   pages,
  hi,
  lo 
)     (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo)&0x1F)))

Definition at line 78 of file xmltok.c.

◆ UTF8_GET_NAMING2

#define UTF8_GET_NAMING2 (   pages,
  byte 
)
Value:
(namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
+ ((((byte)[0]) & 3) << 1) + ((((byte)[1]) >> 5) & 1)] \
& (1u << (((byte)[1]) & 0x1F)))

Definition at line 85 of file xmltok.c.

◆ UTF8_GET_NAMING3

#define UTF8_GET_NAMING3 (   pages,
  byte 
)
Value:
(namingBitmap \
[((pages)[((((byte)[0]) & 0xF) << 4) + ((((byte)[1]) >> 2) & 0xF)] \
<< 3) \
+ ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \
& (1u << (((byte)[2]) & 0x1F)))

Definition at line 95 of file xmltok.c.

◆ UTF8_INVALID2

#define UTF8_INVALID2 (   p)     ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0)

Definition at line 112 of file xmltok.c.

◆ UTF8_INVALID3

#define UTF8_INVALID3 (   p)
Value:
(((p)[2] & 0x80) == 0 \
|| ((*p) == 0xEF && (p)[1] == 0xBF ? (p)[2] > 0xBD \
: ((p)[2] & 0xC0) == 0xC0) \
|| ((*p) == 0xE0 \
? (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \
: ((p)[1] & 0x80) == 0 \
|| ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0)))

Definition at line 115 of file xmltok.c.

◆ UTF8_INVALID4

#define UTF8_INVALID4 (   p)
Value:
(((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 || ((p)[2] & 0x80) == 0 \
|| ((p)[2] & 0xC0) == 0xC0 \
|| ((*p) == 0xF0 \
? (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \
: ((p)[1] & 0x80) == 0 \
|| ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))

Definition at line 124 of file xmltok.c.

◆ utf8_isName4

#define utf8_isName4   isNever

Definition at line 151 of file xmltok.c.

◆ utf8_isNmstrt4

#define utf8_isNmstrt4   isNever

Definition at line 165 of file xmltok.c.

◆ VTABLE

#define VTABLE   VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)

Definition at line 76 of file xmltok.c.

◆ VTABLE1

#define VTABLE1
Value:
{PREFIX(prologTok), PREFIX(contentTok), \
PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE}, \
{PREFIX(attributeValueTok), PREFIX(entityValueTok)}, \
PREFIX(nameMatchesAscii), PREFIX(nameLength), PREFIX(skipS), \
PREFIX(getAtts), PREFIX(charRefNumber), PREFIX(predefinedEntityName), \
PREFIX(updatePosition), PREFIX(isPublicId)
#define IGNORE_SECTION_TOK_VTABLE
Definition: xmltok.c:65
#define PREFIX(ident)
Definition: xmltok.c:922

Definition at line 68 of file xmltok.c.

◆ XML_TOK_IMPL_C [1/3]

#define XML_TOK_IMPL_C

Definition at line 933 of file xmltok.c.

◆ XML_TOK_IMPL_C [2/3]

#define XML_TOK_IMPL_C

Definition at line 933 of file xmltok.c.

◆ XML_TOK_IMPL_C [3/3]

#define XML_TOK_IMPL_C

Definition at line 933 of file xmltok.c.

◆ XML_TOK_NS_C

#define XML_TOK_NS_C

Definition at line 1650 of file xmltok.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UTF8_cval1 
UTF8_cval2 
UTF8_cval3 
UTF8_cval4 

Definition at line 318 of file xmltok.c.

318 { /* UTF8_cvalN is value of masked first byte of N byte sequence */
319 UTF8_cval1 = 0x00,
320 UTF8_cval2 = 0xc0,
321 UTF8_cval3 = 0xe0,
322 UTF8_cval4 = 0xf0
323};
@ UTF8_cval4
Definition: xmltok.c:322
@ UTF8_cval1
Definition: xmltok.c:319
@ UTF8_cval2
Definition: xmltok.c:320
@ UTF8_cval3
Definition: xmltok.c:321

◆ anonymous enum

anonymous enum
Enumerator
UNKNOWN_ENC 
ISO_8859_1_ENC 
US_ASCII_ENC 
UTF_8_ENC 
UTF_16_ENC 
UTF_16BE_ENC 
UTF_16LE_ENC 
NO_ENC 

Definition at line 1479 of file xmltok.c.

1479 {
1480 UNKNOWN_ENC = -1,
1481 ISO_8859_1_ENC = 0,
1483 UTF_8_ENC,
1484 UTF_16_ENC,
1487 /* must match encodingNames up to here */
1488 NO_ENC
1489};
@ NO_ENC
Definition: xmltok.c:1488
@ US_ASCII_ENC
Definition: xmltok.c:1482
@ ISO_8859_1_ENC
Definition: xmltok.c:1481
@ UTF_8_ENC
Definition: xmltok.c:1483
@ UTF_16_ENC
Definition: xmltok.c:1484
@ UNKNOWN_ENC
Definition: xmltok.c:1480
@ UTF_16BE_ENC
Definition: xmltok.c:1485
@ UTF_16LE_ENC
Definition: xmltok.c:1486

Function Documentation

◆ _INTERNAL_trim_to_complete_utf8_characters()

void _INTERNAL_trim_to_complete_utf8_characters ( const char *  from,
const char **  fromLimRef 
)

Definition at line 326 of file xmltok.c.

327 {
328 const char *fromLim = *fromLimRef;
329 size_t walked = 0;
330 for (; fromLim > from; fromLim--, walked++) {
331 const unsigned char prev = (unsigned char)fromLim[-1];
332 if ((prev & 0xf8u)
333 == 0xf0u) { /* 4-byte character, lead by 0b11110xxx byte */
334 if (walked + 1 >= 4) {
335 fromLim += 4 - 1;
336 break;
337 } else {
338 walked = 0;
339 }
340 } else if ((prev & 0xf0u)
341 == 0xe0u) { /* 3-byte character, lead by 0b1110xxxx byte */
342 if (walked + 1 >= 3) {
343 fromLim += 3 - 1;
344 break;
345 } else {
346 walked = 0;
347 }
348 } else if ((prev & 0xe0u)
349 == 0xc0u) { /* 2-byte character, lead by 0b110xxxxx byte */
350 if (walked + 1 >= 2) {
351 fromLim += 2 - 1;
352 break;
353 } else {
354 walked = 0;
355 }
356 } else if ((prev & 0x80u)
357 == 0x00u) { /* 1-byte character, matching 0b0xxxxxxx */
358 break;
359 }
360 }
361 *fromLimRef = fromLim;
362}

◆ XmlInitUnknownEncoding()

ENCODING * XmlInitUnknownEncoding ( void *  mem,
int *  table,
CONVERTER  convert,
void *  userData 
)

Definition at line 1406 of file xmltok.c.

1407 {
1408 int i;
1409 struct unknown_encoding *e = (struct unknown_encoding *)mem;
1410 memcpy(mem, &latin1_encoding, sizeof(struct normal_encoding));
1411 for (i = 0; i < 128; i++)
1412 if (latin1_encoding.type[i] != BT_OTHER
1413 && latin1_encoding.type[i] != BT_NONXML && table[i] != i)
1414 return 0;
1415 for (i = 0; i < 256; i++) {
1416 int c = table[i];
1417 if (c == -1) {
1418 e->normal.type[i] = BT_MALFORM;
1419 /* This shouldn't really get used. */
1420 e->utf16[i] = 0xFFFF;
1421 e->utf8[i][0] = 1;
1422 e->utf8[i][1] = 0;
1423 } else if (c < 0) {
1424 if (c < -4)
1425 return 0;
1426 /* Multi-byte sequences need a converter function */
1427 if (! convert)
1428 return 0;
1429 e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2));
1430 e->utf8[i][0] = 0;
1431 e->utf16[i] = 0;
1432 } else if (c < 0x80) {
1433 if (latin1_encoding.type[c] != BT_OTHER
1434 && latin1_encoding.type[c] != BT_NONXML && c != i)
1435 return 0;
1436 e->normal.type[i] = latin1_encoding.type[c];
1437 e->utf8[i][0] = 1;
1438 e->utf8[i][1] = (char)c;
1439 e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c);
1440 } else if (checkCharRefNumber(c) < 0) {
1441 e->normal.type[i] = BT_NONXML;
1442 /* This shouldn't really get used. */
1443 e->utf16[i] = 0xFFFF;
1444 e->utf8[i][0] = 1;
1445 e->utf8[i][1] = 0;
1446 } else {
1447 if (c > 0xFFFF)
1448 return 0;
1449 if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
1450 e->normal.type[i] = BT_NMSTRT;
1451 else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
1452 e->normal.type[i] = BT_NAME;
1453 else
1454 e->normal.type[i] = BT_OTHER;
1455 e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
1456 e->utf16[i] = (unsigned short)c;
1457 }
1458 }
1459 e->userData = userData;
1460 e->convert = convert;
1461 if (convert) {
1462 e->normal.isName2 = unknown_isName;
1463 e->normal.isName3 = unknown_isName;
1464 e->normal.isName4 = unknown_isName;
1465 e->normal.isNmstrt2 = unknown_isNmstrt;
1466 e->normal.isNmstrt3 = unknown_isNmstrt;
1467 e->normal.isNmstrt4 = unknown_isNmstrt;
1468 e->normal.isInvalid2 = unknown_isInvalid;
1469 e->normal.isInvalid3 = unknown_isInvalid;
1470 e->normal.isInvalid4 = unknown_isInvalid;
1471 }
1472 e->normal.enc.utf8Convert = unknown_toUtf8;
1473 e->normal.enc.utf16Convert = unknown_toUtf16;
1474 return &(e->normal.enc);
1475}
BT_OTHER
Definition: asciitab.h:44
BT_NMSTRT
Definition: asciitab.h:52
BT_NAME
Definition: asciitab.h:46
BT_NONXML
Definition: asciitab.h:35
unsigned char type[256]
Definition: xmltok.c:187
ENCODING enc
Definition: xmltok.c:186
unsigned short utf16[256]
Definition: xmltok.c:1318
CONVERTER convert
Definition: xmltok.c:1316
void * userData
Definition: xmltok.c:1317
char utf8[256][4]
Definition: xmltok.c:1319
struct normal_encoding normal
Definition: xmltok.c:1315
BT_MALFORM
Definition: utf8tab.h:66
BT_LEAD2
Definition: utf8tab.h:51
#define UCS2_GET_NAMING(pages, hi, lo)
Definition: xmltok.c:78
int FASTCALL XmlUtf8Encode(int c, char *buf)
Definition: xmltok.c:1262

◆ XmlSizeOfUnknownEncoding()

int XmlSizeOfUnknownEncoding ( void  )

Definition at line 1325 of file xmltok.c.

1325 {
1326 return sizeof(struct unknown_encoding);
1327}

◆ XmlUtf16Encode()

int FASTCALL XmlUtf16Encode ( int  charNum,
unsigned short *  buf 
)

Definition at line 1298 of file xmltok.c.

1298 {
1299 if (charNum < 0)
1300 return 0;
1301 if (charNum < 0x10000) {
1302 buf[0] = (unsigned short)charNum;
1303 return 1;
1304 }
1305 if (charNum < 0x110000) {
1306 charNum -= 0x10000;
1307 buf[0] = (unsigned short)((charNum >> 10) + 0xD800);
1308 buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00);
1309 return 2;
1310 }
1311 return 0;
1312}

◆ XmlUtf8Encode()

int FASTCALL XmlUtf8Encode ( int  c,
char *  buf 
)

Definition at line 1262 of file xmltok.c.

1262 {
1263 enum {
1264 /* minN is minimum legal resulting value for N byte sequence */
1265 min2 = 0x80,
1266 min3 = 0x800,
1267 min4 = 0x10000
1268 };
1269
1270 if (c < 0)
1271 return 0; /* LCOV_EXCL_LINE: this case is always eliminated beforehand */
1272 if (c < min2) {
1273 buf[0] = (char)(c | UTF8_cval1);
1274 return 1;
1275 }
1276 if (c < min3) {
1277 buf[0] = (char)((c >> 6) | UTF8_cval2);
1278 buf[1] = (char)((c & 0x3f) | 0x80);
1279 return 2;
1280 }
1281 if (c < min4) {
1282 buf[0] = (char)((c >> 12) | UTF8_cval3);
1283 buf[1] = (char)(((c >> 6) & 0x3f) | 0x80);
1284 buf[2] = (char)((c & 0x3f) | 0x80);
1285 return 3;
1286 }
1287 if (c < 0x110000) {
1288 buf[0] = (char)((c >> 18) | UTF8_cval4);
1289 buf[1] = (char)(((c >> 12) & 0x3f) | 0x80);
1290 buf[2] = (char)(((c >> 6) & 0x3f) | 0x80);
1291 buf[3] = (char)((c & 0x3f) | 0x80);
1292 return 4;
1293 }
1294 return 0; /* LCOV_EXCL_LINE: this case too is eliminated before calling */
1295}

Referenced by XmlInitUnknownEncoding().