Annotation of 41BSD/cmd/awk/awk.def, revision 1.1.1.1

1.1       root        1: #define hack   int
                      2: #define        AWKFLOAT        float
                      3: #define        xfree(a)        { if(a!=NULL) { yfree(a); a=NULL;} }
                      4: #define yfree free
                      5: #ifdef DEBUG
                      6: #      define  dprintf if(dbg)printf
                      7: #else
                      8: #      define  dprintf(x1, x2, x3, x4)
                      9: #endif
                     10: typedef        AWKFLOAT        awkfloat;
                     11: 
                     12: extern char    **FS;
                     13: extern char    **RS;
                     14: extern char    **ORS;
                     15: extern char    **OFS;
                     16: extern char    **OFMT;
                     17: extern awkfloat *NR;
                     18: extern awkfloat *NF;
                     19: extern char    **FILENAME;
                     20: 
                     21: extern char    record[];
                     22: extern int     dbg;
                     23: extern int     lineno;
                     24: extern int     errorflag;
                     25: extern int     donefld;        /* 1 if record broken into fields */
                     26: extern int     donerec;        /* 1 if record is valid (no fld has changed */
                     27: 
                     28: typedef struct val {   /* general value during processing */
                     29:        char    *nval;  /* name, for variables only */
                     30:        char    *sval;  /* string value */
                     31:        awkfloat        fval;   /* value as number */
                     32:        unsigned        tval;   /* type info */
                     33:        struct val      *nextval;       /* ptr to next if chained */
                     34: } cell;
                     35: extern cell *symtab[];
                     36: cell   *setsymtab(), *lookup(), **makesymtab();
                     37: 
                     38: extern cell    *recloc;        /* location of input record */
                     39: extern cell    *nrloc;         /* NR */
                     40: extern cell    *nfloc;         /* NF */
                     41: 
                     42: #define        STR     01      /* string value is valid */
                     43: #define        NUM     02      /* number value is valid */
                     44: #define FLD    04      /* FLD means don't free string space */
                     45: #define        CON     010     /* this is a constant */
                     46: #define        ARR     020     /* this is an array */
                     47: 
                     48: awkfloat setfval(), getfval();
                     49: char   *setsval(), *getsval();
                     50: char   *tostring(), *tokname(), *malloc();
                     51: double log(), sqrt(), exp(), atof();
                     52: 
                     53: /* function types */
                     54: #define        FLENGTH 1
                     55: #define        FSQRT   2
                     56: #define        FEXP    3
                     57: #define        FLOG    4
                     58: #define        FINT    5
                     59: 
                     60: typedef struct {
                     61:        char otype;
                     62:        char osub;
                     63:        cell *optr;
                     64: } obj;
                     65: 
                     66: #define BOTCH  1
                     67: struct nd {
                     68:        char ntype;
                     69:        char subtype;
                     70:        struct nd *nnext;
                     71:        int nobj;
                     72:        struct nd *narg[BOTCH]; /* C won't take a zero length array */
                     73: };
                     74: typedef struct nd node;
                     75: extern node    *winner;
                     76: extern node    *nullstat;
                     77: 
                     78: /* otypes */
                     79: #define OCELL  0
                     80: #define OEXPR  1
                     81: #define OBOOL  2
                     82: #define OJUMP  3
                     83: 
                     84: /* cell subtypes */
                     85: #define CTEMP  4
                     86: #define CNAME  3 
                     87: #define CVAR   2
                     88: #define CFLD   1
                     89: #define CCON   0
                     90: 
                     91: /* bool subtypes */
                     92: #define BTRUE  1
                     93: #define BFALSE 2
                     94: 
                     95: /* jump subtypes */
                     96: #define JEXIT  1
                     97: #define JNEXT  2
                     98: #define        JBREAK  3
                     99: #define        JCONT   4
                    100: 
                    101: /* node types */
                    102: #define NVALUE 1
                    103: #define NSTAT  2
                    104: #define NEXPR  3
                    105: #define NPA2   4
                    106: 
                    107: extern obj     (*proctab[])();
                    108: extern obj     true, false;
                    109: extern int     pairstack[], paircnt;
                    110: 
                    111: #define cantexec(n)    (n->ntype == NVALUE)
                    112: #define notlegal(n)    (n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN]== nullproc)
                    113: #define isexpr(n)      (n->ntype == NEXPR)
                    114: #define isjump(n)      (n.otype == OJUMP)
                    115: #define isexit(n)      (n.otype == OJUMP && n.osub == JEXIT)
                    116: #define        isbreak(n)      (n.otype == OJUMP && n.osub == JBREAK)
                    117: #define        iscont(n)       (n.otype == OJUMP && n.osub == JCONT)
                    118: #define        isnext(n)       (n.otype == OJUMP && n.osub == JNEXT)
                    119: #define isstr(n)       (n.optr->tval & STR)
                    120: #define istrue(n)      (n.otype == OBOOL && n.osub == BTRUE)
                    121: #define istemp(n)      (n.otype == OCELL && n.osub == CTEMP)
                    122: #define isfld(n)       (!donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval==0)
                    123: #define isrec(n)       (donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval!=0)
                    124: obj    nullproc();
                    125: obj    relop();
                    126: 
                    127: #define MAXSYM 50
                    128: #define        HAT     0177    /* matches ^ in regular expr */
                    129:                        /* watch out for mach dep */

unix.superglobalmegacorp.com

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