chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start par


From: John Cowan
Subject: Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start parameter
Date: Wed, 22 Jan 2014 20:58:05 -0500
User-agent: Mutt/1.5.20 (2009-06-14)

Mario Domenech Goulart scripsit:

> Quoting Taylor Campbell (from #scheme):
>
>     So, just to be clear: the right fix is to replace `0' by `start'
>     in the definition of STRING-TRIM-RIGHT.  (Taking the minimum of
>     the start and (+ 1 i) is also correct but unnecessary, because
>     STRING-SKIP-RIGHT guarantees (<= start i).)

Yes, he's right, but that exposes another bug:

(string-skip-right "abc   " char-whitespace? 4 4) => 2

The correct result is #f; Riastradh confirmed that the correct semantics
throughout SRFI 13 for start-end is that they are conceptually applied
using substring/shared before anything else is done.

A quick look at the reference implementation suggests that it needs
to trap the case where start = end, and always return #f then.
Causing start > end to throw an error wouldn't hurt either.

-- 
XQuery Blueberry DOM                            John Cowan
Entity parser dot-com                           address@hidden
    Abstract schemata                           http://www.ccil.org/~cowan
    XPointer errata
Infoset Unicode BOM                                 --Richard Tobin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]