/*  cal.c -- UTOOL. Calendar.  Print lines with date match.
     author: David H. Wolen
     last change: 6/2/83

     usage: cal file  mm/dd/yy
            prog |cal -r mm/dd/yy mm/dd/yy
            cal file -ge mm/dd/yy

     options: -g (>)
              -l (<)
              -e (=)
              -r (>= date1 and <= date2)

     input:    file or STDIN
     output:   STDOUT

     notes:    -ge, -le, -gl, are ok (effect is "or" relation)
               only first valid date on line is examined for match
               if -r, no other options are allowed
               if no options, default is -e

*/
/*  cat.c -- UTOOL. Concatenate files ver 2.  
     author: David H. Wolen
     last change: 6/12/83

     usage:
          (1) copy console input to file (^z<cr> to stop)
               cat >ofile
          (2) concat inp files and write on output file
               cat ifile1 ifile2 >ofile
          (3) concat input files and pass to std input of prog2
               cat ifile1 ifile2 |prog2
          (4) clean up WordStar doc file
               cat -w file.doc >ofile
 
     option:   -w  clean up WordStar doc files by zeroing
                    hi bits and converting strange characters
                    to blanks

     input:    files or STDIN
     output:   STDOUT


*/
/*  ch.c -- UTOOL. Change pattern in text file.

     author: David H. Wolen
     last change: 3/4/83

     usage:  ch pattern [newstuff]

     input:  STDIN
     output: STDOUT

     notes:    1.  metacharacters in pattern (same as find)
                    %  begin of line
                    # #  enclose capital letters
                    " "  enclose imbedded blanks
                    ?  match any char except newline
                    $  end of line
                    [c1-c2]  char class
                    [!c1-c2] negated char class
                    *  closure (0 or more occurrences of prev 1 char pattern)
                    escaped chars:  \n (newline) \t (tab) \r (cr) 
                         \f (form feed) \b (backspace) \q (") \p (#)
               2.  If newstuff is omitted, deletion of pattern occurs.
               3.  Newstuff consists of zero or more of the following:
                    c  literal char
                    &  ditto, i.e. whatever was matched
                    \c  escaped char
                    # # and " " as above


*/
/*  cmp.c -- UTOOL. Compare 2 files or file and std input
     for equality.  
     author: David H. Wolen
     last change: 11/23/82

     usage: cmp file1 file2
            prog |cmp file1

     input:    2 files or file and STDIN
     output:   STDOUT

*/
/* comm.c -- UTOOL. Print lines common to two sorted files

     author: David H. Wolen
     last change: 11/29/82

     usage:    comm -123 file1 file2
               prog |comm file1

     options:  -n (n=1,2,3) print only named columns
                            (default is print all 3)

     input:    2 files or file and STDIN
     output:   STDOUT

     notes:    (1) if only one file is given, STDIN is file 2
               (2) col 1 is lines only in file 1
                   col 2 is lines only in file 2
                   col 3 is lines in both files

*/
/*  crt.c -- UTOOL. Display text file (including ws doc)
     a screen at a time.
     author: David H. Wolen
     last change: 6/12/83

     usage: crt -n file
            prog |crt
               <cr> forward a screen
               anything else to quit
     option: -n  line numbers

     input:    file or STDIN
     output:   STDOUT

*/
/* find.c -- UTOOL. Find patterns in text files (ver. 3) 

     author: David H. Wolen
     last change: 5/2/83

     usage:     find [-axn] pattern1 [pattern2 ... pattern10]

     options:  -a   output lines which contain all patterns
                    (default is output lines matching any pattern)
               -x   output lines that fail the match criteria
               -n   line numbers for output
               -c   just output count of matching lines
               -f   fold (ignore case in character comparisons)

     input:    STDIN
     output:   STDOUT

     notes:    1. -x pat1 pat2 : output if line contains neither pat
               2. -ax pat1 pat2 : output if line doesn't contain both pats
               3. metacharacters in pattern
                    %    match pattern at beginning of line
                    # #  enclose capital letters
                    " "  enclose embedded blanks
                    ?    match any char except newline
                    $    end of line
                    [c1-c2]  character class
                    [!c1-c2] negated character class
                    *    closure (0 or more occurrences of prev pattern)
                    escaped chars:  \n (newline)  \t (tab)  \r (cr)
                         \f (form feed)  \b (backspace)  \q (")  \p (#)
               4. first pattern can't begin with "-"
               5. up to MAXPATS patterns allowed (currently 10)
               6. if -c and -n, the latter will be ignored


*/
/*  hcat.c -- UTOOL. Horizontally concatenate text files.

     author: David H. Wolen
     last change: 3/16/83

     usage:    hcat file1 n2 file2 n3 file3 ...

               hcat file1 31 file2 51 file3 
                    (begin file1 in col 1, file2 in col 31, file3 in col 51)

     input:    one or more files
     output:   STDOUT

     notes:    1. max of 6 input files
               2. first file starts in col 1

*/
/* incl.c -- UTOOL. Expand included files

     author: David H. Wolen
     last change: 12/5/82

     usage:    incl <file

     input:    STDIN
     output:   STDOUT

     notes:    Replaces lines that begin with #include "file"
               with file contents.  The #include doesn't have
               to start in column 1.  Up to 8 open files at a
               time.

*/
/*  kwic.c -- UTOOL. Rotate lines to put keyword at front.
     First step in making keyword-in-context index.

     author: David H. Wolen
     last change: 12/1/82

     usage:    kwic <infile |sort -f |unrot

     input:    STDIN
     output:   STDOUT
*/
/* lpr.c -- UTOOL. Send stdin to printer

     author: David H. Wolen
     last change: 12/1/82

     usage:    prog |lpr -lnp 5 55
               lpr <file

     options:  -l  left margin (default 8)
               -n  lines per page (default 50)
               -p  pause after each page. <cr> to
                   resume, anything else to quit.
                   (default false)


     input:    STDIN
     output:   printer

     notes:    (1)  form feed after each page and at eof
               (2)  if both -l and -n are used, margin
                    value must preceed page size value.


*/
/*  prep.c -- UTOOL. Convert a text file (including ws doc files)
     to one word per line.
     author: David H. Wolen
     last change: 3/9/83

     usage:   prep <letter.doc -i dict.dat
     options: -o list.dat   only do words on file
              -i list.dat   ignore words on file
              -d            preface output words with input sequence numbers

     input:    STDIN
     output:   STDOUT

     notes:  (a) files for -o and -i must be prepared by prep
                 and sort (-f and -u)
             (b) can't use both -o and -i
             (c) output is lower case
             (d) max file size for -o or -i is 1000 lines or
                 about 30K.

*/
/*  sort.c -- UTOOL. (ver. 2) Incore sort of ascii lines.
     Max file size 2000 lines or about 30K.

     author: David H. Wolen
     last change: 5/5/83

     usage: sort <infile >outfile
            sort <infile -kf 1-5 8-12 6-7

     options:  -f fold lower into upper case before comparison
               -k key fields (n1-n2)  10 max
                    if no key fields and no numeric, whole line is used
               -r reverse
               -n numeric (first item on line must be int)
                    neither -f nor -k can be used with -n
               -u unique (according to current sort def of equal)

          input:    STDIN
          output:   STDOUT

*/
/* split.c -- UTOOL.  Read STDIN and write it out in n-line chunks to  files

     author: David H. Wolen
     last change:   3/31/83

     usage:    split [-n] [outname]

               split <infile
               split <infile -66 chunk

     options:  n       - number of  lines per file; default 100
               outname - filename for output files; default "temp"
                         (program assigns extentions .a ... .z).

     input:    STDIN
     output:   1 to 26 files

     notes:    (1)  output files are named outname.a ... outname.z if
                    outname is given as an argument.  Otherwise, they're
                    named temp.a ... temp.z (on the default drive).
               (2)  If the input is large, the 26th file may have n lines
                    written to it before end of input is reached.  In that
                    case, the rest of the input will also be
                    transferred to it.
               (3)  outname can't begin with "-"
               (4)  outname can contain a drive prefix; e.g. a:outname

*/
/* tabs.c -- UTOOL. Convert tabs to blanks (-d) or blanks
     to tabs and blanks (-e).

     author: David H. Wolen
     last change:   2/12/83

     usage:    tabs -d
               tabs -e 5 21 &5

     options:  -d   detab (convert tab chars to  blanks)
               -e   entab (convert blanks to tab chars and blanks)

     input:    STDIN
     output:   STDOUT

     notes:    (1) either -d or -e is required
               (2) default tab stops are at columns 8, 16, 24, ...
               (3) &n in the command line sets tabs every n columns.
                   E.G. "5 21 &5" sets tabs at columns 5, 21, 26, 31, ...
                   Anything after the &n will be ignored.

*/
/*  tail.c -- UTOOL. Print last n lines of file.

     author: David H. Wolen
     last change: 01/25/83

     usage:  tail  [n]

     options:  n  number of lines to print.  Range
                  1--1000.  Default 32.

     input:  STDIN
     output: STDOUT

*/
/* tee.c -- UTOOL.  Copy STDIN to STDOUT and named file.

     author: David H. Wolen
     last change: 1/16/83

     usage:  tee [-a] outfile

     options:  -a   append to outfile instead of copying to it

     input:  STDIN
     output: STDOUT and file

     notes:    (a)  if -a and outfile doesn't exist, the
                    option is ignored.
               (b)  if -a, it creates and releases a temp
                    file (temptee.$$$) on the logged drive.

*/
/* tr.c -- UTOOL. Transliterate characters

     author: David H. Wolen
     last change: 12/31/82

     usage:    tr src dest
               tr #A-Z# a-z   (change case)
               tr " \t\n" \n  (make one word per line)
               tr !\n         (delete everything but newlines)
               tr 0-9 9       (change digit strings to single digit 9)


     input:    STDIN
     output:   STDOUT

     notes:    (1) - denotes range
               (2) ! denotes "all but"
               (3) \n (newline) \t (tab) \b (backspace) \r (carr ret)
                   \f (form feed) \p (#) \q (")
               (4) if dest is absent, all chars represented by src are
                   deleted
               (5) if dest is shorter than src, all chars of src that 
                   would map to or beyond last char in dest are mapped
                   to last char in dest.  Adjacent instances of such 
                   chars in src cause a single instance of last char
                   in dest to be output.
               (6) use " " to enclose blanks in src and dest
               (7) use # # to enclose capital letters in src and dest


*/
/*  uniq.c -- UTOOL. Filters out adjacent duplicate lines
          in sorted file.  Lines must be identical
          (including same length) to be filtered out.

     author: David H. Wolen
     last change: 12/2/82

     option:  -c  prefixes each output line with count
     usage:  sort <infile |uniq >outfile -c

     input:    STDIN
     output:   STDOUT

*/
/*  unrot.c -- UTOOL. Unrotate lines rotated by kwic.  Last step
     in making keyword-in-context index.

     author: David H. Wolen
     last change: 12/2/82

     usage: kwic <infile |sort -f |unrot >outfile

     input:   STDIN
     output:  STDOUT
  
*/
/*  utdir.c -- UTOOL.  Sorted file directory.

     author: David H. Wolen
     last change: 6/5/83

     usage:    utdir *.*           all files on current drive
               utdir !*.com        all files on current drive except .com
               utdir b:*.* !b:*.c  all files on b: except .c
               utdir ?.com         all .com files with single letter 
                                        file name on current drive

     options:  none

     input:    command line only
     output:   STDOUT

     notes:    1.  max of 200 files after expansion
               2.  metacharacters in filename:
                    ! except
                    ? wildcard match a single character
                    * wildcard match 1 or more characters

*/
/* vsplit.c -- UTOOL. Vertically split a text file.

     author: David H. Wolen
     last change: 2/20/83

     usage:    vsplit cc col

               vsplit ll 80   (output first 80 cols of each line)
               vsplit lr 10   (delete first 10 cols, output rest)
               vsplit rl 10   (delete last 10 cols, output rest)
               vsplit rr 15   (output last 15 cols)

     options:  ll   split from left, output left part
               lr   split from left, output right part
               rl   split from right, output left part
               rr   split from right, output right part

     input:    STDIN
     output:   STDOUT

     notes:    1. If input line contains only <cr><lf>, so will output
               2. If ll and col > line length, output will be whole line
               3. If lr and col > line length, output will be <cr><lf>
               4. If ll and col <= 0, output will be <cr><lf>
               5. If lr and col <= 0, output will be whole line
               6. If rl and col > line length, output will be <cr><lf>
               7. If rr and col > line length, output will be whole line
               8. If rl and col <= 0, output will be whole line
               9. If rr and col <= 0, output will be <cr><lf>

*/
/*  wc.c -- UTOOL. Count lines, words and characters in 
     standard input.  Can handle Wordstar doc files. 

     author: David H. Wolen
     last change: 9/9/82

     usage: wc <infile

     input:   STDIN
     output:  STDOUT
  
*/
 rl   split from right, output left part
               rr   split from right, output right part

     input:    STDIN
 