mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
attempt to work around what seemed a gcc optimizer bug when handling
* xpath.c: attempt to work around what seemed a gcc optimizer bug when handling floats on i386 http://veillard.com/gcc.bug * tree.c entities.c encoding.c: doing some cleanups while chasing it Daniel
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Fri Jun 22 00:04:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
|
* xpath.c: attempt to work around what seemed a gcc optimizer
|
||||||
|
bug when handling floats on i386 http://veillard.com/gcc.bug
|
||||||
|
* tree.c entities.c encoding.c: doing some cleanups while
|
||||||
|
chasing it
|
||||||
|
|
||||||
Thu Jun 21 13:13:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
Thu Jun 21 13:13:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* Makefile.am: cleanup when --without-debug is specified
|
* Makefile.am: cleanup when --without-debug is specified
|
||||||
|
100
encoding.c
100
encoding.c
@ -2016,7 +2016,7 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
|||||||
default:
|
default:
|
||||||
xmlGenericError(xmlGenericErrorContext,"Unknown input conversion failed %d\n", ret);
|
xmlGenericError(xmlGenericErrorContext,"Unknown input conversion failed %d\n", ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* DEBUG_ENCODING */
|
||||||
/*
|
/*
|
||||||
* Ignore when input buffer is not on a boundary
|
* Ignore when input buffer is not on a boundary
|
||||||
*/
|
*/
|
||||||
@ -2039,70 +2039,82 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
|||||||
* the result of transformation can't fit into the encoding we want), or
|
* the result of transformation can't fit into the encoding we want), or
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmlCharEncInFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
|
||||||
xmlBufferPtr in) {
|
xmlBufferPtr in)
|
||||||
|
{
|
||||||
int ret = -2;
|
int ret = -2;
|
||||||
int written;
|
int written;
|
||||||
int toconv;
|
int toconv;
|
||||||
|
|
||||||
if (handler == NULL) return(-1);
|
if (handler == NULL)
|
||||||
if (out == NULL) return(-1);
|
return (-1);
|
||||||
if (in == NULL) return(-1);
|
if (out == NULL)
|
||||||
|
return (-1);
|
||||||
|
if (in == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
toconv = in->use;
|
toconv = in->use;
|
||||||
if (toconv == 0)
|
if (toconv == 0)
|
||||||
return(0);
|
return (0);
|
||||||
written = out->size - out->use;
|
written = out->size - out->use;
|
||||||
if (toconv * 2 >= written) {
|
if (toconv * 2 >= written) {
|
||||||
xmlBufferGrow(out, out->size + toconv * 2);
|
xmlBufferGrow(out, out->size + toconv * 2);
|
||||||
written = out->size - out->use - 1;
|
written = out->size - out->use - 1;
|
||||||
}
|
}
|
||||||
if (handler->input != NULL) {
|
if (handler->input != NULL) {
|
||||||
ret = handler->input(&out->content[out->use], &written,
|
ret = handler->input(&out->content[out->use], &written,
|
||||||
in->content, &toconv);
|
in->content, &toconv);
|
||||||
xmlBufferShrink(in, toconv);
|
xmlBufferShrink(in, toconv);
|
||||||
out->use += written;
|
out->use += written;
|
||||||
out->content[out->use] = 0;
|
out->content[out->use] = 0;
|
||||||
}
|
}
|
||||||
#ifdef LIBXML_ICONV_ENABLED
|
#ifdef LIBXML_ICONV_ENABLED
|
||||||
else if (handler->iconv_in != NULL) {
|
else if (handler->iconv_in != NULL) {
|
||||||
ret = xmlIconvWrapper(handler->iconv_in, &out->content[out->use],
|
ret = xmlIconvWrapper(handler->iconv_in, &out->content[out->use],
|
||||||
&written, in->content, &toconv);
|
&written, in->content, &toconv);
|
||||||
xmlBufferShrink(in, toconv);
|
xmlBufferShrink(in, toconv);
|
||||||
out->use += written;
|
out->use += written;
|
||||||
out->content[out->use] = 0;
|
out->content[out->use] = 0;
|
||||||
if (ret == -1) ret = -3;
|
if (ret == -1)
|
||||||
|
ret = -3;
|
||||||
}
|
}
|
||||||
#endif /* LIBXML_ICONV_ENABLED */
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
#ifdef DEBUG_ENCODING
|
|
||||||
case 0:
|
case 0:
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
#ifdef DEBUG_ENCODING
|
||||||
"converted %d bytes to %d bytes of input\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
toconv, written);
|
"converted %d bytes to %d bytes of input\n",
|
||||||
break;
|
toconv, written);
|
||||||
case -1:
|
|
||||||
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
|
|
||||||
toconv, written, in->use);
|
|
||||||
break;
|
|
||||||
case -3:
|
|
||||||
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
|
|
||||||
toconv, written, in->use);
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
|
toconv, written, in->use);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -3:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
|
toconv, written, in->use);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
case -2:
|
case -2:
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"input conversion failed due to input error\n");
|
"input conversion failed due to input error\n");
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||||
in->content[0], in->content[1],
|
in->content[0], in->content[1],
|
||||||
in->content[2], in->content[3]);
|
in->content[2], in->content[3]);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Ignore when input buffer is not on a boundary
|
* Ignore when input buffer is not on a boundary
|
||||||
*/
|
*/
|
||||||
if (ret == -3) ret = 0;
|
if (ret == -3)
|
||||||
return(ret);
|
ret = 0;
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2214,17 +2226,19 @@ retry:
|
|||||||
* Attempt to handle error cases
|
* Attempt to handle error cases
|
||||||
*/
|
*/
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
#ifdef DEBUG_ENCODING
|
|
||||||
case 0:
|
case 0:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"converted %d bytes to %d bytes of output\n",
|
"converted %d bytes to %d bytes of output\n",
|
||||||
toconv, written);
|
toconv, written);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"output conversion failed by lack of space\n");
|
"output conversion failed by lack of space\n");
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
|
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
|
||||||
toconv, written, in->use);
|
toconv, written, in->use);
|
||||||
@ -2313,8 +2327,8 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
|
|||||||
else
|
else
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"closed the encoding handler\n");
|
"closed the encoding handler\n");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <libxml/xmlerror.h>
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
#define DEBUG_ENT_REF /* debugging of cross entities dependancies */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The XML predefined entities.
|
* The XML predefined entities.
|
||||||
*/
|
*/
|
||||||
@ -37,8 +35,8 @@ struct xmlPredefinedEntityValue xmlPredefinedEntityValues[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: !!!!!!! This is GROSS, allocation of a 256 entry hash for
|
* TODO: This is GROSS, allocation of a 256 entry hash for
|
||||||
* a fixed number of 4 elements !
|
* a fixed number of 4 elements !
|
||||||
*/
|
*/
|
||||||
xmlHashTablePtr xmlPredefinedEntities = NULL;
|
xmlHashTablePtr xmlPredefinedEntities = NULL;
|
||||||
|
|
||||||
|
4
tree.c
4
tree.c
@ -5645,12 +5645,12 @@ xmlElemDump(FILE *f, xmlDocPtr doc, xmlNodePtr cur) {
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (doc == NULL) {
|
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
|
if (doc == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlElemDump : doc == NULL\n");
|
"xmlElemDump : doc == NULL\n");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
buf = xmlBufferCreate();
|
buf = xmlBufferCreate();
|
||||||
if (buf == NULL) return;
|
if (buf == NULL) return;
|
||||||
if ((doc != NULL) &&
|
if ((doc != NULL) &&
|
||||||
|
66
xpath.c
66
xpath.c
@ -5731,7 +5731,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
|
|||||||
const xmlChar *cur = str;
|
const xmlChar *cur = str;
|
||||||
double ret = 0.0;
|
double ret = 0.0;
|
||||||
double mult = 1;
|
double mult = 1;
|
||||||
int ok = 0;
|
int ok = 0, tmp = 0;
|
||||||
int isneg = 0;
|
int isneg = 0;
|
||||||
int exponent = 0;
|
int exponent = 0;
|
||||||
int is_exponent_negative = 0;
|
int is_exponent_negative = 0;
|
||||||
@ -5744,11 +5744,16 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
|
|||||||
isneg = 1;
|
isneg = 1;
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* tmp is a workaroudn against a gcc compiler bug
|
||||||
|
*/
|
||||||
while ((*cur >= '0') && (*cur <= '9')) {
|
while ((*cur >= '0') && (*cur <= '9')) {
|
||||||
ret = ret * 10 + (*cur - '0');
|
tmp = tmp * 10 + (*cur - '0');
|
||||||
ok = 1;
|
ok = 1;
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
|
ret = (double) tmp;
|
||||||
|
|
||||||
if (*cur == '.') {
|
if (*cur == '.') {
|
||||||
cur++;
|
cur++;
|
||||||
if (((*cur < '0') || (*cur > '9')) && (!ok)) {
|
if (((*cur < '0') || (*cur > '9')) && (!ok)) {
|
||||||
@ -5791,10 +5796,11 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) {
|
xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
|
||||||
|
{
|
||||||
double ret = 0.0;
|
double ret = 0.0;
|
||||||
double mult = 1;
|
double mult = 1;
|
||||||
int ok = 0;
|
int ok = 0, tmp = 0;
|
||||||
int exponent = 0;
|
int exponent = 0;
|
||||||
int is_exponent_negative = 0;
|
int is_exponent_negative = 0;
|
||||||
|
|
||||||
@ -5802,38 +5808,42 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) {
|
|||||||
if ((CUR != '.') && ((CUR < '0') || (CUR > '9'))) {
|
if ((CUR != '.') && ((CUR < '0') || (CUR > '9'))) {
|
||||||
XP_ERROR(XPATH_NUMBER_ERROR);
|
XP_ERROR(XPATH_NUMBER_ERROR);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Try to work around a gcc optimizer bug
|
||||||
|
*/
|
||||||
while ((CUR >= '0') && (CUR <= '9')) {
|
while ((CUR >= '0') && (CUR <= '9')) {
|
||||||
ret = ret * 10 + (CUR - '0');
|
tmp = tmp * 10 + (CUR - '0');
|
||||||
ok = 1;
|
ok = 1;
|
||||||
NEXT;
|
NEXT;
|
||||||
}
|
}
|
||||||
|
ret = (double) tmp;
|
||||||
if (CUR == '.') {
|
if (CUR == '.') {
|
||||||
NEXT;
|
NEXT;
|
||||||
if (((CUR < '0') || (CUR > '9')) && (!ok)) {
|
if (((CUR < '0') || (CUR > '9')) && (!ok)) {
|
||||||
XP_ERROR(XPATH_NUMBER_ERROR);
|
XP_ERROR(XPATH_NUMBER_ERROR);
|
||||||
}
|
}
|
||||||
while ((CUR >= '0') && (CUR <= '9')) {
|
while ((CUR >= '0') && (CUR <= '9')) {
|
||||||
mult /= 10;
|
mult /= 10;
|
||||||
ret = ret + (CUR - '0') * mult;
|
ret = ret + (CUR - '0') * mult;
|
||||||
NEXT;
|
NEXT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((CUR == 'e') || (CUR == 'E')) {
|
if ((CUR == 'e') || (CUR == 'E')) {
|
||||||
NEXT;
|
NEXT;
|
||||||
if (CUR == '-') {
|
if (CUR == '-') {
|
||||||
is_exponent_negative = 1;
|
is_exponent_negative = 1;
|
||||||
NEXT;
|
NEXT;
|
||||||
}
|
}
|
||||||
while ((CUR >= '0') && (CUR <= '9')) {
|
while ((CUR >= '0') && (CUR <= '9')) {
|
||||||
exponent = exponent * 10 + (CUR - '0');
|
exponent = exponent * 10 + (CUR - '0');
|
||||||
NEXT;
|
NEXT;
|
||||||
}
|
}
|
||||||
|
if (is_exponent_negative)
|
||||||
|
exponent = -exponent;
|
||||||
|
ret *= pow(10.0, (double) exponent);
|
||||||
}
|
}
|
||||||
if (is_exponent_negative)
|
|
||||||
exponent = -exponent;
|
|
||||||
ret *= pow(10.0, (double)exponent);
|
|
||||||
PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_NUMBER, 0, 0,
|
PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_NUMBER, 0, 0,
|
||||||
xmlXPathNewFloat(ret), NULL);
|
xmlXPathNewFloat(ret), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user