aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/m4/mdef.h
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2002-04-19 17:26:21 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2002-04-19 17:26:21 +0000
commitacc9d4083840bce63fb8b3ff7ee8195d8f67d49e (patch)
treee50607d075b4fa99ab7d040c1f22f13cfc865fff /usr.bin/m4/mdef.h
parent29fc00b3fb827a8962ad1b28c740c4bb6ce11e07 (diff)
downloadsrc-acc9d4083840bce63fb8b3ff7ee8195d8f67d49e.tar.gz
src-acc9d4083840bce63fb8b3ff7ee8195d8f67d49e.zip
Bring OpenBSD m4(1) off of the OPENBSD vendor branch, and add the -s option,
$FreeBSD$ identifiers, and fix initialisation to stderr to happen in a function as stderr is not the same in CURRENT as in OpenBSD. Reviewed by: obrien
Notes
Notes: svn path=/head/; revision=95060
Diffstat (limited to 'usr.bin/m4/mdef.h')
-rw-r--r--usr.bin/m4/mdef.h102
1 files changed, 75 insertions, 27 deletions
diff --git a/usr.bin/m4/mdef.h b/usr.bin/m4/mdef.h
index 604833fae485..a886412012d8 100644
--- a/usr.bin/m4/mdef.h
+++ b/usr.bin/m4/mdef.h
@@ -1,3 +1,6 @@
+/* $OpenBSD: mdef.h,v 1.21 2001/09/27 11:40:33 espie Exp $ */
+/* $NetBSD: mdef.h,v 1.7 1996/01/13 23:25:27 pk Exp $ */
+
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -70,13 +73,27 @@
#define SYSVTYPE 31
#define EXITTYPE 32
#define DEFNTYPE 33
-
-#define STATIC 128
+#define SELFTYPE 34
+#define INDIRTYPE 35
+#define BUILTINTYPE 36
+#define PATSTYPE 37
+#define FILENAMETYPE 38
+#define LINETYPE 39
+#define REGEXPTYPE 40
+#define ESYSCMDTYPE 41
+#define TRACEONTYPE 42
+#define TRACEOFFTYPE 43
+
+
+#define TYPEMASK 63 /* Keep bits really corresponding to a type. */
+#define RECDEF 256 /* Pure recursive def, don't expand it */
+#define NOARGS 512 /* builtin needs no args */
+#define NEEDARGS 1024 /* mark builtin that need args with this */
/*
* m4 special characters
*/
-
+
#define ARGFLAG '$'
#define LPAREN '('
#define RPAREN ')'
@@ -94,19 +111,19 @@
* other important constants
*/
-#define EOS (char) 0
-#define MAXINP 10 /* maximum include files */
-#define MAXOUT 10 /* maximum # of diversions */
-#define MAXSTR 512 /* maximum size of string */
-#define BUFSIZE 4096 /* size of pushback buffer */
-#define STACKMAX 1024 /* size of call stack */
-#define STRSPMAX 4096 /* size of string space */
-#define MAXTOK MAXSTR /* maximum chars in a tokn */
-#define HASHSIZE 199 /* maximum size of hashtab */
-
+#define EOS '\0'
+#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 STRSPMAX 4096 /* starting size of string space */
+#define MAXTOK 512 /* maximum chars in a tokn */
+#define HASHSIZE 199 /* maximum size of hashtab */
+#define MAXCCHARS 5 /* max size of comment/quote delim */
+
#define ALL 1
#define TOP 0
-
+
#define TRUE 1
#define FALSE 0
#define cycle for(;;)
@@ -114,18 +131,19 @@
/*
* m4 data structures
*/
-
+
typedef struct ndblock *ndptr;
-
-struct ndblock { /* hastable structure */
- char *name; /* entry name.. */
- char *defn; /* definition.. */
- int type; /* type of the entry.. */
- ndptr nxtptr; /* link to next entry.. */
+
+struct ndblock { /* hastable structure */
+ char *name; /* entry name.. */
+ 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 {
char *knam; /* keyword name */
int ktyp; /* keyword type */
@@ -136,6 +154,15 @@ typedef union { /* stack structure */
char *sstr; /* string entry */
} stae;
+struct input_file {
+ FILE *file;
+ char *name;
+ unsigned long lineno;
+ int c;
+};
+
+#define CURRENT_NAME (infile[ilevel].name)
+#define CURRENT_LINE (infile[ilevel].lineno)
/*
* macros for readibility and/or speed
*
@@ -144,10 +171,31 @@ typedef union { /* stack structure */
* pushs() - push a string pointer onto stack
*/
#define gpbc() (bp > bufbase) ? (*--bp ? *bp : EOF) : \
- ((chscratch = getc(infile[ilevel])) == '\n' && ++inlineno[ilevel], \
- chscratch)
-#define pushf(x) if (sp < STACKMAX) mstack[++sp].sfra = (x)
-#define pushs(x) if (sp < STACKMAX) mstack[++sp].sstr = (x)
+ ((chscratch = obtain_char(infile+ilevel)) == '\n' && \
+ ++inlineno[ilevel], chscratch)
+#define pushf(x) \
+ do { \
+ if (++sp == STACKMAX) \
+ enlarge_stack();\
+ mstack[sp].sfra = (x); \
+ sstack[sp] = 0; \
+ } while (0)
+
+#define pushs(x) \
+ do { \
+ if (++sp == STACKMAX) \
+ enlarge_stack();\
+ mstack[sp].sstr = (x); \
+ sstack[sp] = 1; \
+ } while (0)
+
+#define pushs1(x) \
+ do { \
+ if (++sp == STACKMAX) \
+ enlarge_stack();\
+ mstack[sp].sstr = (x); \
+ sstack[sp] = 0; \
+ } while (0)
/*
* . .