further refinement to UTF8 pattern separator (bug 151975)
authorWilliam M. Brack <wbrack@src.gnome.org>
Wed, 8 Sep 2004 01:02:35 +0000 (01:02 +0000)
committerWilliam M. Brack <wbrack@src.gnome.org>
Wed, 8 Sep 2004 01:02:35 +0000 (01:02 +0000)
* libxslt/numbers.c: further refinement to UTF8 pattern
  separator (bug 151975)

ChangeLog
libxslt/numbers.c

index 5cf705a..66dc945 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Sep  7 18:04:55 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/numbers.c: further refinement to UTF8 pattern
+         separator (bug 151975)
+
 Tue Sep  7 00:14:12 PDT 2004 William Brack <wbrack@mmm.com.hk>
 
        * libxslt/numbers.c: fixed problem with UTF8 pattern
index 1660793..27e74df 100644 (file)
@@ -1158,7 +1158,7 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
      * "number" part, should be in suffix 
      */
     if (delayed_multiplier != 0) {
-       the_format--;
+       the_format -= len;
        delayed_multiplier = 0;
     }
 
@@ -1176,21 +1176,18 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
      * If the number is -ve, we must substitute the -ve prefix / suffix
      */
     if (number < 0) {
+        /*
+        * Note that j is the number of UTF8 chars before the separator,
+        * not the number of bytes! (bug 151975)
+        */
         j =  xmlUTF8Strloc(format, self->patternSeparator);
        if (j < 0) {
        /* No -ve pattern present, so use default signing */
            default_sign = 1;
        }
        else {
-            int lenPS;
-           lenPS = xmlUTF8Size(self->patternSeparator);
-           if (lenPS <= 0) {
-               found_error = 1;
-               goto OUTPUT_NUMBER;
-           }
-       
-           /* Skip over pattern separator */
-           the_format = format + j + lenPS;
+           /* Skip over pattern separator (accounting for UTF8) */
+           the_format = xmlUTF8Strpos(format, j + 1);
            /* 
             * Flag changes interpretation of percent/permille 
             * in -ve pattern 
@@ -1223,11 +1220,15 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
                    delayed_multiplier = 0;
                else
                    break; /* while */
-               the_format++;
+               if ((len = xsltUTF8Size(the_format)) < 1) {
+                   found_error = 1;
+                   goto OUTPUT_NUMBER;
+               }
+               the_format += len;
            }
            if (delayed_multiplier != 0) {
                format_info.is_multiplier_set = FALSE;
-               the_format--;
+               the_format -= len;
            }
 
            /* Finally do the -ve suffix */
@@ -1236,8 +1237,8 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
                nsuffix_length = xsltFormatNumberPreSuffix(self, 
                                        &the_format, &format_info);
                if (nsuffix_length < 0) {
-               found_error = 1;
-               goto OUTPUT_NUMBER;
+                   found_error = 1;
+                   goto OUTPUT_NUMBER;
                }
            }
            else