Hello,

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)
                                              0);
           break;
         case 'i':
-          page_incr = xdectoimax (optarg, 1, INTMAX_MAX, "",
+          page_incr = xdectoimax (optarg, INTMAX_MIN, INTMAX_MAX, "",
                                   _("invalid line number increment"), 0);
           break;
         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,

KOBAYASHI Takashi
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)
                                              0);
           break;
         case 'i':
-          page_incr = xdectoimax (optarg, 1, INTMAX_MAX, "",
+          page_incr = xdectoimax (optarg, INTMAX_MIN, INTMAX_MAX, "",
                                   _("invalid line number increment"), 0);
           break;
         case 'p':

Reply via email to