diff options
author | bapt <bapt@FreeBSD.org> | 2011-11-28 13:32:39 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2011-11-28 13:32:39 +0000 |
commit | 0d5c584942b4969017d0bf120398070c8fd2f97a (patch) | |
tree | 5de96cd08140867e02d44da62c0ad8d89e243890 /usr.bin/m4/mdef.h | |
parent | 273ffa0653ea7a2d8c5cf90c7625a5e3915bb9f3 (diff) | |
download | FreeBSD-src-0d5c584942b4969017d0bf120398070c8fd2f97a.zip FreeBSD-src-0d5c584942b4969017d0bf120398070c8fd2f97a.tar.gz |
Synchronize with laster version of m4 from OpenBSD and NetBSD
This bring better compatibility with gnum4
Reviewed by: cognet
Approved by: cognet
Obtained from: OpenBSD, NetBSD
Diffstat (limited to 'usr.bin/m4/mdef.h')
-rw-r--r-- | usr.bin/m4/mdef.h | 100 |
1 files changed, 55 insertions, 45 deletions
diff --git a/usr.bin/m4/mdef.h b/usr.bin/m4/mdef.h index ff19a34..0db78ef 100644 --- a/usr.bin/m4/mdef.h +++ b/usr.bin/m4/mdef.h @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -16,7 +16,7 @@ * 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. - * 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. * @@ -36,6 +36,12 @@ * $FreeBSD$ */ +#ifdef __GNUC__ +# define UNUSED __attribute__((__unused__)) +#else +# define UNUSED +#endif + #define MACRTYPE 1 #define DEFITYPE 2 #define EXPRTYPE 3 @@ -79,7 +85,9 @@ #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 */ @@ -108,13 +116,12 @@ */ #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 @@ -130,31 +137,31 @@ 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) @@ -162,31 +169,33 @@ struct input_file { /* * 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) /* @@ -195,25 +204,26 @@ struct input_file { * +-------+ +-----+ * | 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 CALTYP (mstack[fp-2].sfra) +#define TRACESTATUS (mstack[fp-1].sfra) #define PREVEP (mstack[fp+3].sstr) -#define PREVSP (fp-3) -#define PREVFP (mstack[fp-2].sfra) +#define PREVSP (fp-4) +#define PREVFP (mstack[fp-3].sfra) |