home *** CD-ROM | disk | FTP | other *** search
- TR.TTP: Translate and/or delete characters.
-
- by David Megginson, 1991
- Released into the Public Domain
-
- Usage: tr [-cds] string1 [string2]
-
- INTRODUCTION
-
- Here is my version of tr(1v) for the Atari ST. tr is a pure filter
- program (it cannot take files as arguments) which will translate or
- delete characters from its standard input and place the result on
- its standard output. tr takes three options:
-
- -c Use the complement of string1 (everything but..)
- -d Delete characters in string1
- -s Squeeze output so that multiple instances of the same
- translate character are compressed into a single instance.
-
- The strings may consist of any characters, a range in the format
- <char1>-<char2>, or an octal value in the form \nnn (you may not use
- octal values in a range). Use \ to take - literally. This example will
- create a list of words in a file, one on each line:
-
- tr -cs a-zA-Z '\012' < myfile.txt > wordlist.txt
-
- 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 tr, 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).
-
- 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 in the input file (I have _not_ done
- this for the distribution binary). Even with -DSKIP_CR, CR will usually
- be stripped from the output file, at least in this version.
-
- 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 tr.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).
-
-