bug-coreutils
[Top][All Lists]
Advanced

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

Re: fmt gobbles leading whitespace in prefix mode


From: Jim Meyering
Subject: Re: fmt gobbles leading whitespace in prefix mode
Date: Thu, 19 Jan 2006 22:00:16 +0100

Thomas Hood <address@hidden> wrote:
> Jim: Any comment on this <http://bugs.debian.org/147577>?
>
> $ fmt --version
> fmt (GNU coreutils) 5.93
> $ cat fmt-test
>         tabbed
>                 tabbed-twice
>  leading-space
>   two-leading-spaces
>
>> quoted
>> text
> $ fmt fmt-test
>         tabbed
>                 tabbed-twice
>  leading-space
>   two-leading-spaces
>
>> quoted > text
> $ fmt -p fmt-test
>
> $ fmt -p "> " fmt-test
> tabbed
> tabbed-twice
> leading-space
> two-leading-spaces
>
>> quoted text

It sure looks like a bug to me.
I've added that (expected-fail for now) test case.
If someone feels like fixing this, I'd welcome a patch.

Thanks for digging it up, and to Neil for reporting
it in the first place.

2006-01-19  Jim Meyering  <address@hidden>

        * tests/fmt/basic (pfx-1, pfx-2): New tests, to demonstrate the bug
        reported as http://bugs.debian.org/147577.  Forwarded by Thomas Hood.

Index: tests/fmt/basic
===================================================================
RCS file: /fetish/cu/tests/fmt/basic,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -p -u -r1.12 -r1.13
--- tests/fmt/basic     20 Apr 2005 07:54:54 -0000      1.12
+++ tests/fmt/basic     19 Jan 2006 20:58:22 -0000      1.13
@@ -40,6 +40,23 @@ my @Tests =
       {ERR => "fmt: invalid option -- 7; -WIDTH is recognized only when it"
        . " is the first\noption; use -w N instead\n"
        . "Try `fmt --help' for more information.\n" }, {EXIT => 1}],
+
+     # With --prefix=P, Do not remove leading on lines without the prefix.
+     ['pfx-1', qw (-p '>'),
+      {IN=>  " 1\n  2\n\t3\n\t\t4\n> quoted\n> text\n"},
+      # This is the buggy output (leading white space removed),
+      # from coreutils-5.93.
+      {OUT=> "1\n2\n3\n4\n> quoted text\n"}],
+      # FIXME: this is the desired output
+      # {OUT=> " 1\n  2\n\t3\n\t\t4\n> quoted text\n"}],
+
+     # Like the above, but when two adjacent, non-prefixed lines have
+     # the same indentation, ensure that they are formatted.
+     ['pfx-2', qw (-p '>'),
+      {IN=>  " 1\n 2\n\t3\n\t4\n"},
+      {OUT=> "1\n2\n3\n4\n"}],
+      # FIXME: this is the desired output
+      # {OUT=> " 1 2\n\t3 4\n"}],
     );
 
 my $save_temps = $ENV{DEBUG};




reply via email to

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