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: Mario Domenech Goulart
Subject: Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start parameter
Date: Sun, 19 Jan 2014 22:03:52 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

On Sat, 11 Jan 2014 14:04:07 -0500 John Cowan <address@hidden> wrote:

> Mario Domenech Goulart scripsit:
>
>> However, both Scheme48 and Racket return "" for 
>> 
>>   (string-trim-right "abc   " char-whitespace? 4 4)
>> 
>> CHICKEN returns "abc", which looks like a bug to me.
>
> It certainly is, since the value of (substring s k k) is always "" for
> any legal k.  And indeed the proposed patch, which passes start rather
> than 0 to substring, will actually make this bug worse.  The correct
> value to pass is (min start (+ i 1)), which guarantees that start is
> always safe.

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).)

Best wishes.
Mario
-- 
http://parenteses.org/mario



reply via email to

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