]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
ptx: avoid --format long option falling through into --help
authorBernhard Voelker <mail@bernhard-voelker.de>
Wed, 26 Mar 2014 08:02:42 +0000 (09:02 +0100)
committerBernhard Voelker <mail@bernhard-voelker.de>
Wed, 26 Mar 2014 10:29:53 +0000 (11:29 +0100)
* src/ptx.c (main): Add a 'break' after the --format handling case.
Otherwise it would fall through into the usage case.
* tests/misc/ptx.pl: Add test cases for --format=tex and --format=roff.
* NEWS (Bug fixes): Mention the fix.
Bug introduced in 1999-04-04 commit, SH-UTILS-1_16f-269-gd815c15.
Spotted by coverity (MISSING_BREAK).

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

diff --git a/NEWS b/NEWS
index f68ab4f7c1d52a5aadb0069bf7ca0e403d3c1e70..582f06082a7a1461ee926f8ea293cafcd2b4a609 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   ln -sr '' F no longer segfaults.  Now works as expected.
   [bug introduced with the --relative feature in coreutils-8.16]
 
+  ptx --format long option parsing no longer falls through into the --help case.
+  [bug introduced in TEXTUTILS-1_22i]
+
   shuf --repeat no longer dumps core if the input is empty.
   [bug introduced with the --repeat feature in coreutils-8.22]
 
index 99da0cb5b1b915af4764a66af9f81aeab4f60056..be342eefc54b1c64ac8811b53e1fa11f58654500 100644 (file)
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -2015,6 +2015,8 @@ main (int argc, char **argv)
         case 10:
           output_format = XARGMATCH ("--format", optarg,
                                      format_args, format_vals);
+          break;
+
         case_GETOPT_HELP_CHAR;
 
         case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
index 2db953a92c4ab18398848cc922e285fc1b4cab50..8a91d616af7e1c6cb9ab70950fea2fb2b058a2ae 100755 (executable)
@@ -33,6 +33,13 @@ my @Tests =
 
 # with coreutils-6.12 and earlier, this would act like "ptx F1 F1"
 ["2files", '-g1 -w1', {IN=>{F1=>"a"}}, {IN=>{F2=>"b"}}, {OUT=>"  a\n  b\n"}],
+
+# with coreutils-8.22 and earlier, the --format long option would
+# fall through into the --help case.
+["format-r", '--format=roff', {IN=>"foo\n"},
+                              {OUT=>".xx \"\" \"\" \"foo\" \"\"\n"}],
+["format-t", '--format=tex',  {IN=>"foo\n"},
+                              {OUT=>"\\xx {}{}{foo}{}{}\n"}],
 );
 
 @Tests = triple_test \@Tests;