mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
ws fix.
This commit is contained in:
parent
a000bdd93e
commit
1ffbcc5ecf
1 changed files with 74 additions and 117 deletions
127
ext/xml/xml.c
127
ext/xml/xml.c
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#define IS_EXT_MODULE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -52,7 +53,6 @@
|
|||
* - Weird things happen with <![CDATA[]]> sections.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
int xml_globals_id;
|
||||
#else
|
||||
|
@ -60,14 +60,12 @@ PHP_XML_API php_xml_globals xml_globals;
|
|||
#endif
|
||||
|
||||
/* {{{ dynamically loadable module stuff */
|
||||
|
||||
#ifdef COMPILE_DL_XML
|
||||
ZEND_GET_MODULE(xml)
|
||||
#endif /* COMPILE_DL_XML */
|
||||
|
||||
/* }}} */
|
||||
/* {{{ function prototypes */
|
||||
|
||||
/* {{{ function prototypes */
|
||||
PHP_MINIT_FUNCTION(xml);
|
||||
PHP_RINIT_FUNCTION(xml);
|
||||
PHP_MSHUTDOWN_FUNCTION(xml);
|
||||
|
@ -99,8 +97,8 @@ int _xml_externalEntityRefHandler(XML_Parser, const XML_Char *, const XML_Char
|
|||
void _xml_startNamespaceDeclHandler(void *, const XML_Char *, const XML_Char *);
|
||||
void _xml_endNamespaceDeclHandler(void *, const XML_Char *);
|
||||
/* }}} */
|
||||
/* {{{ extension definition structures */
|
||||
|
||||
/* {{{ extension definition structures */
|
||||
static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };
|
||||
|
||||
function_entry xml_functions[] = {
|
||||
|
@ -156,9 +154,8 @@ xml_encoding xml_encodings[] = {
|
|||
static int le_xml_parser;
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ startup, shutdown and info functions */
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
static void php_xml_init_globals(php_xml_globals *xml_globals_p TSRMLS_DC)
|
||||
{
|
||||
|
@ -204,7 +201,6 @@ PHP_MINIT_FUNCTION(xml)
|
|||
REGISTER_LONG_CONSTANT("XML_OPTION_SKIP_TAGSTART", PHP_XML_OPTION_SKIP_TAGSTART, CONST_CS|CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("XML_OPTION_SKIP_WHITE", PHP_XML_OPTION_SKIP_WHITE, CONST_CS|CONST_PERSISTENT);
|
||||
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -238,7 +234,6 @@ PHP_MINFO_FUNCTION(xml)
|
|||
/* }}} */
|
||||
|
||||
/* {{{ extension-internal functions */
|
||||
|
||||
static zval *_xml_resource_zval(long value)
|
||||
{
|
||||
zval *ret;
|
||||
|
@ -282,13 +277,10 @@ static zval *_xml_xmlchar_zval(const XML_Char *s, int len, const XML_Char *encod
|
|||
ret->value.str.val = xml_utf8_decode(s, len, &ret->value.str.len, encoding);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ xml_parser_dtor() */
|
||||
|
||||
static void
|
||||
xml_parser_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
static void xml_parser_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
xml_parser *parser = (xml_parser *)rsrc->ptr;
|
||||
|
||||
|
@ -346,12 +338,10 @@ xml_parser_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
|||
|
||||
efree(parser);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ xml_set_handler() */
|
||||
|
||||
static void
|
||||
xml_set_handler(zval **handler, zval **data)
|
||||
/* {{{ xml_set_handler() */
|
||||
static void xml_set_handler(zval **handler, zval **data)
|
||||
{
|
||||
/* IS_ARRAY might indicate that we're using array($obj, 'method') syntax */
|
||||
if (Z_TYPE_PP(data) != IS_ARRAY) {
|
||||
|
@ -361,12 +351,10 @@ xml_set_handler(zval **handler, zval **data)
|
|||
zval_add_ref(data);
|
||||
*handler = *data;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ xml_call_handler() */
|
||||
|
||||
static zval *
|
||||
xml_call_handler(xml_parser *parser, zval *handler, int argc, zval **argv)
|
||||
/* {{{ xml_call_handler() */
|
||||
static zval *xml_call_handler(xml_parser *parser, zval *handler, int argc, zval **argv)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
|
@ -410,48 +398,38 @@ xml_call_handler(xml_parser *parser, zval *handler, int argc, zval **argv)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ xml_encode_iso_8859_1() */
|
||||
|
||||
inline static unsigned short
|
||||
xml_encode_iso_8859_1(unsigned char c)
|
||||
/* {{{ xml_encode_iso_8859_1() */
|
||||
inline static unsigned short xml_encode_iso_8859_1(unsigned char c)
|
||||
{
|
||||
return (unsigned short)c;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ xml_decode_iso_8859_1() */
|
||||
|
||||
inline static char
|
||||
xml_decode_iso_8859_1(unsigned short c)
|
||||
/* {{{ xml_decode_iso_8859_1() */
|
||||
inline static char xml_decode_iso_8859_1(unsigned short c)
|
||||
{
|
||||
return (char)(c > 0xff ? '?' : c);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ xml_encode_us_ascii() */
|
||||
|
||||
inline static unsigned short
|
||||
xml_encode_us_ascii(unsigned char c)
|
||||
/* {{{ xml_encode_us_ascii() */
|
||||
inline static unsigned short xml_encode_us_ascii(unsigned char c)
|
||||
{
|
||||
return (unsigned short)c;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ xml_decode_us_ascii() */
|
||||
|
||||
inline static char
|
||||
xml_decode_us_ascii(unsigned short c)
|
||||
/* {{{ xml_decode_us_ascii() */
|
||||
inline static char xml_decode_us_ascii(unsigned short c)
|
||||
{
|
||||
return (char)(c > 0x7f ? '?' : c);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ xml_get_encoding() */
|
||||
|
||||
static xml_encoding *
|
||||
xml_get_encoding(const XML_Char *name)
|
||||
/* {{{ xml_get_encoding() */
|
||||
static xml_encoding *xml_get_encoding(const XML_Char *name)
|
||||
{
|
||||
xml_encoding *enc = &xml_encodings[0];
|
||||
|
||||
|
@ -463,11 +441,10 @@ xml_get_encoding(const XML_Char *name)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ xml_utf8_encode */
|
||||
static XML_Char *
|
||||
xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char *encoding)
|
||||
static XML_Char *xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char *encoding)
|
||||
{
|
||||
int pos = len;
|
||||
char *newbuf;
|
||||
|
@ -518,9 +495,9 @@ xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char *encoding)
|
|||
return newbuf;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ xml_utf8_decode */
|
||||
PHPAPI char *
|
||||
xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_Char *encoding)
|
||||
PHPAPI char *xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_Char *encoding)
|
||||
{
|
||||
int pos = len;
|
||||
char *newbuf = emalloc(len + 1);
|
||||
|
@ -569,8 +546,8 @@ xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_Char *encodin
|
|||
return newbuf;
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ _xml_xmlcharlen() */
|
||||
|
||||
/* {{{ _xml_xmlcharlen() */
|
||||
static int _xml_xmlcharlen(const XML_Char *s)
|
||||
{
|
||||
int len = 0;
|
||||
|
@ -581,10 +558,9 @@ static int _xml_xmlcharlen(const XML_Char *s)
|
|||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_zval_strdup() */
|
||||
|
||||
/* {{{ _xml_zval_strdup() */
|
||||
PHPAPI char *_xml_zval_strdup(zval *val)
|
||||
{
|
||||
if (val->type == IS_STRING) {
|
||||
|
@ -595,8 +571,8 @@ PHPAPI char *_xml_zval_strdup(zval *val)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ _xml_add_to_info */
|
||||
static void _xml_add_to_info(xml_parser *parser,char *name)
|
||||
{
|
||||
|
@ -622,8 +598,8 @@ static void _xml_add_to_info(xml_parser *parser,char *name)
|
|||
parser->curtag++;
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ _xml_decode_tag() */
|
||||
|
||||
/* {{{ _xml_decode_tag() */
|
||||
static char *_xml_decode_tag(xml_parser *parser, const char *tag)
|
||||
{
|
||||
char *newstr;
|
||||
|
@ -637,10 +613,9 @@ static char *_xml_decode_tag(xml_parser *parser, const char *tag)
|
|||
|
||||
return newstr;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_startElementHandler() */
|
||||
|
||||
/* {{{ _xml_startElementHandler() */
|
||||
void _xml_startElementHandler(void *userData, const char *name, const char **attributes)
|
||||
{
|
||||
xml_parser *parser = (xml_parser *)userData;
|
||||
|
@ -724,10 +699,9 @@ void _xml_startElementHandler(void *userData, const char *name, const char **att
|
|||
efree(tag_name);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_endElementHandler() */
|
||||
|
||||
/* {{{ _xml_endElementHandler() */
|
||||
void _xml_endElementHandler(void *userData, const char *name)
|
||||
{
|
||||
xml_parser *parser = (xml_parser *)userData;
|
||||
|
@ -779,10 +753,9 @@ void _xml_endElementHandler(void *userData, const char *name)
|
|||
parser->level--;
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_characterDataHandler() */
|
||||
|
||||
/* {{{ _xml_characterDataHandler() */
|
||||
void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
xml_parser *parser = (xml_parser *)userData;
|
||||
|
@ -858,13 +831,10 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_processingInstructionHandler() */
|
||||
|
||||
void _xml_processingInstructionHandler(void *userData,
|
||||
const XML_Char *target,
|
||||
const XML_Char *data)
|
||||
/* {{{ _xml_processingInstructionHandler() */
|
||||
void _xml_processingInstructionHandler(void *userData, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
xml_parser *parser = (xml_parser *)userData;
|
||||
|
||||
|
@ -880,10 +850,9 @@ void _xml_processingInstructionHandler(void *userData,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_defaultHandler() */
|
||||
|
||||
/* {{{ _xml_defaultHandler() */
|
||||
void _xml_defaultHandler(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
xml_parser *parser = (xml_parser *)userData;
|
||||
|
@ -899,10 +868,9 @@ void _xml_defaultHandler(void *userData, const XML_Char *s, int len)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_unparsedEntityDeclHandler() */
|
||||
|
||||
/* {{{ _xml_unparsedEntityDeclHandler() */
|
||||
void _xml_unparsedEntityDeclHandler(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
|
@ -927,12 +895,10 @@ void _xml_unparsedEntityDeclHandler(void *userData,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_notationDeclHandler() */
|
||||
|
||||
void
|
||||
_xml_notationDeclHandler(void *userData,
|
||||
/* {{{ _xml_notationDeclHandler() */
|
||||
void _xml_notationDeclHandler(void *userData,
|
||||
const XML_Char *notationName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
|
@ -954,12 +920,10 @@ _xml_notationDeclHandler(void *userData,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_externalEntityRefHandler() */
|
||||
|
||||
int
|
||||
_xml_externalEntityRefHandler(XML_Parser parserPtr,
|
||||
/* {{{ _xml_externalEntityRefHandler() */
|
||||
int _xml_externalEntityRefHandler(XML_Parser parserPtr,
|
||||
const XML_Char *openEntityNames,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
|
@ -986,13 +950,10 @@ _xml_externalEntityRefHandler(XML_Parser parserPtr,
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_startNamespaceDeclHandler() */
|
||||
|
||||
void _xml_startNamespaceDeclHandler(void *userData,
|
||||
const XML_Char *prefix,
|
||||
const XML_Char *uri)
|
||||
/* {{{ _xml_startNamespaceDeclHandler() */
|
||||
void _xml_startNamespaceDeclHandler(void *userData,const XML_Char *prefix, const XML_Char *uri)
|
||||
{
|
||||
xml_parser *parser = (xml_parser *)userData;
|
||||
|
||||
|
@ -1008,12 +969,10 @@ void _xml_startNamespaceDeclHandler(void *userData,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ _xml_endNamespaceDeclHandler() */
|
||||
|
||||
void _xml_endNamespaceDeclHandler(void *userData,
|
||||
const XML_Char *prefix)
|
||||
/* {{{ _xml_endNamespaceDeclHandler() */
|
||||
void _xml_endNamespaceDeclHandler(void *userData, const XML_Char *prefix)
|
||||
{
|
||||
xml_parser *parser = (xml_parser *)userData;
|
||||
|
||||
|
@ -1028,9 +987,7 @@ void _xml_endNamespaceDeclHandler(void *userData,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* }}} */
|
||||
|
||||
/************************* EXTENSION FUNCTIONS *************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue