Annotation of researchv10no/cmd/awk/NEW, revision 1.1.1.1

1.1       root        1: NEW Oct 87:
                      2: 
                      3:        New functions toupper(s) and tolower(s) that return
                      4:        the case-converted version of s.
                      5: 
                      6: NEW Jul 87:
                      7: 
                      8:        Array sizes are dynamic: hash table grows as elements are added.
                      9: 
                     10:        Dynamic regular expressions are cached, up to some limit.
                     11: 
                     12: NEW Jun 87:
                     13: 
                     14:        Fixed split() so that does split(s,t,/r/) properly;
                     15:        fixed index(s,/r/) to be an error), since it's wrong.
                     16: 
                     17:        String value of a numeric constant is the input representation.
                     18: 
                     19: NEW Sept 86:
                     20: 
                     21:        Changed order of evaluation of x = y to do rhs first
                     22: 
                     23:        New array SYMTAB, the symbol table.
                     24:        not documented, local pleading only
                     25: 
                     26:        -S and -R are officially deprecated;  they can't work
                     27: 
                     28: NEW June 86:
                     29: 
                     30:        if ((i,j,k) in array) ... now works.
                     31: 
                     32: NEW Apr 86:
                     33: 
                     34:        Pattern action statements can occur on a single line
                     35:        if separated by semicolons.
                     36: 
                     37:        Grammar revised to eliminate many ambiguities caused
                     38:        by abuse of > sign.  As a result, constructs like
                     39:                print a > b c
                     40:        are syntactically illegal; parens are required.
                     41: 
                     42: NEW Jan 86:
                     43: 
                     44:        new function  match(s, re)  returns position
                     45:        in s where re occurs (origin 1) or 0 if not.
                     46:        new variables RSTART set to pos and RLENGTH
                     47:        to length of matched string.
                     48: 
                     49: NEW Dec 85:
                     50: 
                     51:        fixed comment handling so can have
                     52:                ...,    # comment
                     53: 
                     54:        added ?: operator
                     55: 
                     56:        added do-while as in C
                     57: 
                     58:        arr[i,j], etc., works.  Components separated by SUBSEP,
                     59:        initialized to \034.
                     60: 
                     61: WISH LIST:
                     62: 
                     63:        save compiled state
                     64:        lazy field evaluation
                     65:        type decls
                     66:        scanf
                     67:        access to run-time fcns
                     68:        c output, link to c
                     69:        char fcns, left side fcns (e.g., lsubstr)
                     70:        begin & end in patterns
                     71:        limits on arrays, etc., ought to be dynamic instead of static.
                     72: 
                     73: 
                     74: CHANGES SO FAR (Jul 85):
                     75: 
                     76: added & in replacement of sub() and gsub();  use \& to quote it
                     77: 
                     78: mutiple BEGIN's and END's concatenated
                     79: 
                     80: replaced error reporting mechanism
                     81: 
                     82: "function" is a synonym for "func"
                     83: 
                     84: "delete array[elem]" removes elem from array
                     85: 
                     86: Fixed bug in field handling for ~ 25% speed up.
                     87: 
                     88: Augmented the getline function:
                     89:        getline
                     90:                sets $0, NR, NF, $1..., from next input record
                     91:        getline x
                     92:                sets x from next input record, sets NR,
                     93:                but NOT $0, NF, etc.
                     94:        getline < "foo"
                     95:                sets $0 from file foo.  sets NF, $1...,
                     96:                but NOT NR
                     97:        getline x < "foo"
                     98:                sets x from foo.  no effect on $0, NF, NR, etc.
                     99: 
                    100:        Files are as for print; they are matched by name,
                    101:        and remain open until explicitly closed.
                    102:        Input pipes work;  syntax is
                    103:                "whatever" | getline
                    104:                "something" | getline x
                    105:        (This adds a reduce/reduce conflict
                    106:        to the grammar, so it may be a bad idea.)
                    107: 
                    108:        getline returns 0 on EOF, -1 on error, >0 normally
                    109: 
                    110: Added close function:
                    111:        close("foo") calls fclose for right file or pclose for pipe
                    112: 
                    113: Added sub(regexp, replacement, str) and gsub(...).
                    114:        Substitutes replacement for leftmost occurrence
                    115:        of regexpr in str, or in $0 if no str supplied.
                    116:        Gsub substitutes for all.  Number of changes
                    117:        is returned.
                    118: 
                    119: Regular expressions can be dynamic.  Any constant string
                    120:        or variable can be used as a regular expression
                    121:        in sub(), gsub, or after ~ and !~.
                    122: 
                    123: Field separators can be regular expressions, both in FS
                    124:        and as the 3rd argument of split().
                    125: 
                    126: Added "i in arr" condition, for if (...) and patterns.
                    127:        i in arr  is true if arr[i] has been defined.
                    128:        Note that this is different from asking if
                    129:        arr[n] == i for some i!  We are searching for
                    130:        a subscript, not a value.
                    131: 
                    132: terminal i/o, eg stderr
                    133:        at least for output, no change needed:
                    134:        print | "cat -u 1>&2"
                    135:        can only have one of these active at one time.
                    136: 
                    137: ARGC and ARGV[] exist, essentially as in C.
                    138:        ARGC is the number of arguments including the program name.
                    139:        ARGV[0]..ARGV[ARGC-1] are the arguments
                    140:        These can be modified in any way at any time.
                    141:        If an ARGV[i] for i>0 is not null, it is assumed to be
                    142:        the name of a file and is opened in the normal sequence.
                    143:        New members of ARGV can be added dynamically beyond the
                    144:        ones currently processed.
                    145:        The argument '-' is added when input is stdin.
                    146: 
                    147: 
                    148: added system(), rand(), srand(), sin, cos, atan2
                    149: 
                    150: added variable FNR -- line number in current file
                    151:        can test FNR == 1 to see if in new file
                    152: 
                    153: Fixed so that \f, \b, \r, \ddd work in strings as in C
                    154: 
                    155: Functions are in:
                    156:        recursive
                    157:        arguments are call by value for scalars, by ref for arrays
                    158:        declaration is
                    159:                func f(arg list) statement
                    160:                        arguments by name
                    161:        arguments are local;  all others global
                    162:        return [expr]
                    163: 
                    164: Order rules relaxed:
                    165:        BEGIN, END, func declarations can occur anywhere a pattern can.
                    166: 
                    167: Added check when syntax error encountered,
                    168:        for better identification of some errors.
                    169:        Other error messages better.  Line number in source
                    170:        and input line line both given for dynamic errors.
                    171:        Some previously uncaught things now flagged
                    172:        e.g.    print <= "foo"
                    173:                print > foo (where foo is null)
                    174:        detects calls of undefined functions, like foo(bar)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.