[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #60802] Make .substring handle an empty result
From: |
Jim Avera |
Subject: |
[bug #60802] Make .substring handle an empty result |
Date: |
Sun, 4 Jul 2021 17:32:49 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0 |
Follow-up Comment #2, bug #60802 (project groff):
In the email list where this was reported, Brandon Robinson asked for (1) a
unit test for the boundary conditions of the .substring request and (2) a
precise description of its slicing semantics in our documentation.
Here is a first crack at those. Please see attached shell script which runs
a regression test (which currently fails because .substring does not yet
behave in the way expected).
Here is a revised description of desired behavior:
.substring xx n1 n2
Replace string xx with the substring defined by zero-based indicies
n1 and n2. Or, put another way, delete any characters outside the
range (n1..n2). If n2 is omitted then all characters after index
n1 are included in the substring.
If n1 > n2 or if n1 equals the length of the string, then nothing
is selected and the string is set to empty if it was not already empty.
Behavior is undefined if n1 > (n2+1) or if either index is negative.
(file #51644)
_______________________________________________________
Additional Item Attachment:
File name: substring_test.bash Size:2 KB
<https://file.savannah.gnu.org/file/substring_test.bash?file_id=51644>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60802>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #60802] Make .substring handle an empty result,
Jim Avera <=