diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2002-04-10 16:14:34 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2002-04-10 16:14:34 +0000 |
commit | 0eafdef9881c396ce4c014359d8f497cc088cfab (patch) | |
tree | 75b836b809ca66fa749c39ed466c464bcadccf5f | |
parent | 01917aa1cb20fb33e6fa2b1e0ca2125051e491e0 (diff) | |
download | android_external_libxml2-0eafdef9881c396ce4c014359d8f497cc088cfab.tar.gz android_external_libxml2-0eafdef9881c396ce4c014359d8f497cc088cfab.tar.bz2 android_external_libxml2-0eafdef9881c396ce4c014359d8f497cc088cfab.zip |
another patch from Richard Jinks for substring conformance update of the
* xpath.c: another patch from Richard Jinks for substring conformance
* test/XPath/expr/floats test/XPath/expr/strings
result/XPath/expr/floats result/XPath/expr/strings: update of the
test suite to check those.
Daniel
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | result/XPath/expr/floats | 8 | ||||
-rw-r--r-- | result/XPath/expr/strings | 16 | ||||
-rw-r--r-- | test/XPath/expr/floats | 2 | ||||
-rw-r--r-- | test/XPath/expr/strings | 4 | ||||
-rw-r--r-- | xpath.c | 54 |
6 files changed, 69 insertions, 22 deletions
@@ -1,3 +1,10 @@ +Wed Apr 10 18:12:52 CEST 2002 Daniel Veillard <daniel@veillard.com> + + * xpath.c: another patch from Richard Jinks for substring conformance + * test/XPath/expr/floats test/XPath/expr/strings + result/XPath/expr/floats result/XPath/expr/strings: update of the + test suite to check those. + Wed Apr 10 13:29:49 CEST 2002 Daniel Veillard <daniel@veillard.com> * xpath.c: patch from Richard Jinks for .x float parsing. diff --git a/result/XPath/expr/floats b/result/XPath/expr/floats index 7a44f8df..176081b5 100644 --- a/result/XPath/expr/floats +++ b/result/XPath/expr/floats @@ -16,6 +16,14 @@ Expression: 0.123 Object is a number : 0.123 ======================== +Expression: 4. +Object is a number : 4 + +======================== +Expression: .4 +Object is a number : 0.4 + +======================== Expression: 1.23e3 Object is a number : 1230 diff --git a/result/XPath/expr/strings b/result/XPath/expr/strings index 09ccdec0..5ccd7c26 100644 --- a/result/XPath/expr/strings +++ b/result/XPath/expr/strings @@ -76,6 +76,22 @@ Expression: substring("12345",0,3) Object is a string : 12 ======================== +Expression: substring("12345", 0 div 0, 3) +Object is a string : + +======================== +Expression: substring("12345", 1, 0 div 0) +Object is a string : + +======================== +Expression: substring("12345", -42, 1 div 0) +Object is a string : 12345 + +======================== +Expression: substring("12345", -1 div 0, 1 div 0) +Object is a string : + +======================== Expression: string-length("") Object is a number : 0 diff --git a/test/XPath/expr/floats b/test/XPath/expr/floats index 00ac6573..5d052d6a 100644 --- a/test/XPath/expr/floats +++ b/test/XPath/expr/floats @@ -2,6 +2,8 @@ 123 1.23 0.123 +4. +.4 1.23e3 1.23e-3 1 div 0 diff --git a/test/XPath/expr/strings b/test/XPath/expr/strings index c54cdf33..a070f3a3 100644 --- a/test/XPath/expr/strings +++ b/test/XPath/expr/strings @@ -17,5 +17,9 @@ substring("12345",2,3) substring("12345",2) substring("12345",1.5,2.6) substring("12345",0,3) +substring("12345", 0 div 0, 3) +substring("12345", 1, 0 div 0) +substring("12345", -42, 1 div 0) +substring("12345", -1 div 0, 1 div 0) string-length("") string-length("titi") @@ -6152,34 +6152,44 @@ xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) { if (nargs != 3) le = m; - /* - * To meet our requirements, initial index calculations - * must be done before we convert to integer format - * - * First we normalize indices + /* Need to check for the special cases where either + * the index is NaN, the length is NaN, or both + * arguments are infinity (relying on Inf + -Inf = NaN) */ - in -= 1.0; - le += in; - if (in < 0.0) - in = 0.0; - if (le > (double)m) - le = (double)m; + if (!xmlXPathIsNaN(in + le)) { + /* + * To meet our requirements, initial index calculations + * must be done before we convert to integer format + * + * First we normalize indices + */ + in -= 1.0; + le += in; + if (in < 0.0) + in = 0.0; + if (le > (double)m) + le = (double)m; - /* - * Now we go to integer form, rounding up - */ - i = (int) in; - if (((double)i) != in) i++; + /* + * Now we go to integer form, rounding up + */ + i = (int) in; + if (((double)i) != in) i++; - l = (int) le; - if (((double)l) != le) l++; + l = (int) le; + if (((double)l) != le) l++; + + if (l > m) l=m; - if (l > m) l=m; + /* number of chars to copy */ + l -= i; - /* number of chars to copy */ - l -= i; + ret = xmlUTF8Strsub(str->stringval, i, l); + } + else { + ret = NULL; + } - ret = xmlUTF8Strsub(str->stringval, i, l); if (ret == NULL) valuePush(ctxt, xmlXPathNewCString("")); else { |