Kaydet (Commit) fc03a94a authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Incorporate Expat 1.95.6.

üst 5a772d32
/* /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd See the file COPYING for copying permission.
See the file COPYING for copying permission.
*/ */
#define ASCII_A 0x41 #define ASCII_A 0x41
...@@ -69,7 +68,7 @@ See the file COPYING for copying permission. ...@@ -69,7 +68,7 @@ See the file COPYING for copying permission.
#define ASCII_9 0x39 #define ASCII_9 0x39
#define ASCII_TAB 0x09 #define ASCII_TAB 0x09
#define ASCII_SPACE 0x20 #define ASCII_SPACE 0x20
#define ASCII_EXCL 0x21 #define ASCII_EXCL 0x21
#define ASCII_QUOT 0x22 #define ASCII_QUOT 0x22
#define ASCII_AMP 0x26 #define ASCII_AMP 0x26
......
This diff is collapsed.
/* internal.h
Internal definitions used by Expat. This is not needed to compile
client code.
The following calling convention macros are defined for frequently
called functions:
FASTCALL - Used for those internal functions that have a simple
body and a low number of arguments and local variables.
PTRCALL - Used for functions called though function pointers.
PTRFASTCALL - Like PTRCALL, but for low number of arguments.
inline - Used for selected internal functions for which inlining
may improve performance on some platforms.
Note: Use of these macros is based on judgement, not hard rules,
and therefore subject to change.
*/
#if defined(__GNUC__)
/* Instability reported with egcs on a RedHat Linux 7.3.
Let's comment it out:
#define FASTCALL __attribute__((stdcall, regparm(3)))
and let's try this:
*/
#define FASTCALL __attribute__((regparm(3)))
#define PTRCALL
#define PTRFASTCALL __attribute__((regparm(3)))
#elif defined(WIN32)
/* Using __fastcall seems to have an unexpected negative effect under
MS VC++, especially for function pointers, so we won't use it for
now on that platform. It may be reconsidered for a future release
if it can be made more effective.
Likely reason: __fastcall on Windows is like stdcall, therefore
the compiler cannot perform stack optimizations for call clusters.
*/
#define FASTCALL
#define PTRCALL
#define PTRFASTCALL
#endif
#ifndef FASTCALL
#define FASTCALL
#endif
#ifndef PTRCALL
#define PTRCALL
#endif
#ifndef PTRFASTCALL
#define PTRFASTCALL
#endif
#ifndef XML_MIN_SIZE
#if !defined(__cplusplus) && !defined(inline)
#ifdef __GNUC__
#define inline __inline
#endif /* __GNUC__ */
#endif
#endif /* XML_MIN_SIZE */
#ifdef __cplusplus
#define inline inline
#else
#ifndef inline
#define inline
#endif
#endif
This diff is collapsed.
This diff is collapsed.
/* /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd See the file COPYING for copying permission.
See the file COPYING for copying permission.
*/ */
#ifndef XmlRole_INCLUDED #ifndef XmlRole_INCLUDED
#define XmlRole_INCLUDED 1 #define XmlRole_INCLUDED 1
#ifdef __VMS
/* 0 1 2 3 0 1 2 3
1234567890123456789012345678901 1234567890123456789012345678901 */
#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
#endif
#include "xmltok.h" #include "xmltok.h"
#ifdef __cplusplus #ifdef __cplusplus
...@@ -17,6 +22,7 @@ enum { ...@@ -17,6 +22,7 @@ enum {
XML_ROLE_NONE = 0, XML_ROLE_NONE = 0,
XML_ROLE_XML_DECL, XML_ROLE_XML_DECL,
XML_ROLE_INSTANCE_START, XML_ROLE_INSTANCE_START,
XML_ROLE_DOCTYPE_NONE,
XML_ROLE_DOCTYPE_NAME, XML_ROLE_DOCTYPE_NAME,
XML_ROLE_DOCTYPE_SYSTEM_ID, XML_ROLE_DOCTYPE_SYSTEM_ID,
XML_ROLE_DOCTYPE_PUBLIC_ID, XML_ROLE_DOCTYPE_PUBLIC_ID,
...@@ -24,11 +30,13 @@ enum { ...@@ -24,11 +30,13 @@ enum {
XML_ROLE_DOCTYPE_CLOSE, XML_ROLE_DOCTYPE_CLOSE,
XML_ROLE_GENERAL_ENTITY_NAME, XML_ROLE_GENERAL_ENTITY_NAME,
XML_ROLE_PARAM_ENTITY_NAME, XML_ROLE_PARAM_ENTITY_NAME,
XML_ROLE_ENTITY_NONE,
XML_ROLE_ENTITY_VALUE, XML_ROLE_ENTITY_VALUE,
XML_ROLE_ENTITY_SYSTEM_ID, XML_ROLE_ENTITY_SYSTEM_ID,
XML_ROLE_ENTITY_PUBLIC_ID, XML_ROLE_ENTITY_PUBLIC_ID,
XML_ROLE_ENTITY_COMPLETE, XML_ROLE_ENTITY_COMPLETE,
XML_ROLE_ENTITY_NOTATION_NAME, XML_ROLE_ENTITY_NOTATION_NAME,
XML_ROLE_NOTATION_NONE,
XML_ROLE_NOTATION_NAME, XML_ROLE_NOTATION_NAME,
XML_ROLE_NOTATION_SYSTEM_ID, XML_ROLE_NOTATION_SYSTEM_ID,
XML_ROLE_NOTATION_NO_SYSTEM_ID, XML_ROLE_NOTATION_NO_SYSTEM_ID,
...@@ -44,11 +52,13 @@ enum { ...@@ -44,11 +52,13 @@ enum {
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS, XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
XML_ROLE_ATTRIBUTE_ENUM_VALUE, XML_ROLE_ATTRIBUTE_ENUM_VALUE,
XML_ROLE_ATTRIBUTE_NOTATION_VALUE, XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
XML_ROLE_ATTLIST_NONE,
XML_ROLE_ATTLIST_ELEMENT_NAME, XML_ROLE_ATTLIST_ELEMENT_NAME,
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE, XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE, XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE, XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
XML_ROLE_FIXED_ATTRIBUTE_VALUE, XML_ROLE_FIXED_ATTRIBUTE_VALUE,
XML_ROLE_ELEMENT_NONE,
XML_ROLE_ELEMENT_NAME, XML_ROLE_ELEMENT_NAME,
XML_ROLE_CONTENT_ANY, XML_ROLE_CONTENT_ANY,
XML_ROLE_CONTENT_EMPTY, XML_ROLE_CONTENT_EMPTY,
...@@ -64,6 +74,8 @@ enum { ...@@ -64,6 +74,8 @@ enum {
XML_ROLE_CONTENT_ELEMENT_REP, XML_ROLE_CONTENT_ELEMENT_REP,
XML_ROLE_CONTENT_ELEMENT_OPT, XML_ROLE_CONTENT_ELEMENT_OPT,
XML_ROLE_CONTENT_ELEMENT_PLUS, XML_ROLE_CONTENT_ELEMENT_PLUS,
XML_ROLE_PI,
XML_ROLE_COMMENT,
#ifdef XML_DTD #ifdef XML_DTD
XML_ROLE_TEXT_DECL, XML_ROLE_TEXT_DECL,
XML_ROLE_IGNORE_SECT, XML_ROLE_IGNORE_SECT,
...@@ -73,15 +85,17 @@ enum { ...@@ -73,15 +85,17 @@ enum {
}; };
typedef struct prolog_state { typedef struct prolog_state {
int (*handler)(struct prolog_state *state, int (PTRCALL *handler) (struct prolog_state *state,
int tok, int tok,
const char *ptr, const char *ptr,
const char *end, const char *end,
const ENCODING *enc); const ENCODING *enc);
unsigned level; unsigned level;
int role_none;
#ifdef XML_DTD #ifdef XML_DTD
unsigned includeLevel; unsigned includeLevel;
int documentEntity; int documentEntity;
int inEntityValue;
#endif /* XML_DTD */ #endif /* XML_DTD */
} PROLOG_STATE; } PROLOG_STATE;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
const ENCODING *NS(XmlGetUtf8InternalEncoding)(void) const ENCODING *
NS(XmlGetUtf8InternalEncoding)(void)
{ {
return &ns(internal_utf8_encoding).enc; return &ns(internal_utf8_encoding).enc;
} }
const ENCODING *NS(XmlGetUtf16InternalEncoding)(void) const ENCODING *
NS(XmlGetUtf16InternalEncoding)(void)
{ {
#if XML_BYTE_ORDER == 12 #if BYTEORDER == 1234
return &ns(internal_little2_encoding).enc; return &ns(internal_little2_encoding).enc;
#elif XML_BYTE_ORDER == 21 #elif BYTEORDER == 4321
return &ns(internal_big2_encoding).enc; return &ns(internal_big2_encoding).enc;
#else #else
const short n = 1; const short n = 1;
return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc; return (*(const char *)&n
? &ns(internal_little2_encoding).enc
: &ns(internal_big2_encoding).enc);
#endif #endif
} }
static static const ENCODING *NS(encodings)[] = {
const ENCODING *NS(encodings)[] = {
&ns(latin1_encoding).enc, &ns(latin1_encoding).enc,
&ns(ascii_encoding).enc, &ns(ascii_encoding).enc,
&ns(utf8_encoding).enc, &ns(utf8_encoding).enc,
...@@ -26,21 +29,25 @@ const ENCODING *NS(encodings)[] = { ...@@ -26,21 +29,25 @@ const ENCODING *NS(encodings)[] = {
&ns(utf8_encoding).enc /* NO_ENC */ &ns(utf8_encoding).enc /* NO_ENC */
}; };
static static int PTRCALL
int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr)
{ {
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr); return initScan(NS(encodings), (const INIT_ENCODING *)enc,
XML_PROLOG_STATE, ptr, end, nextTokPtr);
} }
static static int PTRCALL
int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr)
{ {
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr); return initScan(NS(encodings), (const INIT_ENCODING *)enc,
XML_CONTENT_STATE, ptr, end, nextTokPtr);
} }
int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name) int
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
const char *name)
{ {
int i = getEncodingIndex(name); int i = getEncodingIndex(name);
if (i == UNKNOWN_ENC) if (i == UNKNOWN_ENC)
...@@ -54,8 +61,8 @@ int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *n ...@@ -54,8 +61,8 @@ int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *n
return 1; return 1;
} }
static static const ENCODING *
const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
{ {
#define ENCODING_MAX 128 #define ENCODING_MAX 128
char buf[ENCODING_MAX]; char buf[ENCODING_MAX];
...@@ -73,26 +80,27 @@ const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const cha ...@@ -73,26 +80,27 @@ const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const cha
return NS(encodings)[i]; return NS(encodings)[i];
} }
int NS(XmlParseXmlDecl)(int isGeneralTextEntity, int
const ENCODING *enc, NS(XmlParseXmlDecl)(int isGeneralTextEntity,
const char *ptr, const ENCODING *enc,
const char *end, const char *ptr,
const char **badPtr, const char *end,
const char **versionPtr, const char **badPtr,
const char **versionEndPtr, const char **versionPtr,
const char **encodingName, const char **versionEndPtr,
const ENCODING **encoding, const char **encodingName,
int *standalone) const ENCODING **encoding,
int *standalone)
{ {
return doParseXmlDecl(NS(findEncoding), return doParseXmlDecl(NS(findEncoding),
isGeneralTextEntity, isGeneralTextEntity,
enc, enc,
ptr, ptr,
end, end,
badPtr, badPtr,
versionPtr, versionPtr,
versionEndPtr, versionEndPtr,
encodingName, encodingName,
encoding, encoding,
standalone); standalone);
} }
...@@ -690,9 +690,9 @@ class PyBuildExt(build_ext): ...@@ -690,9 +690,9 @@ class PyBuildExt(build_ext):
# More information on Expat can be found at www.libexpat.org. # More information on Expat can be found at www.libexpat.org.
# #
if sys.byteorder == "little": if sys.byteorder == "little":
xmlbo = "12" xmlbo = "1234"
else: else:
xmlbo = "21" xmlbo = "4321"
expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat') expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')
exts.append(Extension('pyexpat', exts.append(Extension('pyexpat',
sources = [ sources = [
...@@ -702,10 +702,9 @@ class PyBuildExt(build_ext): ...@@ -702,10 +702,9 @@ class PyBuildExt(build_ext):
'expat/xmltok.c', 'expat/xmltok.c',
], ],
define_macros = [ define_macros = [
('HAVE_EXPAT_H',None),
('XML_NS', '1'), ('XML_NS', '1'),
('XML_DTD', '1'), ('XML_DTD', '1'),
('XML_BYTE_ORDER', xmlbo), ('BYTEORDER', xmlbo),
('XML_CONTEXT_BYTES','1024'), ('XML_CONTEXT_BYTES','1024'),
], ],
include_dirs = [expatinc] include_dirs = [expatinc]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment