[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] Bug in SRFI 13 string-skip-right (was: fix for string-
From: |
John Cowan |
Subject: |
[Chicken-hackers] Bug in SRFI 13 string-skip-right (was: fix for string-trim-right) |
Date: |
Wed, 22 Jan 2014 23:57:34 -0500 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Alex Shinn scripsit:
> > (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.
>
> Shouldn't it return ""?
No, you're confusing string-skip-right (the subject of this bug) with
string-trim-right (the subject of the previous bug). The former returns
an index or #f, whereas the latter returns a substring. The trouble
here is that if start = end, string-skip-right should always return #f,
because there are no indexes in an empty string. Instead, it starts
at end - 1 anyway even though that is less than start, and returns a
spurious result. As a result, string-trim-right where start = end also
returns a spurious result.
--
When I'm stuck in something boring John Cowan
where reading would be impossible or (who loves Asimov too)
rude, I often set up math problems for address@hidden
myself and solve them as a way to pass http://www.ccil.org/~cowan
the time. --John Jenkins
- Re: [Chicken-hackers] [PATCH] fix for srfi-13 string-trim-right start parameter, (continued)
- Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start parameter, .alyn.post., 2014/01/11
- Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start parameter, Mario Domenech Goulart, 2014/01/11
- Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start parameter, Mario Domenech Goulart, 2014/01/19
- Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start parameter, John Cowan, 2014/01/22
- Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start parameter, Alex Shinn, 2014/01/22
- [Chicken-hackers] Bug in SRFI 13 string-skip-right (was: fix for string-trim-right),
John Cowan <=
- Re: [Chicken-hackers] Bug in SRFI 13 string-skip-right (was: fix for string-trim-right), Alex Shinn, 2014/01/23
Re: [Chicken-hackers] [PATH] fix for srfi-13 string-trim-right start parameter, Mario Domenech Goulart, 2014/01/19