diff options
Diffstat (limited to 'generic/regguts.h')
| -rw-r--r-- | generic/regguts.h | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/generic/regguts.h b/generic/regguts.h index 62ab889..cd14df5 100644 --- a/generic/regguts.h +++ b/generic/regguts.h @@ -49,15 +49,46 @@ #include <assert.h> #endif +/* voids */ +#ifndef VOID +#define VOID void /* for function return values */ +#endif +#ifndef DISCARD +#define DISCARD void /* for throwing values away */ +#endif +#ifndef PVOID +#define PVOID void * /* generic pointer */ +#endif +#ifndef VS +#define VS(x) ((void*)(x)) /* cast something to generic ptr */ +#endif +#ifndef NOPARMS +#define NOPARMS void /* for empty parm lists */ +#endif + +/* const */ +#ifndef CONST +#define CONST const /* for old compilers, might be empty */ +#endif + +/* function-pointer declarator */ +#ifndef FUNCPTR +#if __STDC__ >= 1 +#define FUNCPTR(name, args) (*name)args +#else +#define FUNCPTR(name, args) (*name)() +#endif +#endif + /* memory allocation */ #ifndef MALLOC #define MALLOC(n) malloc(n) #endif #ifndef REALLOC -#define REALLOC(p, n) realloc(p, n) +#define REALLOC(p, n) realloc(VS(p), n) #endif #ifndef FREE -#define FREE(p) free(p) +#define FREE(p) free(VS(p)) #endif /* want size of a char in bits, and max value in bounded quantifiers */ @@ -70,11 +101,12 @@ */ #define NOTREACHED 0 +#define xxx 1 #define DUPMAX _POSIX2_RE_DUP_MAX #define DUPINF (DUPMAX+1) -#define REMAGIC 0xFED7 /* magic number for main struct */ +#define REMAGIC 0xfed7 /* magic number for main struct */ /* * debugging facilities @@ -258,10 +290,10 @@ struct state { }; struct nfa { - struct state *pre; /* preinitial state */ + struct state *pre; /* pre-initial state */ struct state *init; /* initial state */ struct state *final; /* final state */ - struct state *post; /* postfinal state */ + struct state *post; /* post-final state */ int nstates; /* for numbering states */ struct state *states; /* state-chain header */ struct state *slast; /* tail of the chain */ @@ -381,7 +413,7 @@ struct subre { */ struct fns { - void (*free) (regex_t *); + VOID FUNCPTR(free, (regex_t *)); }; /* @@ -390,7 +422,7 @@ struct fns { struct guts { int magic; -#define GUTSMAGIC 0xFED9 +#define GUTSMAGIC 0xfed9 int cflags; /* copy of compile flags */ long info; /* copy of re_info */ size_t nsub; /* copy of re_nsub */ @@ -398,7 +430,7 @@ struct guts { struct cnfa search; /* for fast preliminary search */ int ntree; /* number of subre's, plus one */ struct colormap cmap; - int (*compare) (const chr *, const chr *, size_t); + int FUNCPTR(compare, (CONST chr *, CONST chr *, size_t)); struct subre *lacons; /* lookahead-constraint vector */ int nlacons; /* size of lacons */ }; @@ -411,7 +443,7 @@ struct guts { #ifndef AllocVars #define AllocVars(vPtr) \ struct vars var; \ - struct vars *vPtr = &var + register struct vars *vPtr = &var #endif #ifndef FreeVars #define FreeVars(vPtr) ((void) 0) |
