[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fmt gobbles leading whitespace in prefix mode
From: |
G.P. Halkes |
Subject: |
Re: fmt gobbles leading whitespace in prefix mode |
Date: |
Thu, 4 Jan 2007 16:55:30 +0100 |
This message is a reply to:
http://lists.gnu.org/archive/html/bug-coreutils/2006-01/msg00144.html
I ran into the same bug recently, and as it is not fixed in CVS I decided I'd
have a go at writing a patch.
[ For those unwilling to check the previous message: fmt removes whitespace
from lines that don't start with the specified prefix in --prefix mode ]
I also found that the second testcase added in the aforementioned message is
actually incorrect. The documentation for the prefix option says that lines
that do not start with the prefix are not touched. Or as the info page says:
`-p PREFIX'
`--prefix=PREFIX'
Only lines beginning with PREFIX (possibly preceded by whitespace)
are subject to formatting. (...)
The second testcase specifically wants to test for merging of lines that do
NOT start with prefix which is in direct contradiction to the above
explanation of --prefix.
When making this patch I also found that fmt removes all text from lines with
only whitespace (fine with me) and lines with a prefix followed by
whitespace. The latter case I find strange. The user obviously typed a line
with only the prefix, so why does fmt throw away this explicitly added line?
For example:
# Function foo
#
# Args: bar which does blah
Is turned into
# Function foo
# Args: bar which does blah
In my opnion the example should be left unchanged. I have included two
patches: one which only fixes the problem described in the previous post, and
one that ALSO changes the removal of the prefix'ed but otherwise empty lines.
The patches are mutually exclusive though, because they change the same line
in different ways. I think the patch names are self explanatory. Both patches
also change the testcases.
Regards,
Gertjan Halkes
prefix_keep_space.patch
Description: Text Data
prefix_keep_space_keep_prefix.patch
Description: Text Data
- Re: fmt gobbles leading whitespace in prefix mode,
G.P. Halkes <=