home *** CD-ROM | disk | FTP | other *** search
- This is the first step in upgrading GAWK to AWK as described in the "AWK
- Programming Language" (Aho, Kernighan, Weinberger; Addison Wesley 1988).
-
- The major differences between previous versions of GAWK and New GAWK include
-
- 1. New math functions
- a. atan2(y,x) - arctangent of y/x in radians
- b. cos(x) - cosine of x (angle in radians)
- c. sin(x) - sine of x
- d. rand() - generate random number
- e. srand(x) - set new seed for random number generator;
- uses time of day if no x given
-
- 2. New string functions
- a. match(s,r) - index of where s matches r or 0 if no match;
- set RSTART and RLENGTH variables
- b. gsub(r,s,t) - globally substitute s for each substring of t
- matched by r, returns number of substitutions;
- if t is omitted $0 is used
- c. sub(r,s,t) - like gsub but only the first match is substituted
-
- 3. New input/output functions
- a. close(expr) - closed file expr
- b. system(cmd-line) - executes command cmd-line at OS level
- c. getline - set fields, NF, NR, FNR from next input record
- d. getline <file - set fields, NF from next record of file
- e. getline var - set var, NR, FNR from next input record
- f. getline var <file - set var from next record of file
-
- 4. New variables
- a. ARGC - number of command line args
- b. ARGV - array of command line args. (ARGV[0..ARGC-1])
- c. FNR - input record number of current file
- d. RLENGTH - length of string matched by RE in match()
- e. RSTART - position of string matched by RE in match()
- 5. Regular expressions will now work properly on MSDOS (16 bit) machines
- 6. Obstack stuff cleaned up to work with Large model compiles
- 7. %f format in printf now seems to work (maybe %e too, but not tested)
- 8. A ';' will parse as a statement terminator.
- 9. Will no longer open input files if no patterns or actions to perform
- 10. FS is treated as a regular expression if longer than 1 character
- 11. Expressions will be translated into regular expressions (as needed)
- in patterns
- 12. Conditional expressions (cond ? exp : exp) have been added
- 13. A '-' will be accepted as stdin for program (i.e. awk -f - file; will
- read program from stdin. This helps work around the MSDOS-OS/2
- command line length limitation)
- 14.
-
-
- NOTES
- 1. Comments have been added to source files for all changes.
- 2. I am including both the original grammar file as well as the new
- grammar. I had to redo parts of the grammar and didn't feel
- like trying to annotate the changes. (I am not sure how this
- fits in with the FSF software license).
- 3. If you use the BISON from CONSULT in protected mode to recompile
- the grammar, note that it does not unlink temporary files. There
- was a recent thread in MSSYS on unlink not functioning on open
- files in protected mode.
- 4. The grammar still generates 20-odd shift/reduce conflicts. This
- should be cleaned up some but it doesn't seem to do the unexpected
- so maybe it is ok.
-
- FUTURE PLANS
- 1. The major addition will have to be user-defined functions. I have
- a few ideas on how to do this, but if anyone else wants to try or
- simply advise, feel free.
- 2. Pseudo-multidimensional arrays are not yet available (and the SUBSEP
- variable). I haven't even looked at this yet.
- 3. Output to a pipe hasn't been implemented yet. This should is trivial
- under UN*X (simply #define UNIX). It might be easy under OS/2 (just
- write a popen function using DosMakePipe). It may not be worth doing
- under MSDOS (maybe using temprorary files with some code to close the
- the files and system() the command with redirection from the file).
- 4. Input from a pipe (to getline) has not been implemented yet. This may
- or may not be easy (see above).
- 5. Multi-record input may or may not work. It has not been tested at all.
- [Actually, they do partially work; need to add code to use '\n' as a
- field seperator when RS = "" -ade 07/18/88-].
-
- FILES
- awk.y - grammar for awk
- awk1.c - expression tree constructors and main program
- awk2.c - parse tree interpreter
- awk3.c - builtin functions and utility procedures
- debug.c - debugging routines
- obstack.c - object stack functions
- regex.c - regular expression functions (except regsub)
- awk.h - awk header file
- obstack.h - obstack header file
- regex.h - regular expressions header file
- ogawk.y - original gawk grammar
- awk.exe - large model bound awk program
- copying - Free Software Foundation licensing stuff
- readme.doc - Steve Liberty's readme file
- readme2.doc - this file
- gawk - awk makefile (I don't use Microsoft's make so you may have
- to modify this file slightly)
-
-
- Please send any problems or comments to:
- Andy Estes 73076,2737
-