hey eddie,

had a quick look at cvs and noted that infinity is not dealt with
explicitly, though maybe it does what is expected anyhow.
also:
 if ( start < 0){
      start = 0;
 }else if (start + len > strlen){
      return "";
 }

would fail for the following example from the spec:
substring("12345", -42, 1 div 0) returns "12345"

the else clause causes an exception for substrings exceeding the actual
stringlength if the start was negative, ie when both conditions are true.

furthermore i think it's probably incorrect to return "" when the
stringlength is exceeded, my impression is it should return everything
from the start position onwards, ie return str.substring(start);

looking at the spec now i'm not even sure if rounding negative start
values up to 0 is the right thing to do. seems that '0' is treated as 'one
before the first':
substring("12345", 0, 3) returns "12"
would then '-1' mean two before the first character? now i'm confused..


regards,

/m


On Fri, 10 May 2002, Eddie Mc Greal wrote:

> I've checked in an updated version of the substring function and added test
> to the build
> Previoulsy the substring function didn't handle invalid indices etc at all -
> an out of bounds eception was thrown
> Now you get back an empty string along the lines of the spec.
>
> The W3 xpath spec def of substring is very confusing and I think
> inconsistent if not wrong.
> If you take a look at the example in the spec
> http://www.w3.org/TR/xpath#section-String-Functions
> you'll see what I mean. They don't treat 0, negative numbers and infinity in
> a consistent manner. (In the newer XPath 2.0 spec these are treated as
> errors)
>
> Eddie
>
>
>
>
> _______________________________________________________________
>
> Have big pipes? SourceForge.net is looking for download mirrors. We supply
> the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
> _______________________________________________
> Jaxen-interest mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest
>


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to