Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
xmltok.cc File Reference
#include <stddef.h>
#include "expat_external.h"
#include "internal.h"
#include "xmltok.h"
#include "nametab.h"
#include "xmltok_impl.h"
#include "ascii.h"
#include "xmltok_impl.cc"
#include "asciitab.h"
#include "utf8tab.h"
#include "iasciitab.h"
#include "latin1tab.h"
#include "xmltok_ns.cc"
Include dependency graph for xmltok.cc:

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)] & (1 << ((lo) & 0x1F)))
 
#define UTF8_GET_NAMING2(pages, byte)
 
#define UTF8_GET_NAMING3(pages, byte)
 
#define UTF8_GET_NAMING(pages, p, n)
 
#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 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(enc, p)   ((p)[1] == 0 ? (p)[0] : -1)
 
#define LITTLE2_CHAR_MATCHES(enc, p, c)   ((p)[1] == 0 && (p)[0] == c)
 
#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)   UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
 
#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, 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(enc, p)
 
#define CHAR_MATCHES(enc, p, c)   LITTLE2_CHAR_MATCHES(enc, p, c)
 
#define IS_NAME_CHAR(enc, p, n)   0
 
#define IS_NAME_CHAR_MINBPC(enc, p)   LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
 
#define IS_NMSTRT_CHAR(enc, p, n)   (0)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)   LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, 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(enc, p)   ((p)[0] == 0 ? (p)[1] : -1)
 
#define BIG2_CHAR_MATCHES(enc, p, c)   ((p)[0] == 0 && (p)[1] == c)
 
#define BIG2_IS_NAME_CHAR_MINBPC(enc, p)   UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
 
#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, 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(enc, p)
 
#define CHAR_MATCHES(enc, p, c)   BIG2_CHAR_MATCHES(enc, p, c)
 
#define IS_NAME_CHAR(enc, p, n)   0
 
#define IS_NAME_CHAR_MINBPC(enc, p)   BIG2_IS_NAME_CHAR_MINBPC(enc, p)
 
#define IS_NMSTRT_CHAR(enc, p, n)   (0)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)   BIG2_IS_NMSTRT_CHAR_MINBPC(enc, 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

static int PTRFASTCALL isNever (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL utf8_isName2 (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL utf8_isName3 (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL utf8_isNmstrt2 (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL utf8_isNmstrt3 (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL utf8_isInvalid2 (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL utf8_isInvalid3 (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL utf8_isInvalid4 (const ENCODING *enc, const char *p)
 
static int FASTCALL checkCharRefNumber (int)
 
static void PTRCALL utf8_toUtf8 (const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
 
static void PTRCALL utf8_toUtf16 (const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
 
static void PTRCALL latin1_toUtf8 (const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
 
static void PTRCALL latin1_toUtf16 (const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
 
static void PTRCALL ascii_toUtf8 (const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
 
static int PTRFASTCALL unicode_byte_type (char hi, char lo)
 
static int FASTCALL streqci (const char *s1, const char *s2)
 
static void PTRCALL initUpdatePosition (const ENCODING *enc, const char *ptr, const char *end, POSITION *pos)
 
static int toAscii (const ENCODING *enc, const char *ptr, const char *end)
 
static int FASTCALL isSpace (int c)
 
static int parsePseudoAttribute (const ENCODING *enc, const char *ptr, const char *end, const char **namePtr, const char **nameEndPtr, const char **valPtr, const char **nextTokPtr)
 
static int doParseXmlDecl (const ENCODING *(*encodingFinder)(const ENCODING *, const char *, const char *), int isGeneralTextEntity, const ENCODING *enc, const char *ptr, const char *end, const char **badPtr, const char **versionPtr, const char **versionEndPtr, const char **encodingName, const ENCODING **encoding, int *standalone)
 
int FASTCALL XmlUtf8Encode (int c, char *buf)
 
int FASTCALL XmlUtf16Encode (int charNum, unsigned short *buf)
 
int XmlSizeOfUnknownEncoding (void)
 
static int PTRFASTCALL unknown_isName (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL unknown_isNmstrt (const ENCODING *enc, const char *p)
 
static int PTRFASTCALL unknown_isInvalid (const ENCODING *enc, const char *p)
 
static void PTRCALL unknown_toUtf8 (const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
 
static void PTRCALL unknown_toUtf16 (const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
 
ENCODINGXmlInitUnknownEncoding (void *mem, int *table, CONVERTER convert, void *userData)
 
static int FASTCALL getEncodingIndex (const char *name)
 
static int initScan (const ENCODING *const *encodingTable, const INIT_ENCODING *enc, int state, const char *ptr, const char *end, const char **nextTokPtr)
 

Variables

static struct normal_encoding utf8_encoding
 
static struct normal_encoding internal_utf8_encoding
 
static struct normal_encoding latin1_encoding
 
static struct normal_encoding ascii_encoding
 
static struct normal_encoding little2_encoding
 
static struct normal_encoding internal_little2_encoding
 
static struct normal_encoding big2_encoding
 
static struct normal_encoding internal_big2_encoding
 
static const char KW_version []
 
static const char KW_encoding []
 
static const char KW_standalone []
 
static const char KW_yes []
 
static const char KW_no []
 
static const char KW_ISO_8859_1 []
 
static const char KW_US_ASCII []
 
static const char KW_UTF_8 []
 
static const char KW_UTF_16 []
 
static const char KW_UTF_16BE []
 
static const char KW_UTF_16LE []
 

Macro Definition Documentation

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

Definition at line 202 of file xmltok.cc.

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

Definition at line 1260 of file xmltok.cc.

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

Definition at line 789 of file xmltok.cc.

#define BIG2_BYTE_TYPE (   enc,
  p 
)
Value:
((p)[0] == 0 \
? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
: unicode_byte_type((p)[0], (p)[1]))
static int PTRFASTCALL unicode_byte_type(char hi, char lo)
Definition: xmltok.cc:525
const char * p
Definition: xmltok.h:285

Definition at line 785 of file xmltok.cc.

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

Definition at line 790 of file xmltok.cc.

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

Definition at line 791 of file xmltok.cc.

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

Definition at line 793 of file xmltok.cc.

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

Definition at line 838 of file xmltok.cc.

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

Definition at line 838 of file xmltok.cc.

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

Definition at line 838 of file xmltok.cc.

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

Definition at line 837 of file xmltok.cc.

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

Definition at line 837 of file xmltok.cc.

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

Definition at line 837 of file xmltok.cc.

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

Definition at line 839 of file xmltok.cc.

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

Definition at line 839 of file xmltok.cc.

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

Definition at line 839 of file xmltok.cc.

#define DEFINE_UTF16_TO_UTF16 (   E)
Value:
static void PTRCALL \
E ## toUtf16(const ENCODING *enc, \
const char **fromP, const char *fromLim, \
unsigned short **toP, const unsigned short *toLim) \
{ \
/* 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(nIso!=0)
#define GET_HI(ptr)
Definition: xmltok.cc:635
#define GET_LO(ptr)
Definition: xmltok.cc:634
for(G4int i1=0;i1< theStableOnes.GetNumberOfIsotopes(static_cast< G4int >(anE->GetZ()));i1++)

Definition at line 606 of file xmltok.cc.

#define DEFINE_UTF16_TO_UTF8 (   E)

Definition at line 543 of file xmltok.cc.

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

Definition at line 635 of file xmltok.cc.

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

Definition at line 635 of file xmltok.cc.

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

Definition at line 634 of file xmltok.cc.

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

Definition at line 634 of file xmltok.cc.

#define IGNORE_SECTION_TOK_VTABLE   /* as nothing */

Definition at line 34 of file xmltok.cc.

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

Definition at line 1490 of file xmltok.cc.

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

Definition at line 278 of file xmltok.cc.

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

Definition at line 840 of file xmltok.cc.

#define IS_NAME_CHAR (   enc,
  p,
 
)    0

Definition at line 840 of file xmltok.cc.

#define IS_NAME_CHAR (   enc,
  p,
 
)    0

Definition at line 840 of file xmltok.cc.

#define IS_NAME_CHAR_MINBPC (   enc,
  p 
)    (0)

Definition at line 841 of file xmltok.cc.

#define IS_NAME_CHAR_MINBPC (   enc,
  p 
)    LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)

Definition at line 841 of file xmltok.cc.

#define IS_NAME_CHAR_MINBPC (   enc,
  p 
)    BIG2_IS_NAME_CHAR_MINBPC(enc, p)

Definition at line 841 of file xmltok.cc.

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

Definition at line 842 of file xmltok.cc.

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

Definition at line 842 of file xmltok.cc.

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

Definition at line 842 of file xmltok.cc.

#define IS_NMSTRT_CHAR_MINBPC (   enc,
  p 
)    (0)

Definition at line 843 of file xmltok.cc.

#define IS_NMSTRT_CHAR_MINBPC (   enc,
  p 
)    LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)

Definition at line 843 of file xmltok.cc.

#define IS_NMSTRT_CHAR_MINBPC (   enc,
  p 
)    BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)

Definition at line 843 of file xmltok.cc.

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

Definition at line 648 of file xmltok.cc.

#define LITTLE2_BYTE_TYPE (   enc,
  p 
)
Value:
((p)[1] == 0 \
? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
: unicode_byte_type((p)[1], (p)[0]))
static int PTRFASTCALL unicode_byte_type(char hi, char lo)
Definition: xmltok.cc:525
const char * p
Definition: xmltok.h:285

Definition at line 644 of file xmltok.cc.

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

Definition at line 649 of file xmltok.cc.

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

Definition at line 650 of file xmltok.cc.

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

Definition at line 652 of file xmltok.cc.

#define MINBPC (   enc)    1

Definition at line 835 of file xmltok.cc.

#define MINBPC (   enc)    2

Definition at line 835 of file xmltok.cc.

#define MINBPC (   enc)    2

Definition at line 835 of file xmltok.cc.

#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.cc.

#define NS (   x)    x

Definition at line 1624 of file xmltok.cc.

#define ns (   x)    x

Definition at line 1625 of file xmltok.cc.

#define PREFIX (   ident)    normal_ ## ident

Definition at line 834 of file xmltok.cc.

#define PREFIX (   ident)    little2_ ## ident

Definition at line 834 of file xmltok.cc.

#define PREFIX (   ident)    big2_ ## ident

Definition at line 834 of file xmltok.cc.

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

Definition at line 247 of file xmltok.cc.

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

Definition at line 632 of file xmltok.cc.

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

Definition at line 632 of file xmltok.cc.

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

Definition at line 1491 of file xmltok.cc.

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

Definition at line 215 of file xmltok.cc.

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

Definition at line 53 of file xmltok.cc.

#define UTF8_GET_NAMING (   pages,
  p,
 
)
Value:
((n) == 2 \
? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
: ((n) == 3 \
? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \
: 0))
const char * p
Definition: xmltok.h:285
#define UTF8_GET_NAMING2(pages, byte)
Definition: xmltok.cc:60
#define UTF8_GET_NAMING3(pages, byte)
Definition: xmltok.cc:71

Definition at line 79 of file xmltok.cc.

#define UTF8_GET_NAMING2 (   pages,
  byte 
)
Value:
(namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
+ ((((byte)[0]) & 3) << 1) \
+ ((((byte)[1]) >> 5) & 1)] \
& (1 << (((byte)[1]) & 0x1F)))
static const unsigned namingBitmap[]
Definition: nametab.h:1

Definition at line 60 of file xmltok.cc.

#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)] \
& (1 << (((byte)[2]) & 0x1F)))
static const unsigned namingBitmap[]
Definition: nametab.h:1

Definition at line 71 of file xmltok.cc.

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

Definition at line 96 of file xmltok.cc.

#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)))
const char * p
Definition: xmltok.h:285

Definition at line 99 of file xmltok.cc.

#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)))
const char * p
Definition: xmltok.h:285

Definition at line 116 of file xmltok.cc.

#define utf8_isName4   isNever

Definition at line 147 of file xmltok.cc.

#define utf8_isNmstrt4   isNever

Definition at line 161 of file xmltok.cc.

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

Definition at line 51 of file xmltok.cc.

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

Definition at line 37 of file xmltok.cc.

#define XML_TOK_IMPL_C

Definition at line 845 of file xmltok.cc.

#define XML_TOK_IMPL_C

Definition at line 845 of file xmltok.cc.

#define XML_TOK_IMPL_C

Definition at line 845 of file xmltok.cc.

#define XML_TOK_NS_C

Definition at line 1626 of file xmltok.cc.

Enumeration Type Documentation

anonymous enum
Enumerator
UTF8_cval1 
UTF8_cval2 
UTF8_cval3 
UTF8_cval4 

Definition at line 319 of file xmltok.cc.

319  { /* UTF8_cvalN is value of masked first byte of N byte sequence */
320  UTF8_cval1 = 0x00,
321  UTF8_cval2 = 0xc0,
322  UTF8_cval3 = 0xe0,
323  UTF8_cval4 = 0xf0
324 };
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 1431 of file xmltok.cc.

1431  {
1432  UNKNOWN_ENC = -1,
1433  ISO_8859_1_ENC = 0,
1434  US_ASCII_ENC,
1435  UTF_8_ENC,
1436  UTF_16_ENC,
1437  UTF_16BE_ENC,
1438  UTF_16LE_ENC,
1439  /* must match encodingNames up to here */
1440  NO_ENC
1441 };

Function Documentation

static void PTRCALL ascii_toUtf8 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
char **  toP,
const char *  toLim 
)
static

Definition at line 492 of file xmltok.cc.

495 {
496  while (*fromP != fromLim && *toP != toLim)
497  *(*toP)++ = *(*fromP)++;
498 }
static int FASTCALL checkCharRefNumber ( int  result)
static

Definition at line 1179 of file xmltok.cc.

1180 {
1181  switch (result >> 8) {
1182  case 0xD8: case 0xD9: case 0xDA: case 0xDB:
1183  case 0xDC: case 0xDD: case 0xDE: case 0xDF:
1184  return -1;
1185  case 0:
1187  return -1;
1188  break;
1189  case 0xFF:
1190  if (result == 0xFFFE || result == 0xFFFF)
1191  return -1;
1192  break;
1193  }
1194  return result;
1195 }
G4double G4ParticleHPJENDLHEData::G4double result
BT_NONXML
Definition: asciitab.h:5
static struct normal_encoding latin1_encoding
Definition: xmltok.cc:480
unsigned char type[256]
Definition: xmltok.cc:183

Here is the caller graph for this function:

static int doParseXmlDecl ( const ENCODING *(*)(const ENCODING *, const char *, const char *)  encodingFinder,
int  isGeneralTextEntity,
const ENCODING enc,
const char *  ptr,
const char *  end,
const char **  badPtr,
const char **  versionPtr,
const char **  versionEndPtr,
const char **  encodingName,
const ENCODING **  encoding,
int standalone 
)
static

Definition at line 1087 of file xmltok.cc.

1100 {
1101  const char *val = NULL;
1102  const char *name = NULL;
1103  const char *nameEnd = NULL;
1104  ptr += 5 * enc->minBytesPerChar;
1105  end -= 2 * enc->minBytesPerChar;
1106  if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)
1107  || !name) {
1108  *badPtr = ptr;
1109  return 0;
1110  }
1111  if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) {
1112  if (!isGeneralTextEntity) {
1113  *badPtr = name;
1114  return 0;
1115  }
1116  }
1117  else {
1118  if (versionPtr)
1119  *versionPtr = val;
1120  if (versionEndPtr)
1121  *versionEndPtr = ptr;
1122  if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
1123  *badPtr = ptr;
1124  return 0;
1125  }
1126  if (!name) {
1127  if (isGeneralTextEntity) {
1128  /* a TextDecl must have an EncodingDecl */
1129  *badPtr = ptr;
1130  return 0;
1131  }
1132  return 1;
1133  }
1134  }
1135  if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) {
1136  int c = toAscii(enc, val, end);
1137  if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) {
1138  *badPtr = val;
1139  return 0;
1140  }
1141  if (encodingName)
1142  *encodingName = val;
1143  if (encoding)
1144  *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar);
1145  if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
1146  *badPtr = ptr;
1147  return 0;
1148  }
1149  if (!name)
1150  return 1;
1151  }
1152  if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone)
1153  || isGeneralTextEntity) {
1154  *badPtr = name;
1155  return 0;
1156  }
1157  if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) {
1158  if (standalone)
1159  *standalone = 1;
1160  }
1161  else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) {
1162  if (standalone)
1163  *standalone = 0;
1164  }
1165  else {
1166  *badPtr = val;
1167  return 0;
1168  }
1169  while (isSpace(toAscii(enc, ptr, end)))
1170  ptr += enc->minBytesPerChar;
1171  if (ptr != end) {
1172  *badPtr = ptr;
1173  return 0;
1174  }
1175  return 1;
1176 }
const XML_Char * name
Definition: expat.h:151
static int toAscii(const ENCODING *enc, const char *ptr, const char *end)
Definition: xmltok.cc:953
int minBytesPerChar
Definition: xmltok.h:171
static const char KW_version[]
Definition: xmltok.cc:1065
#define ASCII_z
Definition: ascii.h:57
const XML_Char const XML_Char int standalone
Definition: expat.h:187
static const char KW_encoding[]
Definition: xmltok.cc:1069
static int FASTCALL isSpace(int c)
Definition: xmltok.cc:965
#define ASCII_Z
Definition: ascii.h:30
#define ASCII_A
Definition: ascii.h:5
static const char KW_no[]
Definition: xmltok.cc:1082
static const char KW_yes[]
Definition: xmltok.cc:1078
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2)
Definition: xmltok.h:231
static int parsePseudoAttribute(const ENCODING *enc, const char *ptr, const char *end, const char **namePtr, const char **nameEndPtr, const char **valPtr, const char **nextTokPtr)
Definition: xmltok.cc:981
#define ASCII_a
Definition: ascii.h:32
static const char KW_standalone[]
Definition: xmltok.cc:1073

Here is the call graph for this function:

static int FASTCALL getEncodingIndex ( const char *  name)
static

Definition at line 1467 of file xmltok.cc.

1468 {
1469  static const char * const encodingNames[] = {
1470  KW_ISO_8859_1,
1471  KW_US_ASCII,
1472  KW_UTF_8,
1473  KW_UTF_16,
1474  KW_UTF_16BE,
1475  KW_UTF_16LE,
1476  };
1477  int i;
1478  if (name == NULL)
1479  return NO_ENC;
1480  for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++)
1481  if (streqci(name, encodingNames[i]))
1482  return i;
1483  return UNKNOWN_ENC;
1484 }
static const char KW_ISO_8859_1[]
Definition: xmltok.cc:1443
const XML_Char * name
Definition: expat.h:151
static const char KW_UTF_8[]
Definition: xmltok.cc:1451
static const char KW_UTF_16[]
Definition: xmltok.cc:1454
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
static int FASTCALL streqci(const char *s1, const char *s2)
Definition: xmltok.cc:928
static const char KW_UTF_16BE[]
Definition: xmltok.cc:1457
static const char KW_US_ASCII[]
Definition: xmltok.cc:1447
static const char KW_UTF_16LE[]
Definition: xmltok.cc:1461

Here is the call graph for this function:

static int initScan ( const ENCODING *const *  encodingTable,
const INIT_ENCODING enc,
int  state,
const char *  ptr,
const char *  end,
const char **  nextTokPtr 
)
static

Definition at line 1502 of file xmltok.cc.

1508 {
1509  const ENCODING **encPtr;
1510 
1511  if (ptr == end)
1512  return XML_TOK_NONE;
1513  encPtr = enc->encPtr;
1514  if (ptr + 1 == end) {
1515  /* only a single byte available for auto-detection */
1516 #ifndef XML_DTD /* FIXME */
1517  /* a well-formed document entity must have more than one byte */
1518  if (state != XML_CONTENT_STATE)
1519  return XML_TOK_PARTIAL;
1520 #endif
1521  /* so we're parsing an external text entity... */
1522  /* if UTF-16 was externally specified, then we need at least 2 bytes */
1523  switch (INIT_ENC_INDEX(enc)) {
1524  case UTF_16_ENC:
1525  case UTF_16LE_ENC:
1526  case UTF_16BE_ENC:
1527  return XML_TOK_PARTIAL;
1528  }
1529  switch ((unsigned char)*ptr) {
1530  case 0xFE:
1531  case 0xFF:
1532  case 0xEF: /* possibly first byte of UTF-8 BOM */
1533  if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
1534  && state == XML_CONTENT_STATE)
1535  break;
1536  /* fall through */
1537  case 0x00:
1538  case 0x3C:
1539  return XML_TOK_PARTIAL;
1540  }
1541  }
1542  else {
1543  switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) {
1544  case 0xFEFF:
1545  if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
1546  && state == XML_CONTENT_STATE)
1547  break;
1548  *nextTokPtr = ptr + 2;
1549  *encPtr = encodingTable[UTF_16BE_ENC];
1550  return XML_TOK_BOM;
1551  /* 00 3C is handled in the default case */
1552  case 0x3C00:
1553  if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC
1554  || INIT_ENC_INDEX(enc) == UTF_16_ENC)
1555  && state == XML_CONTENT_STATE)
1556  break;
1557  *encPtr = encodingTable[UTF_16LE_ENC];
1558  return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
1559  case 0xFFFE:
1560  if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
1561  && state == XML_CONTENT_STATE)
1562  break;
1563  *nextTokPtr = ptr + 2;
1564  *encPtr = encodingTable[UTF_16LE_ENC];
1565  return XML_TOK_BOM;
1566  case 0xEFBB:
1567  /* Maybe a UTF-8 BOM (EF BB BF) */
1568  /* If there's an explicitly specified (external) encoding
1569  of ISO-8859-1 or some flavour of UTF-16
1570  and this is an external text entity,
1571  don't look for the BOM,
1572  because it might be a legal data.
1573  */
1574  if (state == XML_CONTENT_STATE) {
1575  int e = INIT_ENC_INDEX(enc);
1576  if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC
1577  || e == UTF_16LE_ENC || e == UTF_16_ENC)
1578  break;
1579  }
1580  if (ptr + 2 == end)
1581  return XML_TOK_PARTIAL;
1582  if ((unsigned char)ptr[2] == 0xBF) {
1583  *nextTokPtr = ptr + 3;
1584  *encPtr = encodingTable[UTF_8_ENC];
1585  return XML_TOK_BOM;
1586  }
1587  break;
1588  default:
1589  if (ptr[0] == '\0') {
1590  /* 0 isn't a legal data character. Furthermore a document
1591  entity can only start with ASCII characters. So the only
1592  way this can fail to be big-endian UTF-16 if it it's an
1593  external parsed general entity that's labelled as
1594  UTF-16LE.
1595  */
1596  if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC)
1597  break;
1598  *encPtr = encodingTable[UTF_16BE_ENC];
1599  return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
1600  }
1601  else if (ptr[1] == '\0') {
1602  /* We could recover here in the case:
1603  - parsing an external entity
1604  - second byte is 0
1605  - no externally specified encoding
1606  - no encoding declaration
1607  by assuming UTF-16LE. But we don't, because this would mean when
1608  presented just with a single byte, we couldn't reliably determine
1609  whether we needed further bytes.
1610  */
1611  if (state == XML_CONTENT_STATE)
1612  break;
1613  *encPtr = encodingTable[UTF_16LE_ENC];
1614  return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
1615  }
1616  break;
1617  }
1618  }
1619  *encPtr = encodingTable[INIT_ENC_INDEX(enc)];
1620  return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
1621 }
#define INIT_ENC_INDEX(enc)
Definition: xmltok.cc:1490
uch e
Definition: csz_inflate.cc:248
#define XmlTok(enc, state, ptr, end, nextTokPtr)
Definition: xmltok.h:198
#define XML_TOK_PARTIAL
Definition: xmltok.h:22
const ENCODING ** encPtr
Definition: xmltok.h:263
#define XML_CONTENT_STATE
Definition: xmltok.h:97
#define XML_TOK_BOM
Definition: xmltok.h:45
#define XML_TOK_NONE
Definition: xmltok.h:18
static void PTRCALL initUpdatePosition ( const ENCODING enc,
const char *  ptr,
const char *  end,
POSITION pos 
)
static

Definition at line 946 of file xmltok.cc.

948 {
949  normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
950 }
static struct normal_encoding utf8_encoding
Definition: xmltok.cc:398
ENCODING enc
Definition: xmltok.cc:182
static int PTRFASTCALL isNever ( const ENCODING enc,
const char *  p 
)
static

Definition at line 130 of file xmltok.cc.

131 {
132  return 0;
133 }
static int FASTCALL isSpace ( int  c)
static

Definition at line 965 of file xmltok.cc.

966 {
967  switch (c) {
968  case 0x20:
969  case 0xD:
970  case 0xA:
971  case 0x9:
972  return 1;
973  }
974  return 0;
975 }

Here is the caller graph for this function:

static void PTRCALL latin1_toUtf16 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
unsigned short **  toP,
const unsigned short *  toLim 
)
static

Definition at line 459 of file xmltok.cc.

462 {
463  while (*fromP != fromLim && *toP != toLim)
464  *(*toP)++ = (unsigned char)*(*fromP)++;
465 }
static void PTRCALL latin1_toUtf8 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
char **  toP,
const char *  toLim 
)
static

Definition at line 434 of file xmltok.cc.

437 {
438  for (;;) {
439  unsigned char c;
440  if (*fromP == fromLim)
441  break;
442  c = (unsigned char)**fromP;
443  if (c & 0x80) {
444  if (toLim - *toP < 2)
445  break;
446  *(*toP)++ = (char)((c >> 6) | UTF8_cval2);
447  *(*toP)++ = (char)((c & 0x3f) | 0x80);
448  (*fromP)++;
449  }
450  else {
451  if (*toP == toLim)
452  break;
453  *(*toP)++ = *(*fromP)++;
454  }
455  }
456 }
static int parsePseudoAttribute ( const ENCODING enc,
const char *  ptr,
const char *  end,
const char **  namePtr,
const char **  nameEndPtr,
const char **  valPtr,
const char **  nextTokPtr 
)
static

Definition at line 981 of file xmltok.cc.

988 {
989  int c;
990  char open;
991  if (ptr == end) {
992  *namePtr = NULL;
993  return 1;
994  }
995  if (!isSpace(toAscii(enc, ptr, end))) {
996  *nextTokPtr = ptr;
997  return 0;
998  }
999  do {
1000  ptr += enc->minBytesPerChar;
1001  } while (isSpace(toAscii(enc, ptr, end)));
1002  if (ptr == end) {
1003  *namePtr = NULL;
1004  return 1;
1005  }
1006  *namePtr = ptr;
1007  for (;;) {
1008  c = toAscii(enc, ptr, end);
1009  if (c == -1) {
1010  *nextTokPtr = ptr;
1011  return 0;
1012  }
1013  if (c == ASCII_EQUALS) {
1014  *nameEndPtr = ptr;
1015  break;
1016  }
1017  if (isSpace(c)) {
1018  *nameEndPtr = ptr;
1019  do {
1020  ptr += enc->minBytesPerChar;
1021  } while (isSpace(c = toAscii(enc, ptr, end)));
1022  if (c != ASCII_EQUALS) {
1023  *nextTokPtr = ptr;
1024  return 0;
1025  }
1026  break;
1027  }
1028  ptr += enc->minBytesPerChar;
1029  }
1030  if (ptr == *namePtr) {
1031  *nextTokPtr = ptr;
1032  return 0;
1033  }
1034  ptr += enc->minBytesPerChar;
1035  c = toAscii(enc, ptr, end);
1036  while (isSpace(c)) {
1037  ptr += enc->minBytesPerChar;
1038  c = toAscii(enc, ptr, end);
1039  }
1040  if (c != ASCII_QUOT && c != ASCII_APOS) {
1041  *nextTokPtr = ptr;
1042  return 0;
1043  }
1044  open = (char)c;
1045  ptr += enc->minBytesPerChar;
1046  *valPtr = ptr;
1047  for (;; ptr += enc->minBytesPerChar) {
1048  c = toAscii(enc, ptr, end);
1049  if (c == open)
1050  break;
1051  if (!(ASCII_a <= c && c <= ASCII_z)
1052  && !(ASCII_A <= c && c <= ASCII_Z)
1053  && !(ASCII_0 <= c && c <= ASCII_9)
1054  && c != ASCII_PERIOD
1055  && c != ASCII_MINUS
1056  && c != ASCII_UNDERSCORE) {
1057  *nextTokPtr = ptr;
1058  return 0;
1059  }
1060  }
1061  *nextTokPtr = ptr + enc->minBytesPerChar;
1062  return 1;
1063 }
#define ASCII_PERIOD
Definition: ascii.h:77
static int toAscii(const ENCODING *enc, const char *ptr, const char *end)
Definition: xmltok.cc:953
int minBytesPerChar
Definition: xmltok.h:171
#define ASCII_MINUS
Definition: ascii.h:76
#define ASCII_z
Definition: ascii.h:57
#define ASCII_APOS
Definition: ascii.h:75
#define ASCII_UNDERSCORE
Definition: ascii.h:85
#define ASCII_9
Definition: ascii.h:68
static int FASTCALL isSpace(int c)
Definition: xmltok.cc:965
#define ASCII_Z
Definition: ascii.h:30
#define ASCII_A
Definition: ascii.h:5
#define ASCII_0
Definition: ascii.h:59
#define ASCII_a
Definition: ascii.h:32
#define ASCII_QUOT
Definition: ascii.h:73
#define ASCII_EQUALS
Definition: ascii.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

static int FASTCALL streqci ( const char *  s1,
const char *  s2 
)
static

Definition at line 928 of file xmltok.cc.

929 {
930  for (;;) {
931  char c1 = *s1++;
932  char c2 = *s2++;
933  if (ASCII_a <= c1 && c1 <= ASCII_z)
934  c1 += ASCII_A - ASCII_a;
935  if (ASCII_a <= c2 && c2 <= ASCII_z)
936  c2 += ASCII_A - ASCII_a;
937  if (c1 != c2)
938  return 0;
939  if (!c1)
940  break;
941  }
942  return 1;
943 }
#define ASCII_z
Definition: ascii.h:57
#define ASCII_A
Definition: ascii.h:5
#define ASCII_a
Definition: ascii.h:32

Here is the caller graph for this function:

static int toAscii ( const ENCODING enc,
const char *  ptr,
const char *  end 
)
static

Definition at line 953 of file xmltok.cc.

954 {
955  char buf[1];
956  char *p = buf;
957  XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
958  if (p == buf)
959  return -1;
960  else
961  return buf[0];
962 }
const char * p
Definition: xmltok.h:285
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim)
Definition: xmltok.h:255

Here is the caller graph for this function:

static int PTRFASTCALL unicode_byte_type ( char  hi,
char  lo 
)
static

Definition at line 525 of file xmltok.cc.

526 {
527  switch ((unsigned char)hi) {
528  case 0xD8: case 0xD9: case 0xDA: case 0xDB:
529  return BT_LEAD4;
530  case 0xDC: case 0xDD: case 0xDE: case 0xDF:
531  return BT_TRAIL;
532  case 0xFF:
533  switch ((unsigned char)lo) {
534  case 0xFF:
535  case 0xFE:
536  return BT_NONXML;
537  }
538  break;
539  }
540  return BT_NONASCII;
541 }
BT_LEAD4
Definition: utf8tab.h:6
BT_NONXML
Definition: asciitab.h:5
BT_TRAIL
Definition: utf8tab.h:6
static int PTRFASTCALL unknown_isInvalid ( const ENCODING enc,
const char *  p 
)
static

Definition at line 1289 of file xmltok.cc.

1290 {
1291  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1292  int c = uenc->convert(uenc->userData, p);
1293  return (c & ~0xFFFF) || checkCharRefNumber(c) < 0;
1294 }
CONVERTER convert
Definition: xmltok.cc:1254
const char * p
Definition: xmltok.h:285
#define AS_UNKNOWN_ENCODING(enc)
Definition: xmltok.cc:1260
static int FASTCALL checkCharRefNumber(int)
Definition: xmltok.cc:1179
void * userData
Definition: xmltok.cc:1255

Here is the call graph for this function:

Here is the caller graph for this function:

static int PTRFASTCALL unknown_isName ( const ENCODING enc,
const char *  p 
)
static

Definition at line 1269 of file xmltok.cc.

1270 {
1271  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1272  int c = uenc->convert(uenc->userData, p);
1273  if (c & ~0xFFFF)
1274  return 0;
1275  return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF);
1276 }
CONVERTER convert
Definition: xmltok.cc:1254
const char * p
Definition: xmltok.h:285
static const unsigned char namePages[]
Definition: nametab.h:117
#define UCS2_GET_NAMING(pages, hi, lo)
Definition: xmltok.cc:53
#define AS_UNKNOWN_ENCODING(enc)
Definition: xmltok.cc:1260
void * userData
Definition: xmltok.cc:1255

Here is the caller graph for this function:

static int PTRFASTCALL unknown_isNmstrt ( const ENCODING enc,
const char *  p 
)
static

Definition at line 1279 of file xmltok.cc.

1280 {
1281  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1282  int c = uenc->convert(uenc->userData, p);
1283  if (c & ~0xFFFF)
1284  return 0;
1285  return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF);
1286 }
CONVERTER convert
Definition: xmltok.cc:1254
const char * p
Definition: xmltok.h:285
#define UCS2_GET_NAMING(pages, hi, lo)
Definition: xmltok.cc:53
#define AS_UNKNOWN_ENCODING(enc)
Definition: xmltok.cc:1260
void * userData
Definition: xmltok.cc:1255
static const unsigned char nmstrtPages[]
Definition: nametab.h:83

Here is the caller graph for this function:

static void PTRCALL unknown_toUtf16 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
unsigned short **  toP,
const unsigned short *  toLim 
)
static

Definition at line 1331 of file xmltok.cc.

1334 {
1335  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1336  while (*fromP != fromLim && *toP != toLim) {
1337  unsigned short c = uenc->utf16[(unsigned char)**fromP];
1338  if (c == 0) {
1339  c = (unsigned short)
1340  uenc->convert(uenc->userData, *fromP);
1341  *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP]
1342  - (BT_LEAD2 - 2));
1343  }
1344  else
1345  (*fromP)++;
1346  *(*toP)++ = c;
1347  }
1348 }
#define AS_NORMAL_ENCODING(enc)
Definition: xmltok.cc:202
CONVERTER convert
Definition: xmltok.cc:1254
BT_LEAD2
Definition: utf8tab.h:6
#define AS_UNKNOWN_ENCODING(enc)
Definition: xmltok.cc:1260
void * userData
Definition: xmltok.cc:1255
unsigned short utf16[256]
Definition: xmltok.cc:1256

Here is the caller graph for this function:

static void PTRCALL unknown_toUtf8 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
char **  toP,
const char *  toLim 
)
static

Definition at line 1297 of file xmltok.cc.

1300 {
1301  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1302  char buf[XML_UTF8_ENCODE_MAX];
1303  for (;;) {
1304  const char *utf8;
1305  int n;
1306  if (*fromP == fromLim)
1307  break;
1308  utf8 = uenc->utf8[(unsigned char)**fromP];
1309  n = *utf8++;
1310  if (n == 0) {
1311  int c = uenc->convert(uenc->userData, *fromP);
1312  n = XmlUtf8Encode(c, buf);
1313  if (n > toLim - *toP)
1314  break;
1315  utf8 = buf;
1316  *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP]
1317  - (BT_LEAD2 - 2));
1318  }
1319  else {
1320  if (n > toLim - *toP)
1321  break;
1322  (*fromP)++;
1323  }
1324  do {
1325  *(*toP)++ = *utf8++;
1326  } while (--n != 0);
1327  }
1328 }
#define AS_NORMAL_ENCODING(enc)
Definition: xmltok.cc:202
CONVERTER convert
Definition: xmltok.cc:1254
BT_LEAD2
Definition: utf8tab.h:6
#define AS_UNKNOWN_ENCODING(enc)
Definition: xmltok.cc:1260
#define XML_UTF8_ENCODE_MAX
Definition: xmltok.h:108
int FASTCALL XmlUtf8Encode(int c, char *buf)
Definition: xmltok.cc:1198
void * userData
Definition: xmltok.cc:1255
char utf8[256][4]
Definition: xmltok.cc:1257

Here is the call graph for this function:

Here is the caller graph for this function:

static int PTRFASTCALL utf8_isInvalid2 ( const ENCODING enc,
const char *  p 
)
static

Definition at line 164 of file xmltok.cc.

165 {
166  return UTF8_INVALID2((const unsigned char *)p);
167 }
#define UTF8_INVALID2(p)
Definition: xmltok.cc:96
const char * p
Definition: xmltok.h:285
static int PTRFASTCALL utf8_isInvalid3 ( const ENCODING enc,
const char *  p 
)
static

Definition at line 170 of file xmltok.cc.

171 {
172  return UTF8_INVALID3((const unsigned char *)p);
173 }
const char * p
Definition: xmltok.h:285
#define UTF8_INVALID3(p)
Definition: xmltok.cc:99
static int PTRFASTCALL utf8_isInvalid4 ( const ENCODING enc,
const char *  p 
)
static

Definition at line 176 of file xmltok.cc.

177 {
178  return UTF8_INVALID4((const unsigned char *)p);
179 }
const char * p
Definition: xmltok.h:285
#define UTF8_INVALID4(p)
Definition: xmltok.cc:116
static int PTRFASTCALL utf8_isName2 ( const ENCODING enc,
const char *  p 
)
static

Definition at line 136 of file xmltok.cc.

137 {
138  return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
139 }
const char * p
Definition: xmltok.h:285
static const unsigned char namePages[]
Definition: nametab.h:117
#define UTF8_GET_NAMING2(pages, byte)
Definition: xmltok.cc:60
static int PTRFASTCALL utf8_isName3 ( const ENCODING enc,
const char *  p 
)
static

Definition at line 142 of file xmltok.cc.

143 {
144  return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
145 }
const char * p
Definition: xmltok.h:285
static const unsigned char namePages[]
Definition: nametab.h:117
#define UTF8_GET_NAMING3(pages, byte)
Definition: xmltok.cc:71
static int PTRFASTCALL utf8_isNmstrt2 ( const ENCODING enc,
const char *  p 
)
static

Definition at line 150 of file xmltok.cc.

151 {
152  return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
153 }
const char * p
Definition: xmltok.h:285
#define UTF8_GET_NAMING2(pages, byte)
Definition: xmltok.cc:60
static const unsigned char nmstrtPages[]
Definition: nametab.h:83
static int PTRFASTCALL utf8_isNmstrt3 ( const ENCODING enc,
const char *  p 
)
static

Definition at line 156 of file xmltok.cc.

157 {
158  return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
159 }
const char * p
Definition: xmltok.h:285
#define UTF8_GET_NAMING3(pages, byte)
Definition: xmltok.cc:71
static const unsigned char nmstrtPages[]
Definition: nametab.h:83
static void PTRCALL utf8_toUtf16 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
unsigned short **  toP,
const unsigned short *  toLim 
)
static

Definition at line 346 of file xmltok.cc.

349 {
350  unsigned short *to = *toP;
351  const char *from = *fromP;
352  while (from != fromLim && to != toLim) {
353  switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) {
354  case BT_LEAD2:
355  *to++ = (unsigned short)(((from[0] & 0x1f) << 6) | (from[1] & 0x3f));
356  from += 2;
357  break;
358  case BT_LEAD3:
359  *to++ = (unsigned short)(((from[0] & 0xf) << 12)
360  | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f));
361  from += 3;
362  break;
363  case BT_LEAD4:
364  {
365  unsigned long n;
366  if (to + 1 == toLim)
367  goto after;
368  n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12)
369  | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f);
370  n -= 0x10000;
371  to[0] = (unsigned short)((n >> 10) | 0xD800);
372  to[1] = (unsigned short)((n & 0x3FF) | 0xDC00);
373  to += 2;
374  from += 4;
375  }
376  break;
377  default:
378  *to++ = *from++;
379  break;
380  }
381  }
382 after:
383  *fromP = from;
384  *toP = to;
385 }
BT_LEAD4
Definition: utf8tab.h:6
BT_LEAD2
Definition: utf8tab.h:6
BT_LEAD3
Definition: utf8tab.h:6
static void PTRCALL utf8_toUtf8 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
char **  toP,
const char *  toLim 
)
static

Definition at line 327 of file xmltok.cc.

330 {
331  char *to;
332  const char *from;
333  if (fromLim - *fromP > toLim - *toP) {
334  /* Avoid copying partial characters. */
335  for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
336  if (((unsigned char)fromLim[-1] & 0xc0) != 0x80)
337  break;
338  }
339  for (to = *toP, from = *fromP; from != fromLim; from++, to++)
340  *to = *from;
341  *fromP = from;
342  *toP = to;
343 }
ENCODING* XmlInitUnknownEncoding ( void mem,
int table,
CONVERTER  convert,
void userData 
)

Definition at line 1351 of file xmltok.cc.

1355 {
1356  int i;
1357  struct unknown_encoding *e = (struct unknown_encoding *)mem;
1358  for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
1359  ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
1360  for (i = 0; i < 128; i++)
1361  if (latin1_encoding.type[i] != BT_OTHER
1362  && latin1_encoding.type[i] != BT_NONXML
1363  && table[i] != i)
1364  return 0;
1365  for (i = 0; i < 256; i++) {
1366  int c = table[i];
1367  if (c == -1) {
1368  e->normal.type[i] = BT_MALFORM;
1369  /* This shouldn't really get used. */
1370  e->utf16[i] = 0xFFFF;
1371  e->utf8[i][0] = 1;
1372  e->utf8[i][1] = 0;
1373  }
1374  else if (c < 0) {
1375  if (c < -4)
1376  return 0;
1377  e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2));
1378  e->utf8[i][0] = 0;
1379  e->utf16[i] = 0;
1380  }
1381  else if (c < 0x80) {
1382  if (latin1_encoding.type[c] != BT_OTHER
1383  && latin1_encoding.type[c] != BT_NONXML
1384  && c != i)
1385  return 0;
1386  e->normal.type[i] = latin1_encoding.type[c];
1387  e->utf8[i][0] = 1;
1388  e->utf8[i][1] = (char)c;
1389  e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c);
1390  }
1391  else if (checkCharRefNumber(c) < 0) {
1392  e->normal.type[i] = BT_NONXML;
1393  /* This shouldn't really get used. */
1394  e->utf16[i] = 0xFFFF;
1395  e->utf8[i][0] = 1;
1396  e->utf8[i][1] = 0;
1397  }
1398  else {
1399  if (c > 0xFFFF)
1400  return 0;
1401  if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
1402  e->normal.type[i] = BT_NMSTRT;
1403  else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
1404  e->normal.type[i] = BT_NAME;
1405  else
1406  e->normal.type[i] = BT_OTHER;
1407  e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
1408  e->utf16[i] = (unsigned short)c;
1409  }
1410  }
1411  e->userData = userData;
1412  e->convert = convert;
1413  if (convert) {
1414  e->normal.isName2 = unknown_isName;
1415  e->normal.isName3 = unknown_isName;
1416  e->normal.isName4 = unknown_isName;
1417  e->normal.isNmstrt2 = unknown_isNmstrt;
1418  e->normal.isNmstrt3 = unknown_isNmstrt;
1419  e->normal.isNmstrt4 = unknown_isNmstrt;
1420  e->normal.isInvalid2 = unknown_isInvalid;
1421  e->normal.isInvalid3 = unknown_isInvalid;
1422  e->normal.isInvalid4 = unknown_isInvalid;
1423  }
1424  e->normal.enc.utf8Convert = unknown_toUtf8;
1425  e->normal.enc.utf16Convert = unknown_toUtf16;
1426  return &(e->normal.enc);
1427 }
CONVERTER convert
Definition: xmltok.cc:1254
BT_LEAD2
Definition: utf8tab.h:6
BT_NMSTRT
Definition: asciitab.h:5
if(nIso!=0)
static int PTRFASTCALL unknown_isName(const ENCODING *enc, const char *p)
Definition: xmltok.cc:1269
static const unsigned char namePages[]
Definition: nametab.h:117
#define UCS2_GET_NAMING(pages, hi, lo)
Definition: xmltok.cc:53
static int PTRFASTCALL unknown_isInvalid(const ENCODING *enc, const char *p)
Definition: xmltok.cc:1289
BT_MALFORM
Definition: utf8tab.h:6
static int FASTCALL checkCharRefNumber(int)
Definition: xmltok.cc:1179
#define userData
Definition: xmlparse.cc:572
BT_OTHER
Definition: asciitab.h:5
int FASTCALL XmlUtf8Encode(int c, char *buf)
Definition: xmltok.cc:1198
static void PTRCALL unknown_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
Definition: xmltok.cc:1297
static int PTRFASTCALL unknown_isNmstrt(const ENCODING *enc, const char *p)
Definition: xmltok.cc:1279
void * userData
Definition: xmltok.cc:1255
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
char utf8[256][4]
Definition: xmltok.cc:1257
ENCODING enc
Definition: xmltok.cc:182
BT_NONXML
Definition: asciitab.h:5
struct normal_encoding normal
Definition: xmltok.cc:1253
static struct normal_encoding latin1_encoding
Definition: xmltok.cc:480
unsigned short utf16[256]
Definition: xmltok.cc:1256
unsigned char type[256]
Definition: xmltok.cc:183
static const unsigned char nmstrtPages[]
Definition: nametab.h:83
static void PTRCALL unknown_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
Definition: xmltok.cc:1331
BT_NAME
Definition: asciitab.h:5

Here is the call graph for this function:

Here is the caller graph for this function:

int XmlSizeOfUnknownEncoding ( void  )

Definition at line 1263 of file xmltok.cc.

1264 {
1265  return sizeof(struct unknown_encoding);
1266 }

Here is the caller graph for this function:

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

Definition at line 1235 of file xmltok.cc.

1236 {
1237  if (charNum < 0)
1238  return 0;
1239  if (charNum < 0x10000) {
1240  buf[0] = (unsigned short)charNum;
1241  return 1;
1242  }
1243  if (charNum < 0x110000) {
1244  charNum -= 0x10000;
1245  buf[0] = (unsigned short)((charNum >> 10) + 0xD800);
1246  buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00);
1247  return 2;
1248  }
1249  return 0;
1250 }
int FASTCALL XmlUtf8Encode ( int  c,
char *  buf 
)

Definition at line 1198 of file xmltok.cc.

1199 {
1200  enum {
1201  /* minN is minimum legal resulting value for N byte sequence */
1202  min2 = 0x80,
1203  min3 = 0x800,
1204  min4 = 0x10000
1205  };
1206 
1207  if (c < 0)
1208  return 0;
1209  if (c < min2) {
1210  buf[0] = (char)(c | UTF8_cval1);
1211  return 1;
1212  }
1213  if (c < min3) {
1214  buf[0] = (char)((c >> 6) | UTF8_cval2);
1215  buf[1] = (char)((c & 0x3f) | 0x80);
1216  return 2;
1217  }
1218  if (c < min4) {
1219  buf[0] = (char)((c >> 12) | UTF8_cval3);
1220  buf[1] = (char)(((c >> 6) & 0x3f) | 0x80);
1221  buf[2] = (char)((c & 0x3f) | 0x80);
1222  return 3;
1223  }
1224  if (c < 0x110000) {
1225  buf[0] = (char)((c >> 18) | UTF8_cval4);
1226  buf[1] = (char)(((c >> 12) & 0x3f) | 0x80);
1227  buf[2] = (char)(((c >> 6) & 0x3f) | 0x80);
1228  buf[3] = (char)((c & 0x3f) | 0x80);
1229  return 4;
1230  }
1231  return 0;
1232 }
static int min3(int a, int b, int c)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct normal_encoding ascii_encoding
static

Definition at line 513 of file xmltok.cc.

struct normal_encoding big2_encoding
static

Definition at line 880 of file xmltok.cc.

struct normal_encoding internal_big2_encoding
static

Definition at line 912 of file xmltok.cc.

struct normal_encoding internal_little2_encoding
static

Definition at line 771 of file xmltok.cc.

struct normal_encoding internal_utf8_encoding
static

Definition at line 422 of file xmltok.cc.

const char KW_encoding[]
static
Initial value:
= {
}
#define ASCII_n
Definition: ascii.h:45
#define ASCII_e
Definition: ascii.h:36
#define ASCII_g
Definition: ascii.h:38
#define ASCII_o
Definition: ascii.h:46
#define ASCII_i
Definition: ascii.h:40
#define ASCII_c
Definition: ascii.h:34
#define ASCII_d
Definition: ascii.h:35

Definition at line 1069 of file xmltok.cc.

const char KW_ISO_8859_1[]
static
Initial value:
= {
}
#define ASCII_S
Definition: ascii.h:23
#define ASCII_MINUS
Definition: ascii.h:76
#define ASCII_O
Definition: ascii.h:19
#define ASCII_9
Definition: ascii.h:68
#define ASCII_1
Definition: ascii.h:60
#define ASCII_5
Definition: ascii.h:64
#define ASCII_I
Definition: ascii.h:13
#define ASCII_8
Definition: ascii.h:67

Definition at line 1443 of file xmltok.cc.

const char KW_no[]
static
Initial value:
= {
}
#define ASCII_n
Definition: ascii.h:45
#define ASCII_o
Definition: ascii.h:46

Definition at line 1082 of file xmltok.cc.

const char KW_standalone[]
static
Initial value:
= {
}
#define ASCII_n
Definition: ascii.h:45
#define ASCII_e
Definition: ascii.h:36
#define ASCII_l
Definition: ascii.h:43
#define ASCII_s
Definition: ascii.h:50
#define ASCII_o
Definition: ascii.h:46
#define ASCII_t
Definition: ascii.h:51
#define ASCII_a
Definition: ascii.h:32
#define ASCII_d
Definition: ascii.h:35

Definition at line 1073 of file xmltok.cc.

const char KW_US_ASCII[]
static
Initial value:
= {
'\0'
}
#define ASCII_S
Definition: ascii.h:23
#define ASCII_U
Definition: ascii.h:25
#define ASCII_MINUS
Definition: ascii.h:76
#define ASCII_C
Definition: ascii.h:7
#define ASCII_A
Definition: ascii.h:5
#define ASCII_I
Definition: ascii.h:13

Definition at line 1447 of file xmltok.cc.

const char KW_UTF_16[]
static
Initial value:
= {
}
#define ASCII_U
Definition: ascii.h:25
#define ASCII_6
Definition: ascii.h:65
#define ASCII_MINUS
Definition: ascii.h:76
#define ASCII_1
Definition: ascii.h:60
#define ASCII_F
Definition: ascii.h:10
#define ASCII_T
Definition: ascii.h:24

Definition at line 1454 of file xmltok.cc.

const char KW_UTF_16BE[]
static
Initial value:
= {
'\0'
}
#define ASCII_U
Definition: ascii.h:25
#define ASCII_6
Definition: ascii.h:65
#define ASCII_MINUS
Definition: ascii.h:76
#define ASCII_B
Definition: ascii.h:6
#define ASCII_1
Definition: ascii.h:60
#define ASCII_F
Definition: ascii.h:10
#define ASCII_E
Definition: ascii.h:9
#define ASCII_T
Definition: ascii.h:24

Definition at line 1457 of file xmltok.cc.

const char KW_UTF_16LE[]
static
Initial value:
= {
'\0'
}
#define ASCII_U
Definition: ascii.h:25
#define ASCII_6
Definition: ascii.h:65
#define ASCII_MINUS
Definition: ascii.h:76
#define ASCII_L
Definition: ascii.h:16
#define ASCII_1
Definition: ascii.h:60
#define ASCII_F
Definition: ascii.h:10
#define ASCII_E
Definition: ascii.h:9
#define ASCII_T
Definition: ascii.h:24

Definition at line 1461 of file xmltok.cc.

const char KW_UTF_8[]
static
Initial value:
= {
}
#define ASCII_U
Definition: ascii.h:25
#define ASCII_MINUS
Definition: ascii.h:76
#define ASCII_8
Definition: ascii.h:67
#define ASCII_F
Definition: ascii.h:10
#define ASCII_T
Definition: ascii.h:24

Definition at line 1451 of file xmltok.cc.

const char KW_version[]
static
Initial value:
= {
}
#define ASCII_n
Definition: ascii.h:45
#define ASCII_e
Definition: ascii.h:36
#define ASCII_v
Definition: ascii.h:53
#define ASCII_s
Definition: ascii.h:50
#define ASCII_r
Definition: ascii.h:49
#define ASCII_o
Definition: ascii.h:46
#define ASCII_i
Definition: ascii.h:40

Definition at line 1065 of file xmltok.cc.

const char KW_yes[]
static
Initial value:
= {
}
#define ASCII_e
Definition: ascii.h:36
#define ASCII_s
Definition: ascii.h:50
#define ASCII_y
Definition: ascii.h:56

Definition at line 1078 of file xmltok.cc.

struct normal_encoding latin1_encoding
static

Definition at line 480 of file xmltok.cc.

struct normal_encoding little2_encoding
static

Definition at line 739 of file xmltok.cc.

struct normal_encoding utf8_encoding
static

Definition at line 398 of file xmltok.cc.