diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2010-09-07 19:58:10 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2010-09-07 19:58:10 +0000 |
commit | 33681dd210d7f8d8de0c69fbfaeca5b2946527ae (patch) | |
tree | 7f5cb6675f12a57a7b23c51ba7773f26f31051dc /usr.bin/m4 | |
parent | 05a383ed1a02b670c073c4ebe960fccb1632ea1d (diff) |
Remove stray spaces. No code change.
Diffstat (limited to 'usr.bin/m4')
-rw-r--r-- | usr.bin/m4/eval.c | 32 | ||||
-rw-r--r-- | usr.bin/m4/expr.c | 4 | ||||
-rw-r--r-- | usr.bin/m4/extern.h | 29 | ||||
-rw-r--r-- | usr.bin/m4/gnum4.c | 72 | ||||
-rw-r--r-- | usr.bin/m4/look.c | 27 | ||||
-rw-r--r-- | usr.bin/m4/main.c | 70 | ||||
-rw-r--r-- | usr.bin/m4/mdef.h | 60 | ||||
-rw-r--r-- | usr.bin/m4/misc.c | 30 | ||||
-rw-r--r-- | usr.bin/m4/stdd.h | 8 | ||||
-rw-r--r-- | usr.bin/m4/trace.c | 16 |
10 files changed, 173 insertions, 175 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c index c920e8b73af..b6a790e68ba 100644 --- a/usr.bin/m4/eval.c +++ b/usr.bin/m4/eval.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eval.c,v 1.67 2010/03/25 18:52:29 espie Exp $ */ +/* $OpenBSD: eval.c,v 1.68 2010/09/07 19:58:09 marco Exp $ */ /* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */ /* @@ -100,7 +100,7 @@ eval(const char *argv[], int argc, int td, int is_traced) size_t mark = SIZE_MAX; expansion_id++; - if (td & RECDEF) + if (td & RECDEF) m4errx(1, "expanding recursive definition for %s.", argv[1]); if (is_traced) mark = trace(argv, argc, infile+ilevel); @@ -108,7 +108,7 @@ eval(const char *argv[], int argc, int td, int is_traced) expand_macro(argv, argc); else expand_builtin(argv, argc, td); - if (mark != SIZE_MAX) + if (mark != SIZE_MAX) finish_trace(mark); } @@ -137,7 +137,7 @@ expand_builtin(const char *argv[], int argc, int td) /* we keep the initial value for those built-ins that differentiate * between builtin() and builtin. */ - ac = argc; + ac = argc; if (argc == 3 && !*(argv[2]) && !mimic_gnu) argc--; @@ -252,7 +252,7 @@ expand_builtin(const char *argv[], int argc, int td) /* * dosysval - return value of the last * system call. - * + * */ pbnum(sysval); break; @@ -260,7 +260,7 @@ expand_builtin(const char *argv[], int argc, int td) case ESYSCMDTYPE: if (argc > 2) doesyscmd(argv[2]); - break; + break; case INCLTYPE: if (argc > 2) if (!doincl(argv[2])) @@ -299,7 +299,7 @@ expand_builtin(const char *argv[], int argc, int td) case SUBSTYPE: /* * dosub - select substring - * + * */ if (argc > 3) dosub(argv, argc); @@ -375,11 +375,11 @@ expand_builtin(const char *argv[], int argc, int td) char *temp; temp = xstrdup(argv[2]); - + fd = mkstemp(temp); if (fd == -1) - err(1, - "%s at line %lu: couldn't make temp file %s", + err(1, + "%s at line %lu: couldn't make temp file %s", CURRENT_NAME, CURRENT_LINE, argv[2]); close(fd); pbstr(temp); @@ -465,7 +465,7 @@ expand_builtin(const char *argv[], int argc, int td) if (argc > 2) doindir(argv, argc); break; - + case BUILTINTYPE: /* Builtins only */ if (argc > 2) dobuiltin(argv, argc); @@ -541,7 +541,7 @@ expand_macro(const char *argv[], int argc) pushback(COMMA); } pbstr(argv[2]); - } + } break; case '@': if (argc > 2) { @@ -578,7 +578,7 @@ dodefine(const char *name, const char *defn) { if (!*name && !mimic_gnu) m4errx(1, "null definition."); - else + else macro_define(name, defn); } @@ -632,7 +632,7 @@ dump_one_def(const char *name, struct macro_definition *p) fprintf(traceout, "%s:\t%s\n", name, p->defn); else { fprintf(traceout, "%s:\t<%s>\n", name, p->defn); - } + } } else fprintf(traceout, "`%s'\t`%s'\n", name, p->defn); } @@ -803,7 +803,7 @@ dodiv(int n) resizedivs(n + 10); else n = 0; /* bitbucket */ - } + } if (n < 0) n = 0; /* bitbucket */ @@ -986,7 +986,7 @@ static const char * handledash(char *buffer, char *end, const char *src) { char *p; - + p = buffer; while(*src) { if (src[1] == '-' && src[2]) { diff --git a/usr.bin/m4/expr.c b/usr.bin/m4/expr.c index b04c0da3b37..6e0b45fa5e4 100644 --- a/usr.bin/m4/expr.c +++ b/usr.bin/m4/expr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expr.c,v 1.17 2006/01/20 23:10:19 espie Exp $ */ +/* $OpenBSD: expr.c,v 1.18 2010/09/07 19:58:09 marco Exp $ */ /* * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org> * @@ -33,7 +33,7 @@ yyerror(const char *msg) return(0); } -int +int expr(const char *toeval) { copy_toeval = toeval; diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h index e2cb60e9f87..17953c7e7ef 100644 --- a/usr.bin/m4/extern.h +++ b/usr.bin/m4/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $ */ +/* $OpenBSD: extern.h,v 1.50 2010/09/07 19:58:09 marco Exp $ */ /* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */ /*- @@ -44,7 +44,7 @@ extern unsigned long expansion_id; extern int expr(const char *); /* gnum4.c */ -extern void addtoincludepath(const char *); +extern void addtoincludepath(const char *); extern struct input_file *fopen_trypath(struct input_file *, const char *); extern void doindir(const char *[], int); extern void dobuiltin(const char *[], int); @@ -57,7 +57,6 @@ extern void doprintfilename(struct input_file *); extern void doesyscmd(const char *); extern void getdivfile(const char *); extern void doformat(const char *[], int); - /* look.c */ @@ -71,13 +70,13 @@ extern void mark_traced(const char *, int); extern struct ohash macros; extern struct macro_definition *lookup_macro_definition(const char *); -extern void macro_define(const char *, const char *); -extern void macro_pushdef(const char *, const char *); -extern void macro_popdef(const char *); -extern void macro_undefine(const char *); -extern void setup_builtin(const char *, unsigned int); -extern void macro_for_all(void (*)(const char *, struct macro_definition *)); -#define macro_getdef(p) ((p)->d) +extern void macro_define(const char *, const char *); +extern void macro_pushdef(const char *, const char *); +extern void macro_popdef(const char *); +extern void macro_undefine(const char *); +extern void setup_builtin(const char *, unsigned int); +extern void macro_for_all(void (*)(const char *, struct macro_definition *)); +#define macro_getdef(p) ((p)->d) #define macro_name(p) ((p)->name) #define macro_builtin_type(p) ((p)->builtin_type) #define is_traced(p) ((p)->trace_flags == FLAG_NO_TRACE ? (trace_flags & TRACE_ALL) : (p)->trace_flags) @@ -91,10 +90,10 @@ extern void do_emit_synchline(void); /* misc.c */ extern void chrsave(int); -extern char *compute_prevep(void); +extern char *compute_prevep(void); extern void getdiv(int); extern ptrdiff_t indx(const char *, const char *); -extern void initspaces(void); +extern void initspaces(void); extern void killdiv(void); extern void onintr(int); extern void pbnum(int); @@ -111,7 +110,7 @@ extern size_t buffer_mark(void); extern void dump_buffer(FILE *, size_t); extern void __dead m4errx(int, const char *, ...); -extern int obtain_char(struct input_file *); +extern int obtain_char(struct input_file *); extern void set_input(struct input_file *, FILE *, const char *); extern void release_input(struct input_file *); @@ -122,7 +121,7 @@ extern void release_input(struct input_file *); enlarge_bufspace(); \ *bp++ = (c); \ } while(0) - + #define CHRSAVE(c) \ do { \ if (ep >= endest) \ @@ -152,7 +151,7 @@ extern FILE *active; /* active output file pointer */ extern struct input_file infile[];/* input file stack (0=stdin) */ extern FILE **outfile; /* diversion array(0=bitbucket) */ extern int maxout; /* maximum number of diversions */ -extern int fp; /* m4 call frame pointer */ +extern int fp; /* m4 call frame pointer */ extern int ilevel; /* input file stack pointer */ extern int oindex; /* diversion index. */ extern int sp; /* current m4 stack pointer */ diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c index 8c803fe79fd..5f6568af033 100644 --- a/usr.bin/m4/gnum4.c +++ b/usr.bin/m4/gnum4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gnum4.c,v 1.40 2010/03/22 20:40:43 espie Exp $ */ +/* $OpenBSD: gnum4.c,v 1.41 2010/09/07 19:58:09 marco Exp $ */ /* * Copyright (c) 1999 Marc Espie @@ -25,7 +25,7 @@ * SUCH DAMAGE. */ -/* +/* * functions needed to support gnu-m4 extensions, including a fake freezing */ @@ -80,8 +80,8 @@ new_path_entry(const char *dirname) n->next = 0; return n; } - -void + +void addtoincludepath(const char *dirname) { struct path_entry *n; @@ -108,13 +108,13 @@ ensure_m4path() return; envpathdone = TRUE; envpath = getenv("M4PATH"); - if (!envpath) + if (!envpath) return; /* for portability: getenv result is read-only */ envpath = strdup(envpath); if (!envpath) errx(1, "out of memory"); - for (sweep = envpath; + for (sweep = envpath; (path = strsep(&sweep, ":")) != NULL;) addtoincludepath(path); free(envpath); @@ -156,7 +156,7 @@ fopen_trypath(struct input_file *i, const char *filename) return dopath(i, filename); } -void +void doindir(const char *argv[], int argc) { ndptr n; @@ -166,11 +166,11 @@ doindir(const char *argv[], int argc) if (n == NULL || (p = macro_getdef(n)) == NULL) m4errx(1, "indir: undefined macro %s.", argv[2]); argv[1] = p->defn; - + eval(argv+1, argc-1, p->type, is_traced(n)); } -void +void dobuiltin(const char *argv[], int argc) { ndptr p; @@ -181,7 +181,7 @@ dobuiltin(const char *argv[], int argc) eval(argv+1, argc-1, macro_builtin_type(p), is_traced(p)); else m4errx(1, "unknown builtin %s.", argv[2]); -} +} /* We need some temporary buffer space, as pb pushes BACK and substitution @@ -202,7 +202,7 @@ static void add_sub(int, const char *, regex_t *, regmatch_t *); static void add_replace(const char *, regex_t *, const char *, regmatch_t *); #define addconstantstring(s) addchars((s), sizeof(s)-1) -static void +static void addchars(const char *c, size_t n) { if (n == 0) @@ -218,7 +218,7 @@ addchars(const char *c, size_t n) current += n; } -static void +static void addchar(int c) { if (current +1 > bufsize) { @@ -240,14 +240,14 @@ getstring() } -static void +static void exit_regerror(int er, regex_t *re) { - size_t errlen; - char *errbuf; + size_t errlen; + char *errbuf; errlen = regerror(er, re, NULL, 0); - errbuf = xalloc(errlen, + errbuf = xalloc(errlen, "malloc in regerror: %lu", (unsigned long)errlen); regerror(er, re, errbuf, errlen); m4errx(1, "regular expression error: %s.", errbuf); @@ -270,7 +270,7 @@ add_sub(int n, const char *string, regex_t *re, regmatch_t *pm) /* Add replacement string to the output buffer, recognizing special * constructs and replacing them with substrings of the original string. */ -static void +static void add_replace(const char *string, regex_t *re, const char *replace, regmatch_t *pm) { const char *p; @@ -299,11 +299,11 @@ add_replace(const char *string, regex_t *re, const char *replace, regmatch_t *pm continue; } } - addchar(*p); + addchar(*p); } } -static void +static void do_subst(const char *string, regex_t *re, const char *replace, regmatch_t *pm) { int error; @@ -318,11 +318,11 @@ do_subst(const char *string, regex_t *re, const char *replace, regmatch_t *pm) flags = REG_NOTBOL; } - /* NULL length matches are special... We use the `vi-mode' + /* NULL length matches are special... We use the `vi-mode' * rule: don't allow a NULL-match at the last match - * position. + * position. */ - if (pm[0].rm_so == pm[0].rm_eo && + if (pm[0].rm_so == pm[0].rm_eo && string + pm[0].rm_so == last_match) { if (*string == '\0') return; @@ -343,13 +343,13 @@ do_subst(const char *string, regex_t *re, const char *replace, regmatch_t *pm) pbstr(string); } -static void +static void do_regexp(const char *string, regex_t *re, const char *replace, regmatch_t *pm) { int error; switch(error = regexec(re, string, re->re_nsub+1, pm, 0)) { - case 0: + case 0: add_replace(string, re, replace, pm); pbstr(getstring()); break; @@ -360,7 +360,7 @@ do_regexp(const char *string, regex_t *re, const char *replace, regmatch_t *pm) } } -static void +static void do_regexpindex(const char *string, regex_t *re, regmatch_t *pm) { int error; @@ -444,7 +444,7 @@ dopatsubst(const char *argv[], int argc) if (argv[3][0] == '\0') { const char *s; size_t len; - if (argc > 4 && argv[4]) + if (argc > 4 && argv[4]) len = strlen(argv[4]); else len = 0; @@ -460,17 +460,17 @@ dopatsubst(const char *argv[], int argc) size_t l = strlen(argv[3]); if (!mimic_gnu || - (argv[3][0] == '^') || + (argv[3][0] == '^') || (l > 0 && argv[3][l-1] == '$')) mode |= REG_NEWLINE; - error = regcomp(&re, mimic_gnu ? twiddle(argv[3]) : argv[3], + error = regcomp(&re, mimic_gnu ? twiddle(argv[3]) : argv[3], mode); if (error != 0) exit_regerror(error, &re); - + pmatch = xalloc(sizeof(regmatch_t) * (re.re_nsub+1), NULL); - do_subst(argv[2], &re, + do_subst(argv[2], &re, argc > 4 && argv[4] != NULL ? argv[4] : "", pmatch); free(pmatch); regfree(&re); @@ -493,14 +493,14 @@ doregexp(const char *argv[], int argc) if (argv[3][0] == '\0' && mimic_gnu) { if (argc == 4 || argv[4] == NULL) return; - else + else pbstr(argv[4]); } - error = regcomp(&re, mimic_gnu ? twiddle(argv[3]) : argv[3], + error = regcomp(&re, mimic_gnu ? twiddle(argv[3]) : argv[3], REG_EXTENDED); if (error != 0) exit_regerror(error, &re); - + pmatch = xalloc(sizeof(regmatch_t) * (re.re_nsub+1), NULL); if (argc == 4 || argv[4] == NULL) do_regexpindex(argv[2], &re, pmatch); @@ -541,7 +541,7 @@ doformat(const char *argv[], int argc) if (*format == '*') { format++; if (pos >= argc) - m4errx(1, + m4errx(1, "Format with too many format specifiers."); width = strtol(argv[pos++], NULL, 10); } else { @@ -558,7 +558,7 @@ doformat(const char *argv[], int argc) if (*format == '*') { format++; if (pos >= argc) - m4errx(1, + m4errx(1, "Format with too many format specifiers."); extra = strtol(argv[pos++], NULL, 10); } else { @@ -579,7 +579,7 @@ doformat(const char *argv[], int argc) thisarg = temp; break; default: - m4errx(1, "Unsupported format specification: %s.", + m4errx(1, "Unsupported format specification: %s.", argv[2]); } format++; diff --git a/usr.bin/m4/look.c b/usr.bin/m4/look.c index 6ae1cec875f..041cbb9a868 100644 --- a/usr.bin/m4/look.c +++ b/usr.bin/m4/look.c @@ -1,4 +1,4 @@ -/* $OpenBSD: look.c,v 1.21 2009/10/14 17:23:17 sthen Exp $ */ +/* $OpenBSD: look.c,v 1.22 2010/09/07 19:58:09 marco Exp $ */ /* * Copyright (c) 1989, 1993 @@ -51,7 +51,7 @@ static void *hash_alloc(size_t, void *); static void hash_free(void *, size_t, void *); static void *element_alloc(size_t, void *); -static void setup_definition(struct macro_definition *, const char *, +static void setup_definition(struct macro_definition *, const char *, const char *); static struct ohash_info macro_info = { @@ -64,7 +64,7 @@ struct ohash macros; void * hash_alloc(s, u) size_t s; - void *u UNUSED; + void *u UNUSED; { void *storage = xalloc(s, "hash alloc"); if (storage) @@ -76,7 +76,7 @@ void hash_free(p, s, u) void *p; size_t s UNUSED; - void *u UNUSED; + void *u UNUSED; { free(p); } @@ -84,7 +84,7 @@ hash_free(p, s, u) void * element_alloc(s, u) size_t s; - void *u UNUSED; + void *u UNUSED; { return xalloc(s, "element alloc"); } @@ -98,7 +98,7 @@ init_macros() /* * find name in the hash table */ -ndptr +ndptr lookup(const char *name) { return ohash_find(¯os, ohash_qlookup(¯os, name)); @@ -116,7 +116,7 @@ lookup_macro_definition(const char *name) return NULL; } -static void +static void setup_definition(struct macro_definition *d, const char *defn, const char *name) { ndptr p; @@ -174,7 +174,7 @@ macro_pushdef(const char *name, const char *defn) { ndptr n; struct macro_definition *d; - + n = create_entry(name); d = xalloc(sizeof(struct macro_definition), NULL); d->next = n->d; @@ -221,13 +221,13 @@ macro_for_all(void (*f)(const char *, struct macro_definition *)) ndptr n; unsigned int i; - for (n = ohash_first(¯os, &i); n != NULL; + for (n = ohash_first(¯os, &i); n != NULL; n = ohash_next(¯os, &i)) if (n->d != NULL) f(n->name, n->d); } -void +void setup_builtin(const char *name, unsigned int type) { ndptr n; @@ -259,16 +259,16 @@ mark_traced(const char *name, int on) trace_flags |= TRACE_ALL; else trace_flags &= ~TRACE_ALL; - for (p = ohash_first(¯os, &i); p != NULL; + for (p = ohash_first(¯os, &i); p != NULL; p = ohash_next(¯os, &i)) - p->trace_flags = FLAG_NO_TRACE; + p->trace_flags = FLAG_NO_TRACE; } else { p = create_entry(name); p->trace_flags = on; } } -ndptr +ndptr macro_getbuiltin(const char *name) { ndptr p; @@ -279,4 +279,3 @@ macro_getbuiltin(const char *name) else return p; } - diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index b841f47fad4..bd61e6fc529 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.78 2010/03/22 20:40:44 espie Exp $ */ +/* $OpenBSD: main.c,v 1.79 2010/09/07 19:58:09 marco Exp $ */ /* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */ /*- @@ -57,19 +57,19 @@ #include "pathnames.h" ndptr hashtab[HASHSIZE]; /* hash table for macros etc. */ -stae *mstack; /* stack of m4 machine */ -char *sstack; /* shadow stack, for string space extension */ +stae *mstack; /* stack of m4 machine */ +char *sstack; /* shadow stack, for string space extension */ static size_t STACKMAX; /* current maximum size of stack */ -int sp; /* current m4 stack pointer */ -int fp; /* m4 call frame pointer */ +int sp; /* current m4 stack pointer */ +int fp; /* m4 call frame pointer */ struct input_file infile[MAXINP];/* input file stack (0=stdin) */ FILE **outfile; /* diversion array(0=bitbucket)*/ int maxout; FILE *active; /* active output file pointer */ -int ilevel = 0; /* input file stack pointer */ -int oindex = 0; /* diversion index.. */ +int ilevel = 0; /* input file stack pointer */ +int oindex = 0; /* diversion index.. */ char *null = ""; /* as it says.. just a null.. */ -char **m4wraps = NULL; /* m4wraps array. */ +char **m4wraps = NULL; /* m4wraps array. */ int maxwraps = 0; /* size of m4wraps array */ int wrapindex = 0; /* current offset in m4wraps */ char lquote[MAXCCHARS+1] = {LQUOTE}; /* left quote character (`) */ @@ -105,7 +105,7 @@ struct keyblk keywrds[] = { /* m4 keywords to be installed */ #ifdef EXTENDED { "paste", PASTTYPE }, { "spaste", SPASTYPE }, - /* Newer extensions, needed to handle gnu-m4 scripts */ + /* Newer extensions, needed to handle gnu-m4 scripts */ { "indir", INDIRTYPE}, { "builtin", BUILTINTYPE}, { "patsubst", PATSTYPE}, @@ -132,7 +132,7 @@ struct keyblk keywrds[] = { /* m4 keywords to be installed */ { "traceon", TRACEONTYPE | NOARGS }, { "traceoff", TRACEOFFTYPE | NOARGS }, -#if defined(unix) || defined(__unix__) +#if defined(unix) || defined(__unix__) { "unix", SELFTYPE | NOARGS }, #else #ifdef vms @@ -236,8 +236,8 @@ main(int argc, char *argv[]) active = stdout; /* default active output */ bbase[0] = bufbase; if (!argc) { - sp = -1; /* stack pointer initialized */ - fp = 0; /* frame pointer initialized */ + sp = -1; /* stack pointer initialized */ + fp = 0; /* frame pointer initialized */ set_input(infile+0, stdin, "stdin"); /* default input (naturally) */ macro(); @@ -249,9 +249,9 @@ main(int argc, char *argv[]) else if (fopen_trypath(infile, p) == NULL) err(1, "%s", p); sp = -1; - fp = 0; + fp = 0; macro(); - release_input(infile); + release_input(infile); } if (wrapindex) { @@ -270,7 +270,7 @@ main(int argc, char *argv[]) for (i = 0; i < wrapindex; i++) { pbstr(m4wraps[i]); macro(); - } + } } } @@ -313,8 +313,8 @@ do_look_ahead(int t, const char *token) return 1; } -#define LOOK_AHEAD(t, token) (t != EOF && \ - (unsigned char)(t)==(unsigned char)(token)[0] && \ +#define LOOK_AHEAD(t, token) (t != EOF && \ + (unsigned char)(t)==(unsigned char)(token)[0] && \ do_look_ahead(t,token)) /* @@ -381,7 +381,7 @@ macro(void) p = inspect(t, token); if (p != NULL) pushback(l = gpbc()); - if (p == NULL || (l != LPAREN && + if (p == NULL || (l != LPAREN && (macro_getdef(p)->type & NEEDARGS) != 0)) outputstr(token); else { @@ -398,15 +398,15 @@ macro(void) */ pushs1(macro_getdef(p)->defn); /* defn string */ pushs1((char *)macro_name(p)); /* macro name */ - pushs(ep); /* start next..*/ + pushs(ep); /* start next..*/ - if (l != LPAREN && PARLEV == 0) { + if (l != LPAREN && PARLEV == 0) { /* no bracks */ chrsave(EOS); if (sp == STACKMAX) errx(1, "internal stack overflow"); - eval((const char **) mstack+fp+1, 2, + eval((const char **) mstack+fp+1, 2, CALTYP, TRACESTATUS); ep = PREVEP; /* flush strspace */ @@ -451,7 +451,7 @@ macro(void) if (sp == STACKMAX) errx(1, "internal stack overflow"); - eval((const char **) mstack+fp+1, sp-fp, + eval((const char **) mstack+fp+1, sp-fp, CALTYP, TRACESTATUS); ep = PREVEP; /* flush strspace */ @@ -494,8 +494,8 @@ macro(void) } } -/* - * output string directly, without pushing it for reparses. +/* + * output string directly, without pushing it for reparses. */ void outputstr(const char *s) @@ -515,7 +515,7 @@ reallyoutputstr(const char *s) fputc(*s, active); if (*s++ == '\n') { infile[ilevel].synch_lineno++; - if (infile[ilevel].synch_lineno != + if (infile[ilevel].synch_lineno != infile[ilevel].lineno) do_emit_synchline(); } @@ -537,15 +537,15 @@ reallyputchar(int c) /* * build an input token.. - * consider only those starting with _ or A-Za-z. + * consider only those starting with _ or A-Za-z. */ static ndptr -inspect(int c, char *tp) +inspect(int c, char *tp) { char *name = tp; char *etp = tp+MAXTOK; ndptr p; - + *tp++ = c; while ((isalnum(c = gpbc()) || c == '_') && tp < etp) @@ -576,9 +576,9 @@ inspect(int c, char *tp) } /* - * initkwds - initialise m4 keywords as fast as possible. + * initkwds - initialise m4 keywords as fast as possible. * This very similar to install, but without certain overheads, - * such as calling lookup. Malloc is not used for storing the + * such as calling lookup. Malloc is not used for storing the * keyword strings, since we simply use the static pointers * within keywrds block. */ @@ -615,20 +615,20 @@ dump_stack(struct position *t, int lev) fprintf(stderr, " ...\n"); break; } - fprintf(stderr, " %s at line %lu\n", + fprintf(stderr, " %s at line %lu\n", t[i].name, t[i].line); } } -static void +static void enlarge_stack(void) { STACKMAX += STACKMAX/2; - mstack = xrealloc(mstack, sizeof(stae) * STACKMAX, - "Evaluation stack overflow (%lu)", + mstack = xrealloc(mstack, sizeof(stae) * STACKMAX, + "Evaluation stack overflow (%lu)", (unsigned long)STACKMAX); sstack = xrealloc(sstack, STACKMAX, - "Evaluation stack overflow (%lu)", + "Evaluation stack overflow (%lu)", (unsigned long)STACKMAX); } diff --git a/usr.bin/m4/mdef.h b/usr.bin/m4/mdef.h index d5e97e10234..ddf7d47a095 100644 --- a/usr.bin/m4/mdef.h +++ b/usr.bin/m4/mdef.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mdef.h,v 1.29 2006/03/20 20:27:45 espie Exp $ */ +/* $OpenBSD: mdef.h,v 1.30 2010/09/07 19:58:09 marco Exp $ */ /* $NetBSD: mdef.h,v 1.7 1996/01/13 23:25:27 pk Exp $ */ /* @@ -87,7 +87,7 @@ #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 NOARGS 512 /* builtin needs no args */ @@ -96,7 +96,7 @@ /* * m4 special characters */ - + #define ARGFLAG '$' #define LPAREN '(' #define RPAREN ')' @@ -115,18 +115,18 @@ */ #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 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(;;) @@ -134,9 +134,9 @@ /* * m4 data structures */ - + typedef struct ndblock *ndptr; - + struct macro_definition { struct macro_definition *next; char *defn; /* definition.. */ @@ -145,23 +145,23 @@ struct macro_definition { struct ndblock { /* hashtable structure */ - unsigned int builtin_type; + 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; + FILE *file; + char *name; + unsigned long lineno; unsigned long synch_lineno; /* used for -s */ - int c; + int c; }; #define CURRENT_NAME (infile[ilevel].name) @@ -173,26 +173,26 @@ struct input_file { * pushf() - push a call frame entry onto stack * pushs() - push a string pointer onto stack */ -#define gpbc() (bp > bufbase) ? *--bp : obtain_char(infile+ilevel) -#define pushf(x) \ +#define gpbc() (bp > bufbase) ? *--bp : obtain_char(infile+ilevel) +#define pushf(x) \ do { \ - if (++sp == STACKMAX) \ + if (++sp == STACKMAX) \ enlarge_stack();\ mstack[sp].sfra = (x); \ sstack[sp] = 0; \ } while (0) -#define pushs(x) \ +#define pushs(x) \ do { \ - if (++sp == STACKMAX) \ + if (++sp == STACKMAX) \ enlarge_stack();\ mstack[sp].sstr = (x); \ sstack[sp] = 1; \ } while (0) -#define pushs1(x) \ +#define pushs1(x) \ do { \ - if (++sp == STACKMAX) \ + if (++sp == STACKMAX) \ enlarge_stack();\ mstack[sp].sstr = (x); \ sstack[sp] = 0; \ @@ -204,18 +204,18 @@ struct input_file { * +-------+ +-----+ * | arg 3 ----------------------->| str | * +-------+ | . | - * | arg 2 ---PREVEP-----+ . + * | arg 2 ---PREVEP-----+ . * +-------+ | * . | | | - * +-------+ | +-----+ + * +-------+ | +-----+ * | plev | PARLEV +-------->| str | * +-------+ | . | * | type | CALTYP . * +-------+ * | prcf ---PREVFP--+ - * +-------+ | + * +-------+ | * | . | PREVSP | - * . | + * . | * +-------+ | * | <----------+ * +-------+ diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c index d03978beba7..80cdb479bbc 100644 --- a/usr.bin/m4/misc.c +++ b/usr.bin/m4/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.41 2009/10/14 17:19:47 sthen Exp $ */ +/* $OpenBSD: misc.c,v 1.42 2010/09/07 19:58:09 marco Exp $ */ /* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */ /* @@ -57,7 +57,7 @@ static size_t bufsize = BUFSIZE; unsigned char *buf; /* push-back buffer */ unsigned char *bufbase; /* the base for current ilevel */ unsigned char *bbase[MAXINP]; /* the base for each ilevel */ -unsigned char *bp; /* first available character */ +unsigned char *bp; /* first available character */ unsigned char *endpbb; /* end of push-back buffer */ @@ -155,7 +155,7 @@ pbunsigned(unsigned long n) while ((n /= 10) > 0); } -void +void initspaces() { int i; @@ -171,7 +171,7 @@ initspaces() bbase[i] = buf; } -void +void enlarge_strspace() { char *newstrspace; @@ -182,9 +182,9 @@ enlarge_strspace() if (!newstrspace) errx(1, "string space overflow"); memcpy(newstrspace, strspace, strsize/2); - for (i = 0; i <= sp; i++) + for (i = 0; i <= sp; i++) if (sstack[i]) - mstack[i].sstr = (mstack[i].sstr - strspace) + mstack[i].sstr = (mstack[i].sstr - strspace) + newstrspace; ep = (ep-strspace) + newstrspace; free(strspace); @@ -214,7 +214,7 @@ enlarge_bufspace() void chrsave(int c) { - if (ep >= endest) + if (ep >= endest) enlarge_strspace(); *ep++ = c; } @@ -283,7 +283,7 @@ resizedivs(int n) { int i; - outfile = (FILE **)xrealloc(outfile, sizeof(FILE *) * n, + outfile = (FILE **)xrealloc(outfile, sizeof(FILE *) * n, "too many diverts %d", n); for (i = maxout; i < n; i++) outfile[i] = NULL; @@ -300,7 +300,7 @@ xalloc(size_t n, const char *fmt, ...) err(1, "malloc"); else { va_list va; - + va_start(va, fmt); verr(1, fmt, va); va_end(va); @@ -324,7 +324,7 @@ xrealloc(void *old, size_t n, const char *fmt, ...) va_start(va, fmt); verr(1, fmt, va); va_end(va); - } + } } return p; } @@ -347,7 +347,7 @@ usage() exit(1); } -int +int obtain_char(struct input_file *f) { if (f->c == EOF) @@ -360,7 +360,7 @@ obtain_char(struct input_file *f) return f->c; } -void +void set_input(struct input_file *f, FILE *real, const char *name) { f->file = real; @@ -378,14 +378,14 @@ do_emit_synchline() infile[ilevel].synch_lineno = infile[ilevel].lineno; } -void +void release_input(struct input_file *f) { if (f->file != stdin) fclose(f->file); f->c = EOF; /* - * XXX can't free filename, as there might still be + * XXX can't free filename, as there might still be * error information pointing to it. */ } @@ -404,7 +404,7 @@ doprintfilename(struct input_file *f) pbstr(lquote); } -/* +/* * buffer_mark/dump_buffer: allows one to save a mark in a buffer, * and later dump everything that was added since then to a file. */ diff --git a/usr.bin/m4/stdd.h b/usr.bin/m4/stdd.h index 90ea5f29c6d..58d42b690c1 100644 --- a/usr.bin/m4/stdd.h +++ b/usr.bin/m4/stdd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stdd.h,v 1.5 2003/06/03 02:56:10 millert Exp $ */ +/* $OpenBSD: stdd.h,v 1.6 2010/09/07 19:58:09 marco Exp $ */ /* $NetBSD: stdd.h,v 1.2 1995/09/28 05:37:50 tls Exp $ */ /*- @@ -44,9 +44,9 @@ #define iswhite(c) ((c) == ' ' || (c) == '\t') -/* - * STREQ is an optimised strcmp(a,b)==0 - * STREQN is an optimised strncmp(a,b,n)==0; assumes n > 0 +/* + * STREQ is an optimised strcmp(a,b)==0 + * STREQN is an optimised strncmp(a,b,n)==0; assumes n > 0 */ #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0) #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0) diff --git a/usr.bin/m4/trace.c b/usr.bin/m4/trace.c index d2a1fb09064..edf58875acc 100644 --- a/usr.bin/m4/trace.c +++ b/usr.bin/m4/trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trace.c,v 1.15 2006/03/24 08:03:44 espie Exp $ */ +/* $OpenBSD: trace.c,v 1.16 2010/09/07 19:58:09 marco Exp $ */ /* * Copyright (c) 2001 Marc Espie. * @@ -35,7 +35,7 @@ FILE *traceout; -#define TRACE_ARGS 1 +#define TRACE_ARGS 1 #define TRACE_EXPANSION 2 #define TRACE_QUOTE 4 #define TRACE_FILENAME 8 @@ -123,7 +123,7 @@ frame_level() int level; int framep; - for (framep = fp, level = 0; framep != 0; + for (framep = fp, level = 0; framep != 0; level++,framep = mstack[framep-3].sfra) ; return level; @@ -142,7 +142,7 @@ print_header(struct input_file *inp) fprintf(traceout, "id %lu: ", expansion_id); } -size_t +size_t trace(const char *argv[], int argc, struct input_file *inp) { if (!traceout) @@ -160,9 +160,9 @@ trace(const char *argv[], int argc, struct input_file *inp) delim[0] = LPAREN; delim[1] = EOS; for (i = 2; i < argc; i++) { - fprintf(traceout, "%s%s%s%s", delim, - (trace_flags & TRACE_QUOTE) ? lquote : "", - argv[i], + fprintf(traceout, "%s%s%s%s", delim, + (trace_flags & TRACE_QUOTE) ? lquote : "", + argv[i], (trace_flags & TRACE_QUOTE) ? rquote : ""); delim[0] = COMMA; delim[1] = ' '; @@ -183,7 +183,7 @@ trace(const char *argv[], int argc, struct input_file *inp) } } -void +void finish_trace(size_t mark) { fprintf(traceout, " -> "); |