home *** CD-ROM | disk | FTP | other *** search
- WC.TTP: Count characters, words and lines in (a) file(s)
-
- by David Megginson, 1991
- Released into the Public Domain
-
- Usage: wc [-cwl] [files...]
-
- INTRODUCTION
-
- Here is my version of wc(1) for the Atari ST. I have tested this
- version against the one which comes with Dave Beckemeyer's MT C-Shell,
- and the results seem to be identical (if there are bugs, we share
- them), although my output format is slightly different. wc takes three
- options:
-
- -c Count characters
- -w Count words
- -l Count lines
-
- If no options are given, wc will count all three. If there are no
- arguments after the options, wc will read from stdin; otherwise, it
- will read from each of the files supplied on the command line, where
- "-" stands for stdin.
-
- SPEED
-
- For the sake of speed, I bypass the high-level i/o functions and read
- in large chunks of a file at once (this is portable to Unix and MSDOS,
- by the way). The default buffer size is 50000 bytes, but you can change
- it in the Makefile by adding -DBUFFER_SIZE=<whatever>. The bigger the
- buffer, the faster wc, but also the more memory wasted (remember, the
- ST is a MULTITASKING machine now, so we can't use Malloc(-1L) to grab
- all available memory any more without risking flames). This buffering
- system makes my wc about 5-6 times faster than D.B.'s: in the test I
- ran (10 1,000-line text files), my wc took 28 seconds, while D.B.'s
- took 163 seconds. This version should work with MT C-Shell, which is
- still a very nice package (I ran the test on the old release; the new
- wc might be faster).
-
- THOSE PESKY CARRIAGE RETURNS
-
- For some brain-damaged reason (MSDOS,CP/M compatibility, I imagine),
- the ST uses "\r\n" to mark the end of a line instead of "\n" like in
- Unix. Many of us have recompiled programs to avoid this, but the problem
- of compatibility still remains. Use the -DSKIP_CR flag in the Makefile
- to handle '\r' correctly (I have done this for the distribution binary).
-
- WHAT DOES THIS COST?
-
- Nothing, of course. After Eric Smith created MiNT and made it free to
- the public, how could I live with myself if I tried to make this
- shareware? Besides, I spent only an hour or two on it. Do feel free
- to post glowing messages about me to the net, though... :-)
-
- REVISION NUMBER
-
- You can check the revision number of your wc.ttp binaries using the
- RCS ident(1) command. If you don't have A. Pratt's excellent port of
- RCS for the Atari ST, GET IT!
-
- USING THE SOURCE
-
- This program is in the Public Domain, _not_ under the Gnu licensing
- agreement. As a result, you may incorporate it (re-compiled) into
- commercial packages without charge, although I would like a little
- credit somewhere in the documentation. The source is (I hope) good
- ANSI, and you will need an ANSI compiler and ANSI header files to
- recompile it (I use the Gnu C compiler and Eric Smith's MiNT library
- for GCC on the Atari ST).
-
-