implement initial non-alphanumeric token handling in number formatting.
authorThomas Broyer <tbroyer@src.gnome.org>
Sun, 14 Oct 2001 15:13:33 +0000 (15:13 +0000)
committerThomas Broyer <tbroyer@src.gnome.org>
Sun, 14 Oct 2001 15:13:33 +0000 (15:13 +0000)
* libxslt/numbers.c tests/REC/test-7.7-4.out: implement initial
  non-alphanumeric token handling in number formatting.

ChangeLog
libxslt/numbers.c
tests/REC/test-7.7-4.out

index c659f55bb52712532cf201b9988e0dea07d0129e..199249e005132650d397bf7d53667e330b900944 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Oct 14 17:17:03 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
+
+       * libxslt/numbers.c tests/REC/test-7.7-4.out: implement initial
+         non-alphanumeric token handling in number formatting.
+
 Wed Oct 10 11:58:41 CEST 2001 Daniel Veillard <daniel@veillard.com>
 
        * configure.in: releasing 1.0.5
index 6c933fd0905e4d93aa58a784d9d8d3053fa0b1b0..ad5e6f13682dd3b7771440f66d2624d1c4d4e506 100644 (file)
@@ -206,8 +206,22 @@ xsltNumberFormatTokenize(xmlChar *format,
     default_token.token = (xmlChar)'0';
     default_token.width = 1;
     default_token.filling = BAD_CAST(".");
-    
-    for (cnt = 0; cnt < array_max; cnt++) {
+
+    /*
+     * Parse initial non-alphanumeric token
+     * Always use an empty token for that
+     */
+    while (! (IS_LETTER(format[index]) || IS_DIGIT(format[index]))) {
+        if (format[index] == 0)
+             break; /* while */
+        index++;
+    }
+    if (index > 0)
+        array[0].filling = xmlStrndup(format, index);
+    else
+        array[0].filling = NULL;    
+
+    for (cnt = 1; cnt < array_max; cnt++) {
        if (format[index] == 0) {
            break; /* for */
        } else if (IS_DIGIT_ONE(format[index]) ||
@@ -288,12 +302,20 @@ xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
     int is_last_default_token = 0;
 
     minmax = (array_max >= numbers_max) ? numbers_max : array_max;
+
+    /*
+     * Handle initial non-alphanumeric token
+     */
+    token = &(*array)[0];
+    if (token->filling != NULL)
+        xmlBufferCat(buffer, token->filling);
+
     for (i = 0; i < numbers_max; i++) {
        /* Insert number */
        number = numbers[(numbers_max - 1) - i];
-       if (i < array_max) {
-         token = &(*array)[i];
-       } else if (array_max > 0) {
+       if (i + 1 < array_max) {
+         token = &(*array)[i + 1];
+       } else if (array_max > 1) {
          token = &(*array)[array_max - 1];
        } else {
          token = &default_token;
index a223307ea7078c47b574e0b1709b35cf8cac2c30..47d37bd93f1bf48fc5048ad47bae23bda90c0e6b 100644 (file)
@@ -3,14 +3,14 @@
   
     
       
-       <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1) A note here</fo:block>
-       <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">2) And here</fo:block>
+       <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">(1) A note here</fo:block>
+       <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">(2) And here</fo:block>
       
       
       
     
   
   
-    <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1) And another note here</fo:block>
+    <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">(1) And another note here</fo:block>