bug-cflow
[Top][All Lists]
Advanced

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

Re: [bug-cflow] 1 line, no newline, wc says 0 lines


From: James Dennis
Subject: Re: [bug-cflow] 1 line, no newline, wc says 0 lines
Date: Fri, 14 Oct 2016 09:32:11 -0400

OK, that makes sense. Thank you for the response and have a nice day. :)

On Thu, Oct 13, 2016 at 12:39 PM, Sergey Poznyakoff <address@hidden> wrote:
Hi James,

> I was writing data to a file and ran `wc -l <file>` on it to check if the
> file had output. wc kept reporting 0, so I assumed there was no data.

That's quite correct.  The -l switch instructs wc to report the number
of newline characters (not lines!) in the input file.  Your file had
none, so you were returned 0.

To test if file is not empty, use "test -s <file>".

Quoting man page for wc:

  DESCRIPTION
         Print newline, word, and byte counts for each FILE
         [...]

  -l, --lines
                print the newline counts


> I found `wc.c` in cflow's source inside the `doc/` directory and was easy
> enough to adjust for this specific case.

(A minor clarification regarding this file: it is not the source of the
system wc utility, although it does the same job.  The wc utility on most
GNU/Linux systems comes from the coreutils package
[http://www.gnu.org/software/coreutils/coreutils].  Other Unices provide
their own versions as well.

The purpose of wc.c in cflow is to serve as an example source to
illustrate its functionality).

> My experience may be the intended behavior. The COUNT macro certainly
> suggests this, but I found it misleading and would love to patch it if the
> cflow team agrees.

Thanks for proposition, but that's the way standard wc works, so it
should not be changed.

Best regards,
Sergey



--
jms dnns
me // facebook // github // twitter


reply via email to

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