]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
base64: no longer support hex or oct --wrap params
authorPádraig Brady <P@draigBrady.com>
Mon, 17 Aug 2015 04:45:47 +0000 (21:45 -0700)
committerPádraig Brady <P@draigBrady.com>
Wed, 2 Sep 2015 23:34:12 +0000 (00:34 +0100)
* src/base64.c (main): Support decimal numbers with leading zeros,
by disabling the auto detection of octal and hex.  It's not
envisaged that base conversion is needed for --wrap parameters,
and in the edge case it is, $((0x0)) shell constructs can be used.
* tests/misc/base64.pl: Adjust accordingly.
* NEWS: Mention the change in behavior.

NEWS
src/base64.c
tests/misc/base64.pl

diff --git a/NEWS b/NEWS
index d247e9d3c8af646390910ed6d73295aa51895957..33414c4ebf1082f5b07137e104107e38153b358b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,11 @@ GNU coreutils NEWS                                    -*- outline -*-
   base32 is added to complement the existing base64 command,
   and encodes and decodes printable text as per RFC 4648.
 
+** Changes in behavior
+
+  base64 no longer supports hex or oct --wrap parameters,
+  thus better supporting decimals with leading zeros.
+
 
 * Noteworthy changes in release 8.24 (2015-07-03) [stable]
 
index 15888fa83a2e894b4d329536c47152a1df451c96..1e43ff1869af3515f4e0b1df1a88fb0445b1fdbf 100644 (file)
@@ -289,7 +289,7 @@ main (int argc, char **argv)
         break;
 
       case 'w':
-        wrap_column = xnumtoumax (optarg, 0, 0, UINTMAX_MAX, "",
+        wrap_column = xdectoumax (optarg, 0, UINTMAX_MAX, "",
                                   _("invalid wrap size"), 0);
         break;
 
index 44c3d21ab88687ec14f91b48ba656e2dfb3d6dc6..af397425c5551f39089a3fec24173c6799fbf0b4 100755 (executable)
@@ -71,7 +71,7 @@ sub gen_tests($)
      ['inout4', {IN=>'a'x4}, {OUT=>&$enc(4)."\n"}],
      ['inout5', {IN=>'a'x5}, {OUT=>&$enc(5)."\n"}],
      ['wrap', '--wrap 0', {IN=>'a'}, {OUT=>&$enc(1)}],
-     ['wrap-hex', '--wrap 0x0', {IN=>'a'}, {OUT=>&$enc(1)}],
+     ['wrap-zero', '--wrap 08', {IN=>'a'}, {OUT=>&$enc(1)."\n"}],
      ['wrap5-39', '--wrap=5', {IN=>'a' x 39}, {OUT=>wrap &$enc(39),5}],
      ['wrap5-40', '--wrap=5', {IN=>'a' x 40}, {OUT=>wrap &$enc(40),5}],
      ['wrap5-41', '--wrap=5', {IN=>'a' x 41}, {OUT=>wrap &$enc(41),5}],
@@ -81,9 +81,9 @@ sub gen_tests($)
      ['wrap5-45', '--wrap=5', {IN=>'a' x 45}, {OUT=>wrap &$enc(45),5}],
      ['wrap5-46', '--wrap=5', {IN=>'a' x 46}, {OUT=>wrap &$enc(46),5}],
 
-     ['wrap-bad-1', '-w08', {IN=>''}, {OUT=>""},
+     ['wrap-bad-1', '-w0x0', {IN=>''}, {OUT=>""},
       {ERR_SUBST => 's/base..:/base..:/'},
-      {ERR => "base..: invalid wrap size: '08'\n"}, {EXIT => 1}],
+      {ERR => "base..: invalid wrap size: '0x0'\n"}, {EXIT => 1}],
      ['wrap-bad-2', '-w1k', {IN=>''}, {OUT=>""},
       {ERR_SUBST => 's/base..:/base..:/'},
       {ERR => "base..: invalid wrap size: '1k'\n"}, {EXIT => 1}],