[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #60802] Make .substring handle an empty result
From: |
anonymous |
Subject: |
[bug #60802] Make .substring handle an empty result |
Date: |
Sat, 19 Jun 2021 23:01:28 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Firefox/45.0 |
URL:
<https://savannah.gnu.org/bugs/?60802>
Summary: Make .substring handle an empty result
Project: GNU troff
Submitted by: None
Submitted on: Sun 20 Jun 2021 03:01:26 AM UTC
Category: Core
Severity: 3 - Normal
Item Group: Incorrect behaviour
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
_______________________________________________________
Details:
I'm trying to use .substring to remove the first character of a string,
leaving behind whatever follows, even if that is nothing (i.e. the string had
only one character).
.substring str 1
or
.length n2 "\*[str]
.nr n2 -1
.substring str 1 \n[n2]
(if n2 is omitted, it appears to default to length-1 as you might expect).
The above works as long as the string originally had at least two characters.
If it only has one, so the desired result is the empty string, it does not
remove anything, leaving behind the 0th character and emitting a warning (with
-w all).
This seems like a corner-case bug.
At first glance, it seems like it would be safe to fix this because the result
is currently always wrong in this case, i.e. n1 equals the length of the
string (so the result should be empty).
_______________________________________________________
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,
anonymous <=