Ignore:
Timestamp:
Aug 12, 2001, 5:34:51 PM (24 years ago)
Author:
umoeller
Message:

XML updates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/xmltok.c

    r75 r97  
    1 
    21/*
    3  *sourcefile xmltok.c
    4  *      part of the expat implementation. See xmlparse.c.
    5  *
     2 * Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
     3 * See the file COPYING for copying permission.
    64 */
    75
    8 /*
    9  *      Copyright (C) 2001 Ulrich M”ller.
    10  *      Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd.
    11  *                                     and Clark Cooper.
    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
    18  *      permit persons to whom the Software is furnished to do so, subject to
    19  *      the 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.
    27  *      IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    28  *      CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    29  *      TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    30  *      SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     6/* #ifdef COMPILED_FROM_DSP
     7 * #  include "winconfig.h"
     8 * #else
     9 * #  include <config.h>
     10 * #endif
    3111 */
    3212
    33 #include "setup.h"
    34 
    35 #include "expat\expat_setup.h"          // V0.9.9 (2001-02-10) [umoeller]
     13#include <memory.h>
     14
     15#include "expat\expat_setup.h"  // V0.9.9 (2001-02-10) [umoeller]
    3616
    3717#pragma info(norea, nogen)
     
    10585#define UTF8_INVALID4(p) ((*p) == 0xF4 && ((p)[1] & 0x30) != 0)
    10686
    107 static int EXPATENTRY isNever(const ENCODING * enc, const char *p)
     87static
     88int isNever(const ENCODING * enc, const char *p)
    10889{
    10990    return 0;
    11091}
    11192
    112 static int EXPATENTRY utf8_isName2(const ENCODING * enc, const char *p)
     93static
     94int utf8_isName2(const ENCODING * enc, const char *p)
    11395{
    11496    return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
    11597}
    11698
    117 static int EXPATENTRY utf8_isName3(const ENCODING * enc, const char *p)
     99static
     100int utf8_isName3(const ENCODING * enc, const char *p)
    118101{
    119102    return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
     
    122105#define utf8_isName4 isNever
    123106
    124 static int EXPATENTRY utf8_isNmstrt2(const ENCODING * enc, const char *p)
     107static
     108int utf8_isNmstrt2(const ENCODING * enc, const char *p)
    125109{
    126110    return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
    127111}
    128112
    129 static int EXPATENTRY utf8_isNmstrt3(const ENCODING * enc, const char *p)
     113static
     114int utf8_isNmstrt3(const ENCODING * enc, const char *p)
    130115{
    131116    return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
     
    136121#define utf8_isInvalid2 isNever
    137122
    138 static int EXPATENTRY utf8_isInvalid3(const ENCODING * enc, const char *p)
     123static
     124int utf8_isInvalid3(const ENCODING * enc, const char *p)
    139125{
    140126    return UTF8_INVALID3((const unsigned char *)p);
    141127}
    142128
    143 static int EXPATENTRY utf8_isInvalid4(const ENCODING * enc, const char *p)
     129static
     130int utf8_isInvalid4(const ENCODING * enc, const char *p)
    144131{
    145132    return UTF8_INVALID4((const unsigned char *)p);
     
    151138    unsigned char type[256];
    152139#ifdef XML_MIN_SIZE
    153     int (* EXPATENTRY byteType) (const ENCODING *, const char *);
    154     int (* EXPATENTRY isNameMin) (const ENCODING *, const char *);
    155     int (* EXPATENTRY isNmstrtMin) (const ENCODING *, const char *);
    156     int (* EXPATENTRY byteToAscii) (const ENCODING *, const char *);
    157     int (* EXPATENTRY charMatches) (const ENCODING *, const char *, int);
     140    int (*byteType) (const ENCODING *, const char *);
     141    int (*isNameMin) (const ENCODING *, const char *);
     142    int (*isNmstrtMin) (const ENCODING *, const char *);
     143    int (*byteToAscii) (const ENCODING *, const char *);
     144    int (*charMatches) (const ENCODING *, const char *, int);
    158145#endif                          /* XML_MIN_SIZE */
    159     int (* EXPATENTRY isName2) (const ENCODING *, const char *);
    160     int (* EXPATENTRY isName3) (const ENCODING *, const char *);
    161     int (* EXPATENTRY isName4) (const ENCODING *, const char *);
    162     int (* EXPATENTRY isNmstrt2) (const ENCODING *, const char *);
    163     int (* EXPATENTRY isNmstrt3) (const ENCODING *, const char *);
    164     int (* EXPATENTRY isNmstrt4) (const ENCODING *, const char *);
    165     int (* EXPATENTRY isInvalid2) (const ENCODING *, const char *);
    166     int (* EXPATENTRY isInvalid3) (const ENCODING *, const char *);
    167     int (* EXPATENTRY isInvalid4) (const ENCODING *, const char *);
     146    int (*isName2) (const ENCODING *, const char *);
     147    int (*isName3) (const ENCODING *, const char *);
     148    int (*isName4) (const ENCODING *, const char *);
     149    int (*isNmstrt2) (const ENCODING *, const char *);
     150    int (*isNmstrt3) (const ENCODING *, const char *);
     151    int (*isNmstrt4) (const ENCODING *, const char *);
     152    int (*isInvalid2) (const ENCODING *, const char *);
     153    int (*isInvalid3) (const ENCODING *, const char *);
     154    int (*isInvalid4) (const ENCODING *, const char *);
    168155};
    169156
     
    215202
    216203#ifdef XML_MIN_SIZE
    217 static int EXPATENTRY sb_byteType(const ENCODING * enc, const char *p)
     204static
     205int sb_byteType(const ENCODING * enc, const char *p)
    218206{
    219207    return SB_BYTE_TYPE(enc, p);
     
    228216#define BYTE_TO_ASCII(enc, p) \
    229217 (((const struct normal_encoding *)(enc))->byteToAscii(enc, p))
    230 static int EXPATENTRY sb_byteToAscii(const ENCODING * enc, const char *p)
     218static
     219int sb_byteToAscii(const ENCODING * enc, const char *p)
    231220{
    232221    return *p;
     
    256245#define CHAR_MATCHES(enc, p, c) \
    257246 (((const struct normal_encoding *)(enc))->charMatches(enc, p, c))
    258 static int EXPATENTRY sb_charMatches(const ENCODING * enc, const char *p, int c)
     247static
     248int sb_charMatches(const ENCODING * enc, const char *p, int c)
    259249{
    260250    return *p == c;
     
    286276};
    287277
    288 static void EXPATENTRY utf8_toUtf8(const ENCODING * enc,
    289                                  const char **fromP,
    290                                  const char *fromLim,
    291                                  char **toP,
    292                                  const char *toLim)
     278static void utf8_toUtf8(const ENCODING * enc,
     279                        const char **fromP,
     280                        const char *fromLim,
     281                        char **toP,
     282                        const char *toLim)
    293283{
    294284    char *to;
     
    298288    {
    299289        /* Avoid copying partial characters. */
    300         for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
     290        for (fromLim = *fromP + (toLim - *toP);
     291             fromLim > *fromP;
     292             fromLim--)
    301293            if (((unsigned char)fromLim[-1] & 0xc0) != 0x80)
    302294                break;
    303295    }
    304     for (to = *toP, from = *fromP; from != fromLim; from++, to++)
     296    for (to = *toP, from = *fromP;
     297         from != fromLim;
     298         from++, to++)
    305299        *to = *from;
    306300    *fromP = from;
     
    308302}
    309303
    310 static void EXPATENTRY utf8_toUtf16(const ENCODING * enc,
    311                   const char **fromP, const char *fromLim,
    312                   unsigned short **toP, const unsigned short *toLim)
     304static void utf8_toUtf16(const ENCODING * enc,
     305                         const char **fromP,
     306                         const char *fromLim,
     307                         unsigned short **toP,
     308                         const unsigned short *toLim)
    313309{
    314310    unsigned short *to = *toP;
     
    401397};
    402398
    403 static void EXPATENTRY latin1_toUtf8(const ENCODING * enc,
    404                    const char **fromP, const char *fromLim,
    405                    char **toP, const char *toLim)
     399static void latin1_toUtf8(const ENCODING * enc,
     400                          const char **fromP,
     401                          const char *fromLim,
     402                          char **toP,
     403                          const char *toLim)
    406404{
    407405    for (;;)
     
    429427}
    430428
    431 static void EXPATENTRY latin1_toUtf16(const ENCODING * enc,
    432                     const char **fromP, const char *fromLim,
    433                     unsigned short **toP, const unsigned short *toLim)
     429static void latin1_toUtf16(const ENCODING * enc,
     430                           const char **fromP,
     431                           const char *fromLim,
     432                           unsigned short **toP,
     433                           const unsigned short *toLim)
    434434{
    435435    while (*fromP != fromLim && *toP != toLim)
     
    463463};
    464464
    465 static void EXPATENTRY ascii_toUtf8(const ENCODING * enc,
    466                   const char **fromP, const char *fromLim,
    467                   char **toP, const char *toLim)
     465static void ascii_toUtf8(const ENCODING * enc,
     466                         const char **fromP,
     467                         const char *fromLim,
     468                         char **toP,
     469                         const char *toLim)
    468470{
    469471    while (*fromP != fromLim && *toP != toLim)
     
    524526
    525527#define DEFINE_UTF16_TO_UTF8(E) \
    526 static void EXPATENTRY E ## toUtf8(const ENCODING *enc, \
     528static \
     529void E ## toUtf8(const ENCODING *enc, \
    527530         const char **fromP, const char *fromLim, \
    528531         char **toP, const char *toLim) \
     
    586589
    587590#define DEFINE_UTF16_TO_UTF16(E) \
    588 static void EXPATENTRY E ## toUtf16(const ENCODING *enc, \
     591static \
     592void E ## toUtf16(const ENCODING *enc, \
    589593          const char **fromP, const char *fromLim, \
    590594          unsigned short **toP, const unsigned short *toLim) \
     
    635639#ifdef XML_MIN_SIZE
    636640
    637     static int EXPATENTRY little2_byteType(const ENCODING * enc, const char *p)
    638     {
    639         return LITTLE2_BYTE_TYPE(enc, p);
    640     }
    641 
    642     static int EXPATENTRY little2_byteToAscii(const ENCODING * enc, const char *p)
    643     {
    644         return LITTLE2_BYTE_TO_ASCII(enc, p);
    645     }
    646 
    647     static int EXPATENTRY little2_charMatches(const ENCODING * enc, const char *p, int c)
    648     {
    649         return LITTLE2_CHAR_MATCHES(enc, p, c);
    650     }
    651 
    652     static int EXPATENTRY little2_isNameMin(const ENCODING * enc, const char *p)
    653     {
    654         return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p);
    655     }
    656 
    657     static int EXPATENTRY little2_isNmstrtMin(const ENCODING * enc, const char *p)
    658     {
    659         return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p);
    660     }
    661 
    662     #undef VTABLE
    663     #define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
     641     static
     642     int little2_byteType(const ENCODING * enc, const char *p)
     643{
     644    return LITTLE2_BYTE_TYPE(enc, p);
     645}
     646
     647static int little2_byteToAscii(const ENCODING * enc, const char *p)
     648{
     649    return LITTLE2_BYTE_TO_ASCII(enc, p);
     650}
     651
     652static int little2_charMatches(const ENCODING * enc, const char *p, int c)
     653{
     654    return LITTLE2_CHAR_MATCHES(enc, p, c);
     655}
     656
     657static int little2_isNameMin(const ENCODING * enc, const char *p)
     658{
     659    return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p);
     660}
     661
     662static int little2_isNmstrtMin(const ENCODING * enc, const char *p)
     663{
     664    return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p);
     665}
     666
     667#undef VTABLE
     668#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
    664669
    665670#else /* not XML_MIN_SIZE */
    666671
    667     #undef PREFIX
    668     #define PREFIX(ident) little2_ ## ident
    669     #define MINBPC(enc) 2
    670     /* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
    671     #define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
    672     #define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p)
    673     #define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
    674     #define IS_NAME_CHAR(enc, p, n) 0
    675     #define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
    676     #define IS_NMSTRT_CHAR(enc, p, n) (0)
    677     #define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
    678 
    679     #include "xmltok_impl.c"
    680 
    681     #undef MINBPC
    682     #undef BYTE_TYPE
    683     #undef BYTE_TO_ASCII
    684     #undef CHAR_MATCHES
    685     #undef IS_NAME_CHAR
    686     #undef IS_NAME_CHAR_MINBPC
    687     #undef IS_NMSTRT_CHAR
    688     #undef IS_NMSTRT_CHAR_MINBPC
    689     #undef IS_INVALID_CHAR
     672#undef PREFIX
     673#define PREFIX(ident) little2_ ## ident
     674#define MINBPC(enc) 2
     675/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
     676#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
     677#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p)
     678#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
     679#define IS_NAME_CHAR(enc, p, n) 0
     680#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
     681#define IS_NMSTRT_CHAR(enc, p, n) (0)
     682#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
     683
     684#include "xmltok_impl.c"
     685
     686#undef MINBPC
     687#undef BYTE_TYPE
     688#undef BYTE_TO_ASCII
     689#undef CHAR_MATCHES
     690#undef IS_NAME_CHAR
     691#undef IS_NAME_CHAR_MINBPC
     692#undef IS_NMSTRT_CHAR
     693#undef IS_NMSTRT_CHAR_MINBPC
     694#undef IS_INVALID_CHAR
    690695
    691696#endif /* not XML_MIN_SIZE */
     
    693698#ifdef XML_NS
    694699
    695          static const struct normal_encoding little2_encoding_ns =
     700     static const struct normal_encoding little2_encoding_ns =
     701     {
     702         {VTABLE, 2, 0,
     703#if XML_BYTE_ORDER == 12
     704          1
     705#else
     706          0
     707#endif
     708         },
    696709         {
    697              {VTABLE, 2, 0,
    698     #if XML_BYTE_ORDER == 12
    699               1
    700     #else
    701               0
    702     #endif
    703              },
    704              {
    705     #include "expat\asciitab.h"
    706     #include "expat\latin1tab.h"
    707              },
    708              STANDARD_VTABLE(little2_)
    709     };
     710#include "expat\asciitab.h"
     711#include "expat\latin1tab.h"
     712         },
     713         STANDARD_VTABLE(little2_)
     714};
    710715
    711716#endif
     
    773778#ifdef XML_MIN_SIZE
    774779
    775     static int EXPATENTRY big2_byteType(const ENCODING * enc, const char *p)
    776     {
    777         return BIG2_BYTE_TYPE(enc, p);
    778     }
    779 
    780     static int EXPATENTRY big2_byteToAscii(const ENCODING * enc, const char *p)
    781     {
    782         return BIG2_BYTE_TO_ASCII(enc, p);
    783     }
    784 
    785     static int EXPATENTRY big2_charMatches(const ENCODING * enc, const char *p, int c)
    786     {
    787         return BIG2_CHAR_MATCHES(enc, p, c);
    788     }
    789 
    790     static int EXPATENTRY big2_isNameMin(const ENCODING * enc, const char *p)
    791     {
    792         return BIG2_IS_NAME_CHAR_MINBPC(enc, p);
    793     }
    794 
    795     static int EXPATENTRY big2_isNmstrtMin(const ENCODING * enc, const char *p)
    796     {
    797         return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p);
    798     }
    799 
    800     #undef VTABLE
    801     #define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
     780static int big2_byteType(const ENCODING * enc, const char *p)
     781{
     782    return BIG2_BYTE_TYPE(enc, p);
     783}
     784
     785static int big2_byteToAscii(const ENCODING * enc, const char *p)
     786{
     787    return BIG2_BYTE_TO_ASCII(enc, p);
     788}
     789
     790static int big2_charMatches(const ENCODING * enc, const char *p, int c)
     791{
     792    return BIG2_CHAR_MATCHES(enc, p, c);
     793}
     794
     795static int big2_isNameMin(const ENCODING * enc, const char *p)
     796{
     797    return BIG2_IS_NAME_CHAR_MINBPC(enc, p);
     798}
     799
     800static int big2_isNmstrtMin(const ENCODING * enc, const char *p)
     801{
     802    return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p);
     803}
     804
     805#undef VTABLE
     806#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
    802807
    803808#else /* not XML_MIN_SIZE */
    804809
    805     #undef PREFIX
    806     #define PREFIX(ident) big2_ ## ident
    807     #define MINBPC(enc) 2
    808     /* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
    809     #define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
    810     #define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p)
    811     #define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
    812     #define IS_NAME_CHAR(enc, p, n) 0
    813     #define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
    814     #define IS_NMSTRT_CHAR(enc, p, n) (0)
    815     #define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
    816 
    817     #include "xmltok_impl.c"
    818 
    819     #undef MINBPC
    820     #undef BYTE_TYPE
    821     #undef BYTE_TO_ASCII
    822     #undef CHAR_MATCHES
    823     #undef IS_NAME_CHAR
    824     #undef IS_NAME_CHAR_MINBPC
    825     #undef IS_NMSTRT_CHAR
    826     #undef IS_NMSTRT_CHAR_MINBPC
    827     #undef IS_INVALID_CHAR
     810#undef PREFIX
     811#define PREFIX(ident) big2_ ## ident
     812#define MINBPC(enc) 2
     813/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
     814#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
     815#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p)
     816#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
     817#define IS_NAME_CHAR(enc, p, n) 0
     818#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
     819#define IS_NMSTRT_CHAR(enc, p, n) (0)
     820#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
     821
     822#include "xmltok_impl.c"
     823
     824#undef MINBPC
     825#undef BYTE_TYPE
     826#undef BYTE_TO_ASCII
     827#undef CHAR_MATCHES
     828#undef IS_NAME_CHAR
     829#undef IS_NAME_CHAR_MINBPC
     830#undef IS_NMSTRT_CHAR
     831#undef IS_NMSTRT_CHAR_MINBPC
     832#undef IS_INVALID_CHAR
    828833
    829834#endif /* not XML_MIN_SIZE */
     
    899904#undef PREFIX
    900905
    901      static
    902      int streqci(const char *s1, const char *s2)
     906static int streqci(const char *s1, const char *s2)
    903907{
    904908    for (;;)
     
    919923}
    920924
    921 static void EXPATENTRY initUpdatePosition(const ENCODING * enc,
    922                                           const char *ptr,
    923                                           const char *end,
    924                                           POSITION * pos)
     925static void initUpdatePosition(const ENCODING * enc, const char *ptr,
     926                        const char *end, POSITION * pos)
    925927{
    926928    normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
    927929}
    928930
    929 static int EXPATENTRY toAscii(const ENCODING * enc, const char *ptr, const char *end)
     931static int toAscii(const ENCODING * enc, const char *ptr, const char *end)
    930932{
    931933    char buf[1];
     
    954956/* Return 1 if there's just optional white space
    955957 * or there's an S followed by name=val. */
    956 static int EXPATENTRY parsePseudoAttribute(const ENCODING * enc,
    957                                            const char *ptr,
    958                                            const char *end,
    959                                            const char **namePtr,
    960                                            const char **nameEndPtr,
    961                                            const char **valPtr,
    962                                            const char **nextTokPtr)
     958static int parsePseudoAttribute(const ENCODING * enc,
     959                                const char *ptr,
     960                                const char *end,
     961                                const char **namePtr,
     962                                const char **nameEndPtr,
     963                                const char **valPtr,
     964                                const char **nextTokPtr)
    963965{
    964966    int c;
     
    10811083};
    10821084
    1083 static int doParseXmlDecl(const ENCODING* (* EXPATENTRY encodingFinder)(const ENCODING *,
    1084                                                                       const char *,
    1085                                                                       const char *),
     1085static int doParseXmlDecl(const ENCODING * (*encodingFinder) (const ENCODING *,
     1086                                                              const char *,
     1087                                                              const char *),
    10861088                          int isGeneralTextEntity,
    10871089                          const ENCODING * enc,
     
    12811283};
    12821284
    1283 int EXPATENTRY XmlSizeOfUnknownEncoding(void)
     1285int XmlSizeOfUnknownEncoding(void)
    12841286{
    12851287    return sizeof(struct unknown_encoding);
    12861288}
    12871289
    1288 static int EXPATENTRY unknown_isName(const ENCODING * enc, const char *p)
     1290static int unknown_isName(const ENCODING * enc, const char *p)
    12891291{
    12901292    int c = ((const struct unknown_encoding *)enc)
     
    12961298}
    12971299
    1298 static int EXPATENTRY unknown_isNmstrt(const ENCODING * enc, const char *p)
     1300static int unknown_isNmstrt(const ENCODING * enc, const char *p)
    12991301{
    13001302    int c = ((const struct unknown_encoding *)enc)
     
    13061308}
    13071309
    1308 static int EXPATENTRY unknown_isInvalid(const ENCODING * enc, const char *p)
     1310static int unknown_isInvalid(const ENCODING * enc, const char *p)
    13091311{
    13101312    int c = ((const struct unknown_encoding *)enc)
     
    13141316}
    13151317
    1316 static void EXPATENTRY unknown_toUtf8(const ENCODING * enc,
    1317                                     const char **fromP,
    1318                                     const char *fromLim,
    1319                                     char **toP,
    1320                                     const char *toLim)
     1318static void unknown_toUtf8(const ENCODING * enc,
     1319                           const char **fromP,
     1320                           const char *fromLim,
     1321                           char **toP,
     1322                           const char *toLim)
    13211323{
    13221324    char buf[XML_UTF8_ENCODE_MAX];
     
    13571359}
    13581360
    1359 static void EXPATENTRY unknown_toUtf16(const ENCODING * enc,
    1360                                        const char **fromP,
    1361                                        const char *fromLim,
    1362                                        unsigned short **toP,
    1363                                        const unsigned short *toLim)
     1361static void unknown_toUtf16(const ENCODING * enc,
     1362                            const char **fromP,
     1363                            const char *fromLim,
     1364                            unsigned short **toP,
     1365                            const unsigned short *toLim)
    13641366{
    13651367    while (*fromP != fromLim && *toP != toLim)
     
    13811383}
    13821384
    1383 ENCODING * XmlInitUnknownEncoding(void *mem,
    1384                                   int *table,
    1385                                   int (*convert) (void *userData, const char *p),
    1386                                   void *userData)
     1385/*
     1386 *@@ XmlInitUnknownEncoding:
     1387 *
     1388 *@@changed V0.9.14 (2001-08-09) [umoeller]: couple of performance hacks
     1389 */
     1390
     1391ENCODING* XmlInitUnknownEncoding(void *mem,
     1392                                 int *table,
     1393                                 int (*convert) (void *userData, const char *p),
     1394                                 void *userData)
    13871395{
    13881396    int i;
    1389     struct unknown_encoding *e = (struct unknown_encoding *)mem;
    1390     for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
    1391 
    1392         ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
     1397    struct unknown_encoding *e = mem;
     1398
     1399    // gee, isn't this a regular memcpy?!?
     1400    /* for (i = 0;
     1401         i < (int)sizeof(struct normal_encoding);
     1402         i++)
     1403        ((char *)mem)[i] = ((char *)&latin1_encoding)[i]; */
     1404
     1405    // replaced the above with this V0.9.14 (2001-08-09) [umoeller]
     1406    memcpy(mem, &latin1_encoding, sizeof(struct normal_encoding));
     1407
    13931408    for (i = 0; i < 128; i++)
    1394         if (latin1_encoding.type[i] != BT_OTHER
    1395             && latin1_encoding.type[i] != BT_NONXML
    1396             && table[i] != i)
     1409        if (    latin1_encoding.type[i] != BT_OTHER
     1410             && latin1_encoding.type[i] != BT_NONXML
     1411             && table[i] != i
     1412           )
    13971413            return 0;
     1414
    13981415    for (i = 0; i < 256; i++)
    13991416    {
     
    14181435        else if (c < 0x80)
    14191436        {
    1420             if (latin1_encoding.type[c] != BT_OTHER
    1421                 && latin1_encoding.type[c] != BT_NONXML
    1422                 && c != i)
     1437            if (    latin1_encoding.type[c] != BT_OTHER
     1438                 && latin1_encoding.type[c] != BT_NONXML
     1439                 && c != i
     1440               )
    14231441                return 0;
    14241442            e->normal.type[i] = latin1_encoding.type[c];
     
    15231541    if (name == 0)
    15241542        return NO_ENC;
    1525     for (i = 0; i < (int)(sizeof(encodingNames) / sizeof(encodingNames[0])); i++)
     1543    for (i = 0;
     1544         i < (int)(sizeof(encodingNames) / sizeof(encodingNames[0]));
     1545         i++)
    15261546        if (streqci(name, encodingNames[i]))
    15271547            return i;
     
    15431563
    15441564
    1545 static int EXPATENTRY initScan(const ENCODING ** encodingTable,
    1546                                const INIT_ENCODING * enc,
    1547                                int state,
    1548                                const char *ptr,
    1549                                const char *end,
    1550                                const char **nextTokPtr)
     1565static int initScan(const ENCODING ** encodingTable,
     1566                    const INIT_ENCODING * enc,
     1567                    int state,
     1568                    const char *ptr,
     1569                    const char *end,
     1570                    const char **nextTokPtr)
    15511571{
    15521572    const ENCODING **encPtr;
     
    16301650                if ((unsigned char)ptr[2] == 0xBF)
    16311651                {
     1652                    *nextTokPtr = ptr + 3;
    16321653                    *encPtr = encodingTable[UTF_8_ENC];
    16331654                    return XML_TOK_BOM;
     
    16871708ENCODING * XmlInitUnknownEncodingNS(void *mem,
    16881709                                    int *table,
    1689                                     int (* EXPATENTRY convert) (void *userData, const char *p),
     1710                                    int (*convert) (void *userData, const char *p),
    16901711                                    void *userData)
    16911712{
Note: See TracChangeset for help on using the changeset viewer.