groff
[Top][All Lists]
Advanced

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

[Groff] Re: .substring bug - indicies don't work as documented(?)


From: Bernd Warken
Subject: [Groff] Re: .substring bug - indicies don't work as documented(?)
Date: Sun, 28 Oct 2001 01:15:14 +0200
User-agent: Mutt/1.2.5i

On Sat, Oct 27, 2001 at 07:23:07PM +0200, Werner LEMBERG wrote:
> 
> Now you'll get the following consistent results:
> 
>   for s=abcdefg .substring s  0   yields "g"
>   for s=abcdefg .substring s  0 1 yields "abcdefg"
>   for s=abcdefg .substring s  0 2 yields "bcdefg"
>   for s=abcdefg .substring s  0 3 yields "cdefg"
>   for s=abcdefg .substring s  1 1 yields "a"
>   for s=abcdefg .substring s  1 2 yields "ab"
>   for s=abcdefg .substring s  1 3 yields "abc"
>   for s=abcdefg .substring s  2 1 yields "ab"
>   for s=abcdefg .substring s  2 2 yields "b"
>   for s=abcdefg .substring s  2 3 yields "bc"
>   for s=abcdefg .substring s -2   yields "efg"
>   for s=abcdefg .substring s -1   yields "fg"
>   for s=abcdefg .substring s  0   yields "g"
>   for s=abcdefg .substring s  1   yields "abcdefg"
>   for s=abcdefg .substring s  2   yields "bcdefg"
>
BTW how about defining a single argument meaning the corresponding
character, e.g. ".substring s 1" the first letter and ".substring -1"
the last letter.

It is illogical to start with 1 from the front and with 0 from the end.
Moreover, 0 means everything up to behind the last character; so the last
character should be -1 anyway.

Also 2 args in reversed order could be made into reversing the output.

It seems to be fairly unused so far, so it's still time to make sound.

Bernd Warken


reply via email to

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