groff
[Top][All Lists]
Advanced

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

Re: [Groff] changed .substring


From: Werner LEMBERG
Subject: Re: [Groff] changed .substring
Date: Fri, 12 Jul 2002 10:22:42 +0200 (CEST)

> .substring does not test range violations.  If indexes are out of range
> the string is not altered; this is not wanted.

Actually, the string *is* altered.

> The following behavior is used with other languages:
> 
> 1) Referring an index before the first or after the last character
> should produce an error (>=length or <-length).
> 
> .ds s abc
> .substring s 3 3      \" should be an error
> .substring s -4 -4    \" should be an error

Both calls return the empty string.

I think it is better to emit a warning of type RANGE instead of
signaling an error (and I've done this right now in my local copy).

> 2) If the first argument points to an index after the index retrieved 
> from the second argument the result should be the empty string.
> 
> .ds s abc
> .substring s 2 1      \" s should become empty
> .substring s -1 -2    \" s should become empty
> .substring s 2 -2     \" s should become empty

The current philosophy is to exchange the boundaries (this was there
from the very beginning IIRC).  I know this is questionable, so again
I ask you all for your opinion.


    Werner

reply via email to

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