[Top][All Lists]

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

nl: line number decrement

From: KOBAYASHI Takashi
Subject: nl: line number decrement
Date: Sun, 25 Oct 2020 01:39:08 -0700


I wrote a little patch for nl(1). Could you merge this mainstream?
It reduces the line number with the "--line-increment(-i)" option and
negative value. The "--starting-line-number(-v)" option has been allowed
negative value but "-i" has not until now. It should be unified.

diff --git a/src/nl.c b/src/nl.c
index 8fe91f773..c61c81d5b 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -508,7 +508,7 @@ main (int argc, char **argv)
         case 'i':
-          page_incr = xdectoimax (optarg, 1, INTMAX_MAX, "",
+          page_incr = xdectoimax (optarg, INTMAX_MIN, INTMAX_MAX, "",
                                   _("invalid line number increment"), 0);
         case 'p':

I think this change in behavior was a bit hard a while ago because
integer-overflow of the line number was verified with a comparison
operator. However the bug had been fixed with the "INT_ADD_WRAPV" macro by
Paul Eggert last year. It made the implementation of decrement safe.

Best regards,


Attachment: nl_i.patch
Description: Source code patch

reply via email to

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