Annotation of researchv10no/cmd/prefer/prefawk/awk.h, revision 1.1

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

unix.superglobalmegacorp.com

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