mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-07 06:43:02 +03:00
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
This commit is contained in:
@@ -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>
|
Wed Apr 10 13:29:49 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* xpath.c: patch from Richard Jinks for .x float parsing.
|
* xpath.c: patch from Richard Jinks for .x float parsing.
|
||||||
|
@@ -15,6 +15,14 @@ Object is a number : 1.23
|
|||||||
Expression: 0.123
|
Expression: 0.123
|
||||||
Object is a number : 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
|
Expression: 1.23e3
|
||||||
Object is a number : 1230
|
Object is a number : 1230
|
||||||
|
@@ -75,6 +75,22 @@ Object is a string : 234
|
|||||||
Expression: substring("12345",0,3)
|
Expression: substring("12345",0,3)
|
||||||
Object is a string : 12
|
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("")
|
Expression: string-length("")
|
||||||
Object is a number : 0
|
Object is a number : 0
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
123
|
123
|
||||||
1.23
|
1.23
|
||||||
0.123
|
0.123
|
||||||
|
4.
|
||||||
|
.4
|
||||||
1.23e3
|
1.23e3
|
||||||
1.23e-3
|
1.23e-3
|
||||||
1 div 0
|
1 div 0
|
||||||
|
@@ -17,5 +17,9 @@ substring("12345",2,3)
|
|||||||
substring("12345",2)
|
substring("12345",2)
|
||||||
substring("12345",1.5,2.6)
|
substring("12345",1.5,2.6)
|
||||||
substring("12345",0,3)
|
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("")
|
||||||
string-length("titi")
|
string-length("titi")
|
||||||
|
54
xpath.c
54
xpath.c
@@ -6152,34 +6152,44 @@ xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
if (nargs != 3)
|
if (nargs != 3)
|
||||||
le = m;
|
le = m;
|
||||||
|
|
||||||
/*
|
/* Need to check for the special cases where either
|
||||||
* To meet our requirements, initial index calculations
|
* the index is NaN, the length is NaN, or both
|
||||||
* must be done before we convert to integer format
|
* arguments are infinity (relying on Inf + -Inf = NaN)
|
||||||
*
|
|
||||||
* First we normalize indices
|
|
||||||
*/
|
*/
|
||||||
in -= 1.0;
|
if (!xmlXPathIsNaN(in + le)) {
|
||||||
le += in;
|
/*
|
||||||
if (in < 0.0)
|
* To meet our requirements, initial index calculations
|
||||||
in = 0.0;
|
* must be done before we convert to integer format
|
||||||
if (le > (double)m)
|
*
|
||||||
le = (double)m;
|
* 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
|
* Now we go to integer form, rounding up
|
||||||
*/
|
*/
|
||||||
i = (int) in;
|
i = (int) in;
|
||||||
if (((double)i) != in) i++;
|
if (((double)i) != in) i++;
|
||||||
|
|
||||||
l = (int) le;
|
l = (int) le;
|
||||||
if (((double)l) != le) l++;
|
if (((double)l) != le) l++;
|
||||||
|
|
||||||
if (l > m) l=m;
|
if (l > m) l=m;
|
||||||
|
|
||||||
/* number of chars to copy */
|
/* number of chars to copy */
|
||||||
l -= i;
|
l -= i;
|
||||||
|
|
||||||
|
ret = xmlUTF8Strsub(str->stringval, i, l);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ret = xmlUTF8Strsub(str->stringval, i, l);
|
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
valuePush(ctxt, xmlXPathNewCString(""));
|
valuePush(ctxt, xmlXPathNewCString(""));
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user