[BACK]Return to mdef.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / m4

Annotation of src/usr.bin/m4/mdef.h, Revision 1.23

1.23    ! millert     1: /*     $OpenBSD: mdef.h,v 1.22 2002/04/28 14:37:12 espie Exp $ */
1.2       deraadt     2: /*     $NetBSD: mdef.h,v 1.7 1996/01/13 23:25:27 pk Exp $      */
1.1       deraadt     3:
                      4: /*
                      5:  * Copyright (c) 1989, 1993
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  *
                      8:  * This code is derived from software contributed to Berkeley by
                      9:  * Ozan Yigit at York University.
                     10:  *
                     11:  * Redistribution and use in source and binary forms, with or without
                     12:  * modification, are permitted provided that the following conditions
                     13:  * are met:
                     14:  * 1. Redistributions of source code must retain the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer.
                     16:  * 2. Redistributions in binary form must reproduce the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer in the
                     18:  *    documentation and/or other materials provided with the distribution.
1.23    ! millert    19:  * 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    20:  *    may be used to endorse or promote products derived from this software
                     21:  *    without specific prior written permission.
                     22:  *
                     23:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     24:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     25:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     26:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     27:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     28:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     29:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     30:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     31:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     32:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     33:  * SUCH DAMAGE.
                     34:  *
                     35:  *     @(#)mdef.h      8.1 (Berkeley) 6/6/93
                     36:  */
                     37:
                     38: #define MACRTYPE        1
                     39: #define DEFITYPE        2
                     40: #define EXPRTYPE        3
                     41: #define SUBSTYPE        4
                     42: #define IFELTYPE        5
                     43: #define LENGTYPE        6
                     44: #define CHNQTYPE        7
                     45: #define SYSCTYPE        8
                     46: #define UNDFTYPE        9
                     47: #define INCLTYPE        10
                     48: #define SINCTYPE        11
                     49: #define PASTTYPE        12
                     50: #define SPASTYPE        13
                     51: #define INCRTYPE        14
                     52: #define IFDFTYPE        15
                     53: #define PUSDTYPE        16
                     54: #define POPDTYPE        17
                     55: #define SHIFTYPE        18
                     56: #define DECRTYPE        19
                     57: #define DIVRTYPE        20
                     58: #define UNDVTYPE        21
                     59: #define DIVNTYPE        22
                     60: #define MKTMTYPE        23
                     61: #define ERRPTYPE        24
                     62: #define M4WRTYPE        25
                     63: #define TRNLTYPE        26
                     64: #define DNLNTYPE        27
                     65: #define DUMPTYPE        28
                     66: #define CHNCTYPE        29
                     67: #define INDXTYPE        30
                     68: #define SYSVTYPE        31
                     69: #define EXITTYPE        32
                     70: #define DEFNTYPE        33
1.10      espie      71: #define SELFTYPE       34
1.14      espie      72: #define INDIRTYPE      35
                     73: #define BUILTINTYPE    36
                     74: #define PATSTYPE       37
                     75: #define FILENAMETYPE   38
                     76: #define LINETYPE       39
                     77: #define REGEXPTYPE     40
1.17      espie      78: #define ESYSCMDTYPE    41
1.21      espie      79: #define TRACEONTYPE    42
                     80: #define TRACEOFFTYPE   43
                     81:
1.1       deraadt    82:
1.9       espie      83: #define TYPEMASK       63      /* Keep bits really corresponding to a type. */
                     84: #define RECDEF         256     /* Pure recursive def, don't expand it */
1.11      espie      85: #define NOARGS         512     /* builtin needs no args */
                     86: #define NEEDARGS       1024    /* mark builtin that need args with this */
1.1       deraadt    87:
                     88: /*
                     89:  * m4 special characters
                     90:  */
                     91:
                     92: #define ARGFLAG         '$'
                     93: #define LPAREN          '('
                     94: #define RPAREN          ')'
                     95: #define LQUOTE          '`'
                     96: #define RQUOTE          '\''
                     97: #define COMMA           ','
                     98: #define SCOMMT          '#'
                     99: #define ECOMMT          '\n'
                    100:
                    101: #ifdef msdos
                    102: #define system(str)    (-1)
                    103: #endif
                    104:
                    105: /*
                    106:  * other important constants
                    107:  */
                    108:
1.5       espie     109: #define EOS             '\0'
1.6       espie     110: #define MAXINP          10              /* maximum include files           */
                    111: #define MAXOUT          10              /* maximum # of diversions         */
                    112: #define BUFSIZE         4096            /* starting size of pushback buffer */
1.15      espie     113: #define INITSTACKMAX    4096                   /* starting size of call stack      */
1.16      espie     114: #define STRSPMAX        4096            /* starting size of string space    */
1.18      espie     115: #define MAXTOK          512            /* maximum chars in a tokn          */
1.6       espie     116: #define HASHSIZE        199             /* maximum size of hashtab         */
                    117: #define MAXCCHARS      5               /* max size of comment/quote delim  */
1.1       deraadt   118:
                    119: #define ALL             1
                    120: #define TOP             0
                    121:
                    122: #define TRUE            1
                    123: #define FALSE           0
                    124: #define cycle           for(;;)
                    125:
                    126: /*
                    127:  * m4 data structures
                    128:  */
                    129:
                    130: typedef struct ndblock *ndptr;
                    131:
1.9       espie     132: struct ndblock {               /* hastable structure         */
                    133:        char            *name;  /* entry name..               */
                    134:        char            *defn;  /* definition..               */
                    135:        unsigned int    type;   /* type of the entry..        */
                    136:        unsigned int    hv;     /* hash function value..      */
                    137:        ndptr           nxtptr; /* link to next entry..       */
1.1       deraadt   138: };
                    139:
                    140: #define nil     ((ndptr) 0)
                    141:
                    142: struct keyblk {
                    143:         char    *knam;          /* keyword name */
                    144:         int     ktyp;           /* keyword type */
                    145: };
                    146:
                    147: typedef union {                        /* stack structure */
                    148:        int     sfra;           /* frame entry  */
                    149:        char    *sstr;          /* string entry */
                    150: } stae;
                    151:
1.12      espie     152: struct input_file {
                    153:        FILE            *file;
                    154:        char            *name;
                    155:        unsigned long   lineno;
1.22      espie     156:        unsigned long   synch_lineno;   /* used for -s */
1.12      espie     157:        int             c;
                    158: };
                    159:
                    160: #define CURRENT_NAME   (infile[ilevel].name)
                    161: #define CURRENT_LINE   (infile[ilevel].lineno)
1.1       deraadt   162: /*
                    163:  * macros for readibility and/or speed
                    164:  *
                    165:  *      gpbc()  - get a possibly pushed-back character
                    166:  *      pushf() - push a call frame entry onto stack
                    167:  *      pushs() - push a string pointer onto stack
                    168:  */
1.12      espie     169: #define gpbc()          (bp > bufbase) ? *--bp : obtain_char(infile+ilevel)
1.15      espie     170: #define pushf(x)                       \
                    171:        do {                            \
                    172:                if (++sp == STACKMAX)   \
                    173:                        enlarge_stack();\
                    174:                mstack[sp].sfra = (x);  \
                    175:                sstack[sp] = 0; \
1.20      espie     176:        } while (0)
1.15      espie     177:
                    178: #define pushs(x)                       \
                    179:        do {                            \
                    180:                if (++sp == STACKMAX)   \
                    181:                        enlarge_stack();\
                    182:                mstack[sp].sstr = (x);  \
                    183:                sstack[sp] = 1; \
1.20      espie     184:        } while (0)
1.15      espie     185:
                    186: #define pushs1(x)                      \
                    187:        do {                            \
                    188:                if (++sp == STACKMAX)   \
                    189:                        enlarge_stack();\
                    190:                mstack[sp].sstr = (x);  \
                    191:                sstack[sp] = 0; \
1.20      espie     192:        } while (0)
1.1       deraadt   193:
                    194: /*
                    195:  *         .                              .
                    196:  *     |   .   |  <-- sp               |  .  |
                    197:  *     +-------+                       +-----+
                    198:  *     | arg 3 ----------------------->| str |
                    199:  *     +-------+                       |  .  |
                    200:  *     | arg 2 ---PREVEP-----+            .
                    201:  *     +-------+             |
                    202:  *         .                 |         |     |
                    203:  *     +-------+             |         +-----+
                    204:  *     | plev  |  PARLEV     +-------->| str |
                    205:  *     +-------+                       |  .  |
                    206:  *     | type  |  CALTYP                  .
                    207:  *     +-------+
                    208:  *     | prcf  ---PREVFP--+
                    209:  *     +-------+          |
                    210:  *     |   .   |  PREVSP  |
                    211:  *         .              |
                    212:  *     +-------+          |
                    213:  *     |       <----------+
                    214:  *     +-------+
                    215:  *
                    216:  */
                    217: #define PARLEV  (mstack[fp].sfra)
                    218: #define CALTYP  (mstack[fp-1].sfra)
1.15      espie     219: #define PREVEP (mstack[fp+3].sstr)
1.1       deraadt   220: #define PREVSP (fp-3)
                    221: #define PREVFP (mstack[fp-2].sfra)