bug-coreutils
[Top][All Lists]
Advanced

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

Re: wc annoyances


From: Jim Meyering
Subject: Re: wc annoyances
Date: Sun, 20 Jul 2003 17:56:43 +0200

Paul Eggert <address@hidden> wrote:
...
> However, I agree with you that the leading spaces are annoying; this
> has bitten me as well, in other examples.  I looked into this, and it
> turns out that the coreutils documentation is incorrect about what
> POSIX requires for 'wc'.  When this misunderstanding is corrected, 'wc
> -l <autolist.txt' can output no leading spaces.  While I was at it, I
> fixed another problem: wc's columns sometimes don't line up for files
> bigger than 9,999,999 bytes.  The fix handles only the case of regular
> files, but that's an important case.
>
> This patch fixes a couple of other minor related bugs that I noticed
> while implementing this change: there was a confusion between "" and NULL,
> and a possible arithmetic overflow.
>
> 2003-07-20  Paul Eggert  <address@hidden>
>
>         wc count field widths now are heuristically adjusted depending
>         on the input size, if known.  If only one count is printed, it
>         is guaranteed to be printed without leading spaces.
>
>         Previously, wc did not align the count fields if
>         POSIXLY_CORRECT was set, but POSIX did not actually require
>         this undesirable behavior, so it has been removed.

Thanks!
I've applied that, along with some additional changes.
Not that it matters, but in some unusual cases,
the new widths are worse than the old:

  $ dd bs=1 seek=1G of=b < /dev/null 2> /dev/null
  $ ./wc -lw b
           0          0 b
  $ wc -lw b
        0       0 b




reply via email to

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