[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
.substring bug - indicies don't work as documented(?)
From: |
Jim Avera |
Subject: |
.substring bug - indicies don't work as documented(?) |
Date: |
Fri, 26 Oct 2001 14:57:40 -0700 (PDT) |
Hi,
There may be a bug in the .substring function in
GNU troff version 1.16.1.
The man page says:
.substring xx n1 [n2]
Replace the string in register xx with the subĀ
string defined by the indices n1 and n2. The first
character in the string has index one. If n2 is
omitted, it is taken to be equal to the string's
length. If the index value n1 or n2 is negative or
zero, it will be counted from the end of the
string, going backwards: The last character has
index 0, the character before the last character
has index -1, etc.
Are n1 and n2 supposed to be the starting and ending indicies
of the substring to be retained?
Here are some results:
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 ""
for s=abcdefg .substring s 1 2 yields "a"
for s=abcdefg .substring s 1 3 yields "ab"
for s=abcdefg .substring s 2 1 yields "a"
If this is not a bug, can someone explain the output to me?
Thanks...
-Jim Avera
P.S. Attached is a test program.
=====
__________________________________________________
Please do not put me on a mailing list or give my
address(es) to anyone else.
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
substring_test.tr
Description: substring_test.tr
- .substring bug - indicies don't work as documented(?),
Jim Avera <=
Re: .substring bug - indicies don't work as documented(?), Werner LEMBERG, 2001/10/27