Annotation of researchv8dc/cmd/awk/awk.h, revision 1.1.1.1

1.1       root        1: 
                      2: #ifdef MYALLOC
                      3:        extern char *Malloc(), *Calloc();
                      4: #else
                      5: #      define  Malloc  malloc
                      6: #      define  Calloc  calloc
                      7: #      define  Free    free
                      8: #endif
                      9: 
                     10: #define        xfree(a)        { if ((a) != NULL) { Free(a); a=NULL;} }
                     11: 
                     12: #ifdef DEBUG
                     13: #      define  dprintf if(dbg)printf
                     14: #else
                     15: #      define  dprintf(x1, x2, x3, x4)
                     16: #endif
                     17: 
                     18: #define        RECSIZE (3 * 1024)      /* sets limit on records, fields, etc., etc. */
                     19: 
                     20: typedef double Awkfloat;
                     21: 
                     22: extern char    **FS;
                     23: extern char    **RS;
                     24: extern char    **ORS;
                     25: extern char    **OFS;
                     26: extern char    **OFMT;
                     27: extern Awkfloat *NR;
                     28: extern Awkfloat *FNR;
                     29: extern Awkfloat *NF;
                     30: extern char    **FILENAME;
                     31: 
                     32: extern char    *record;
                     33: extern int     dbg;
                     34: extern int     lineno;
                     35: extern int     errorflag;
                     36: extern int     donefld;        /* 1 if record broken into fields */
                     37: extern int     donerec;        /* 1 if record is valid (no fld has changed */
                     38: 
                     39: /* Cell:  all information about a variable or constant */
                     40: 
                     41: typedef struct Cell {
                     42:        char    ctype;          /* OCELL, OBOOL, OJUMP, etc. */
                     43:        char    csub;           /* CCON, CTEMP, CFLD, etc. */
                     44:        char    *nval;          /* name, for variables only */
                     45:        char    *sval;          /* string value */
                     46:        Awkfloat fval;          /* value as number */
                     47:        unsigned tval;          /* type info: STR|NUM|ARR|FCN|FLD|CON|DONTFREE */
                     48:        struct Cell *cnext;     /* ptr to next if chained */
                     49: } Cell;
                     50: 
                     51: extern Cell    *symtab[];
                     52: extern Cell    *setsymtab(), *lookup(), **makesymtab();
                     53: 
                     54: extern Cell    *recloc;        /* location of input record */
                     55: extern Cell    *nrloc;         /* NR */
                     56: extern Cell    *fnrloc;        /* FNR */
                     57: extern Cell    *nfloc;         /* NF */
                     58: 
                     59: /* Cell.tval values: */
                     60: #define        NUM     01      /* number value is valid */
                     61: #define        STR     02      /* string value is valid */
                     62: #define DONTFREE 04    /* string space is not freeable */
                     63: #define        CON     010     /* this is a constant */
                     64: #define        ARR     020     /* this is an array */
                     65: #define        FCN     040     /* this is a function name */
                     66: #define FLD    0100    /* this is a field $1, $2, ... */
                     67: #define        REC     0200    /* this is $0 */
                     68: 
                     69: #define freeable(p)    (!((p)->tval & DONTFREE))
                     70: 
                     71: Awkfloat setfval(), getfval();
                     72: char   *setsval(), *getsval();
                     73: char   *tostring(), *tokname(), *malloc(), *calloc();
                     74: double log(), sqrt(), exp(), atof();
                     75: 
                     76: /* function types */
                     77: #define        FLENGTH 1
                     78: #define        FSQRT   2
                     79: #define        FEXP    3
                     80: #define        FLOG    4
                     81: #define        FINT    5
                     82: #define        FSYSTEM 6
                     83: #define        FRAND   7
                     84: #define        FSRAND  8
                     85: #define        FSIN    9
                     86: #define        FCOS    10
                     87: #define        FATAN   11
                     88: 
                     89: /* Node:  parse tree is made of nodes, with Cell's at bottom */
                     90: 
                     91: typedef struct Node {
                     92:        int     ntype;
                     93:        struct  Node *nnext;
                     94:        int     lineno;
                     95:        int     nobj;
                     96:        struct Node *narg[1];   /* variable: actual size set by calling malloc */
                     97: } Node;
                     98: 
                     99: extern Node    *winner;
                    100: extern Node    *nullstat;
                    101: 
                    102: 
                    103: /* ctypes */
                    104: #define OCELL  1
                    105: #define OBOOL  2
                    106: #define OJUMP  3
                    107: 
                    108: /* Cell subtypes: csub */
                    109: #define CCOPY  6
                    110: #define CCON   5
                    111: #define CTEMP  4
                    112: #define CNAME  3 
                    113: #define CVAR   2
                    114: #define CFLD   1
                    115: 
                    116: /* bool subtypes */
                    117: #define BTRUE  11
                    118: #define BFALSE 12
                    119: 
                    120: /* jump subtypes */
                    121: #define JEXIT  21
                    122: #define JNEXT  22
                    123: #define        JBREAK  23
                    124: #define        JCONT   24
                    125: #define        JRET    25
                    126: 
                    127: /* node types */
                    128: #define NVALUE 1
                    129: #define NSTAT  2
                    130: #define NEXPR  3
                    131: #define        NFIELD  4
                    132: 
                    133: extern Cell    *(*proctab[])();
                    134: extern Cell    *nullproc();
                    135: extern Cell    *relop();
                    136: extern int     pairstack[], paircnt;
                    137: 
                    138: #define notlegal(n)    (n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN] == nullproc)
                    139: #define isvalue(n)     ((n)->ntype == NVALUE)
                    140: #define isexpr(n)      ((n)->ntype == NEXPR)
                    141: #define isjump(n)      ((n)->ctype == OJUMP)
                    142: #define isexit(n)      ((n)->csub == JEXIT)
                    143: #define        isbreak(n)      ((n)->csub == JBREAK)
                    144: #define        iscont(n)       ((n)->csub == JCONT)
                    145: #define        isnext(n)       ((n)->csub == JNEXT)
                    146: #define        isret(n)        ((n)->csub == JRET)
                    147: #define isstr(n)       ((n)->tval & STR)
                    148: #define isnum(n)       ((n)->tval & NUM)
                    149: #define isarr(n)       ((n)->tval & ARR)
                    150: #define isfunc(n)      ((n)->tval & FCN)
                    151: #define istrue(n)      ((n)->csub == BTRUE)
                    152: #define istemp(n)      ((n)->csub == CTEMP)
                    153: 
                    154: #define MAXSYM 50
                    155: #define        HAT     0177    /* matches ^ in regular expr */
                    156: #define NCHARS 128
                    157: #define NSTATES        16
                    158: typedef struct fcell {
                    159:        int info;
                    160:        struct fcell *link;
                    161: } fcell;
                    162: 
                    163: typedef struct rrow {
                    164:        int ltype;
                    165:        int lval;
                    166:        fcell *lfollow;
                    167: } rrow;
                    168: 
                    169: typedef struct fa {
                    170:        char gototab[NSTATES][NCHARS];
                    171:        fcell *posns[NSTATES];
                    172:        char out[NSTATES];
                    173:        char initstat;
                    174:        char curstat;
                    175:        char accept;
                    176:        char reset;
                    177:        struct rrow re[1];
                    178: } fa;

unix.superglobalmegacorp.com

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