[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Question about .substring
From: |
Ralph Corderoy |
Subject: |
Re: [Groff] Question about .substring |
Date: |
Thu, 20 Nov 2014 12:20:49 +0000 |
Hi ulrich,
> > -- Request: .substring str n1 [n2]
> > Replace the string named STR with the substring defined by the
> > indices N1 and N2. The first character in the string has index 0.
> > If N2 is omitted, it is taken to be equal to the string's length.
>
> shouldn't that be "it is taken to be equal to the string's length - 1"
> ? (As we count from zero.)
That's how substring_request() works it out.
http://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/troff/input.cpp#n4777
int end = -1;
if (!has_arg() || get_integer(&end)) {
...
if (start < 0)
start += real_length;
if (end < 0)
end += real_length;
if (start > end) {
int tem = start;
start = end;
end = tem;
}
"If N2 is omitted, the index of xx's last character is used."?
Cheers, Ralph.
- Re: [Groff] Question about .substring, (continued)
- Re: [Groff] Question about .substring, Steffen Nurpmeso, 2014/11/28
- Re: [Groff] Question about .substring, Ralph Corderoy, 2014/11/29
- Re: [Groff] Question about .substring, Steffen Nurpmeso, 2014/11/22
- Re: [Groff] Question about .substring, Carsten Kunze, 2014/11/20
- [Groff] .fl (was: Question about .substring), Carsten Kunze, 2014/11/20
- Re: [Groff] Question about .substring, Ralph Corderoy, 2014/11/19
- Re: [Groff] Question about .substring, Ulrich Lauther, 2014/11/19
- Re: [Groff] Question about .substring,
Ralph Corderoy <=