aboutsummaryrefslogtreecommitdiffstats
path: root/xpath.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2002-03-19 11:25:30 +0000
committerDaniel Veillard <veillard@src.gnome.org>2002-03-19 11:25:30 +0000
commit28cac6b5a9558001844e02f00bfddda211b466d2 (patch)
tree79a4be42681452d185198d761f528b9e630c13ae /xpath.c
parent34ce8bece2f22cc99d25221b77315cd008f4866b (diff)
downloadandroid_external_libxml2-28cac6b5a9558001844e02f00bfddda211b466d2.tar.gz
android_external_libxml2-28cac6b5a9558001844e02f00bfddda211b466d2.tar.bz2
android_external_libxml2-28cac6b5a9558001844e02f00bfddda211b466d2.zip
pretty insane thing, the xmlXPathFormatNumber() was not serializing 1 as
* xpath.c: pretty insane thing, the xmlXPathFormatNumber() was not serializing 1 as "1" if LC_ALL=sv_SE :-( and in the context of ScrollKeeper, made sure that if the number is an integer, the serialization follows the description at http://www.w3.org/TR/xpath#section-String-Functions Daniel
Diffstat (limited to 'xpath.c')
-rw-r--r--xpath.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/xpath.c b/xpath.c
index 24d8dc01..3a3d4059 100644
--- a/xpath.c
+++ b/xpath.c
@@ -1125,6 +1125,36 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
if (xmlXPathIsNaN(number)) {
if (buffersize > (int)sizeof("NaN"))
sprintf(buffer, "NaN");
+ } else if (number == ((int) number)) {
+ char work[30];
+ char *ptr, *cur;
+ int res, value = (int) number;
+
+ ptr = &buffer[0];
+ if (value < 0) {
+ *ptr++ = '-';
+ value = -value;
+ }
+ if (value == 0) {
+ *ptr++ = '0';
+ } else {
+ cur = &work[0];
+ while (value != 0) {
+ res = value % 10;
+ value = value / 10;
+ *cur++ = '0' + res;
+ }
+ cur--;
+ while ((cur >= &work[0]) && (ptr - buffer < buffersize)) {
+ *ptr++ = *cur--;
+ }
+ }
+ if (ptr - buffer < buffersize) {
+ *ptr = 0;
+ } else if (buffersize > 0) {
+ ptr--;
+ *ptr = 0;
+ }
} else {
/* 3 is sign, decimal point, and terminating zero */
char work[DBL_DIG + EXPONENT_DIGITS + 3];