-/* $OpenBSD: mdef.h,v 1.21 2001/09/27 11:40:33 espie Exp $ */
+/* $OpenBSD: mdef.h,v 1.31 2011/09/27 07:24:02 espie Exp $ */
/* $NetBSD: mdef.h,v 1.7 1996/01/13 23:25:27 pk Exp $ */
/*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* SUCH DAMAGE.
*
* @(#)mdef.h 8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.bin/m4/mdef.h,v 1.10 2002/07/15 02:15:12 jmallett Exp $
- * $DragonFly: src/usr.bin/m4/mdef.h,v 1.3 2006/12/27 21:29:02 pavalos Exp $
+ * $FreeBSD: src/usr.bin/m4/mdef.h,v 1.13 2012/11/17 01:54:24 svnexp Exp $
*/
#define MACRTYPE 1
#define ESYSCMDTYPE 41
#define TRACEONTYPE 42
#define TRACEOFFTYPE 43
+#define FORMATTYPE 44
+#define BUILTIN_MARKER "__builtin_"
#define TYPEMASK 63 /* Keep bits really corresponding to a type. */
#define RECDEF 256 /* Pure recursive def, don't expand it */
*/
#define EOS '\0'
-#define MAXINP 10 /* maximum include files */
-#define MAXOUT 10 /* maximum # of diversions */
+#define MAXINP 10 /* maximum include files */
+#define MAXOUT 10 /* maximum # of diversions */
#define BUFSIZE 4096 /* starting size of pushback buffer */
-#define INITSTACKMAX 4096 /* starting size of call stack */
+#define INITSTACKMAX 4096 /* starting size of call stack */
#define STRSPMAX 4096 /* starting size of string space */
-#define MAXTOK 512 /* maximum chars in a tokn */
-#define HASHSIZE 199 /* maximum size of hashtab */
+#define MAXTOK 512 /* maximum chars in a tokn */
#define MAXCCHARS 5 /* max size of comment/quote delim */
#define ALL 1
#define TRUE 1
#define FALSE 0
-#define cycle for(;;)
/*
* m4 data structures
typedef struct ndblock *ndptr;
-struct ndblock { /* hastable structure */
- char *name; /* entry name.. */
+struct macro_definition {
+ struct macro_definition *next;
char *defn; /* definition.. */
unsigned int type; /* type of the entry.. */
- unsigned int hv; /* hash function value.. */
- ndptr nxtptr; /* link to next entry.. */
};
-#define nil ((ndptr) 0)
-struct keyblk {
- const char *knam; /* keyword name */
- int ktyp; /* keyword type */
+struct ndblock { /* hashtable structure */
+ unsigned int builtin_type;
+ unsigned int trace_flags;
+ struct macro_definition *d;
+ char name[1]; /* entry name.. */
};
typedef union { /* stack structure */
int sfra; /* frame entry */
- char *sstr; /* string entry */
+ char *sstr; /* string entry */
} stae;
struct input_file {
- FILE *file;
- char *name;
- unsigned long lineno;
- int c;
+ FILE *file;
+ char *name;
+ unsigned long lineno;
+ unsigned long synch_lineno; /* used for -s */
+ int c;
};
#define CURRENT_NAME (infile[ilevel].name)
/*
* macros for readibility and/or speed
*
+ * gpbc() - get a possibly pushed-back character
* pushf() - push a call frame entry onto stack
* pushs() - push a string pointer onto stack
*/
-#define pushf(x) \
- do { \
- if ((uintptr_t)++sp == STACKMAX) \
- enlarge_stack(); \
- mstack[sp].sfra = (x); \
- sstack[sp] = 0; \
+#define gpbc() (bp > bufbase) ? *--bp : obtain_char(infile+ilevel)
+#define pushf(x) \
+ do { \
+ if (++sp == (int)STACKMAX) \
+ enlarge_stack();\
+ mstack[sp].sfra = (x); \
+ sstack[sp] = 0; \
} while (0)
-#define pushs(x) \
- do { \
- if ((uintptr_t)++sp == STACKMAX) \
- enlarge_stack(); \
- mstack[sp].sstr = (x); \
- sstack[sp] = 1; \
+#define pushs(x) \
+ do { \
+ if (++sp == (int)STACKMAX) \
+ enlarge_stack();\
+ mstack[sp].sstr = (x); \
+ sstack[sp] = 1; \
} while (0)
-#define pushs1(x) \
- do { \
- if ((uintptr_t)++sp == STACKMAX) \
- enlarge_stack(); \
- mstack[sp].sstr = (x); \
- sstack[sp] = 0; \
+#define pushs1(x) \
+ do { \
+ if (++sp == (int)STACKMAX) \
+ enlarge_stack();\
+ mstack[sp].sstr = (x); \
+ sstack[sp] = 0; \
} while (0)
/*
* +-------+ +-----+
* | arg 3 ----------------------->| str |
* +-------+ | . |
- * | arg 2 ---PREVEP-----+ .
+ * | arg 2 ---PREVEP-----+ .
* +-------+ |
* . | | |
- * +-------+ | +-----+
+ * +-------+ | +-----+
* | plev | PARLEV +-------->| str |
* +-------+ | . |
* | type | CALTYP .
* +-------+
* | prcf ---PREVFP--+
- * +-------+ |
+ * +-------+ |
* | . | PREVSP |
- * . |
+ * . |
* +-------+ |
* | <----------+
* +-------+
*
*/
#define PARLEV (mstack[fp].sfra)
-#define CALTYP (mstack[fp-1].sfra)
-#define PREVEP (mstack[fp+3].sstr)
-#define PREVSP (fp-3)
-#define PREVFP (mstack[fp-2].sfra)
+#define CALTYP (mstack[fp - 2].sfra)
+#define TRACESTATUS (mstack[fp - 1].sfra)
+#define PREVEP (mstack[fp + 3].sstr)
+#define PREVSP (fp - 4)
+#define PREVFP (mstack[fp - 3].sfra)