From: Lionel Sambuc Date: Tue, 11 Dec 2012 17:14:47 +0000 (+0100) Subject: Updating usr.bin/m4 X-Git-Tag: v3.2.1~110 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F175%2F2;p=minix.git Updating usr.bin/m4 Change-Id: I6edfb294639490da27f6abd132822b901de0d650 --- diff --git a/releasetools/nbsd_ports b/releasetools/nbsd_ports index fd8d32111..c2745a371 100644 --- a/releasetools/nbsd_ports +++ b/releasetools/nbsd_ports @@ -120,7 +120,7 @@ 2011/01/17 18:11:10,usr.bin/ldd 2012/02/10 16:16:12,usr.bin/login 2012/10/17 12:00:00,usr.bin/lorder -2010/05/14 17:14:28,usr.bin/m4 +2012/10/17 12:00:00,usr.bin/m4 2012/03/31 00:12:24,usr.bin/make 2012/10/17 12:00:00,usr.bin/Makefile 2012/10/17 12:00:00,usr.bin/Makefile.inc diff --git a/usr.bin/m4/Makefile b/usr.bin/m4/Makefile index d681ab0bb..d2f9b8bfa 100644 --- a/usr.bin/m4/Makefile +++ b/usr.bin/m4/Makefile @@ -24,7 +24,4 @@ tokenizer.o: parser.h CLEANFILES+=parser.c parser.h tokenizer.o -# LSC Until it compiles cleanly... -NOGCCERROR:=yes - .include diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c index 591b1944c..4b5340e3f 100644 --- a/usr.bin/m4/eval.c +++ b/usr.bin/m4/eval.c @@ -1,5 +1,5 @@ /* $OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $ */ -/* $NetBSD: eval.c,v 1.20 2009/10/26 21:11:28 christos Exp $ */ +/* $NetBSD: eval.c,v 1.22 2011/08/21 23:38:43 dholland Exp $ */ /* * Copyright (c) 1989, 1993 @@ -42,7 +42,7 @@ #include "nbtool_config.h" #endif #include -__RCSID("$NetBSD: eval.c,v 1.20 2009/10/26 21:11:28 christos Exp $"); +__RCSID("$NetBSD: eval.c,v 1.22 2011/08/21 23:38:43 dholland Exp $"); #include #include @@ -52,6 +52,7 @@ __RCSID("$NetBSD: eval.c,v 1.20 2009/10/26 21:11:28 christos Exp $"); #include #include #include +#include #include #include #include "mdef.h" @@ -429,8 +430,11 @@ expand_builtin(const char *argv[], int argc, int td) */ if (argc > 2) { for (n = 2; n < argc; n++) - fprintf(stderr, "%s ", argv[n]); - fprintf(stderr, "\n"); + fprintf(stderr, "%s%s", + mimic_gnu && n == 2 ? "" : " ", + argv[n]); + if (!mimic_gnu) + fprintf(stderr, "\n"); } break; diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h index 29bfe902c..90b669153 100644 --- a/usr.bin/m4/extern.h +++ b/usr.bin/m4/extern.h @@ -1,5 +1,5 @@ /* $OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $ */ -/* $NetBSD: extern.h,v 1.14 2009/10/26 21:12:47 christos Exp $ */ +/* $NetBSD: extern.h,v 1.16 2012/03/15 02:02:23 joerg Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -96,20 +96,19 @@ extern void getdiv(int); extern ptrdiff_t indx(const char *, const char *); extern void initspaces(void); extern void killdiv(void); -extern void onintr(int); extern void pbnum(int); extern void pbnumbase(int, int, int); extern void pbunsigned(unsigned long); extern void pbstr(const char *); extern void pushback(int); -extern void *xalloc(size_t, const char *fmt, ...); -extern void *xrealloc(void *, size_t, const char *fmt, ...); +extern void *xalloc(size_t, const char *fmt, ...) __printflike(2, 3); +extern void *xrealloc(void *, size_t, const char *fmt, ...) + __printflike(3, 4); extern char *xstrdup(const char *); -extern void usage(void); extern void resizedivs(int); extern size_t buffer_mark(void); extern void dump_buffer(FILE *, size_t); -extern void __dead m4errx(int, const char *, ...); +extern void __dead m4errx(int, const char *, ...) __printflike(2, 3); extern int obtain_char(struct input_file *); extern void set_input(struct input_file *, FILE *, const char *); diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c index 3eee7037e..168c33297 100644 --- a/usr.bin/m4/gnum4.c +++ b/usr.bin/m4/gnum4.c @@ -1,4 +1,4 @@ -/* $NetBSD: gnum4.c,v 1.7 2009/10/26 21:16:49 christos Exp $ */ +/* $NetBSD: gnum4.c,v 1.9 2012/03/20 20:34:58 matt Exp $ */ /* $OpenBSD: gnum4.c,v 1.39 2008/08/21 21:01:04 espie Exp $ */ /* @@ -33,7 +33,7 @@ #include "nbtool_config.h" #endif #include -__RCSID("$NetBSD: gnum4.c,v 1.7 2009/10/26 21:16:49 christos Exp $"); +__RCSID("$NetBSD: gnum4.c,v 1.9 2012/03/20 20:34:58 matt Exp $"); #include #include @@ -106,7 +106,7 @@ addtoincludepath(const char *dirname) } static void -ensure_m4path() +ensure_m4path(void) { static int envpathdone = 0; char *envpath; @@ -203,7 +203,7 @@ static void addchars(const char *, size_t); static void addchar(int); static char *twiddle(const char *); static char *getstring(void); -static void exit_regerror(int, regex_t *); +static void exit_regerror(int, regex_t *) __dead; static void do_subst(const char *, regex_t *, const char *, regmatch_t *); static void do_regexpindex(const char *, regex_t *, regmatch_t *); static void do_regexp(const char *, regex_t *, const char *, regmatch_t *); @@ -241,7 +241,7 @@ addchar(int c) } static char * -getstring() +getstring(void) { addchar('\0'); current = 0; diff --git a/usr.bin/m4/look.c b/usr.bin/m4/look.c index fe83602de..d88dc9e08 100644 --- a/usr.bin/m4/look.c +++ b/usr.bin/m4/look.c @@ -1,4 +1,4 @@ -/* $NetBSD: look.c,v 1.11 2009/10/26 21:11:28 christos Exp $ */ +/* $NetBSD: look.c,v 1.12 2012/03/20 20:34:58 matt Exp $ */ /* $OpenBSD: look.c,v 1.21 2009/10/14 17:23:17 sthen Exp $ */ /* @@ -42,7 +42,7 @@ #include "nbtool_config.h" #endif #include -__RCSID("$NetBSD: look.c,v 1.11 2009/10/26 21:11:28 christos Exp $"); +__RCSID("$NetBSD: look.c,v 1.12 2012/03/20 20:34:58 matt Exp $"); #include #include #include @@ -67,9 +67,7 @@ struct ohash macros; /* Support routines for hash tables. */ void * -hash_alloc(s, u) - size_t s; - void *u UNUSED; +hash_alloc(size_t s, void *u UNUSED) { void *storage = xalloc(s, "hash alloc"); if (storage) @@ -78,24 +76,19 @@ hash_alloc(s, u) } void -hash_free(p, s, u) - void *p; - size_t s UNUSED; - void *u UNUSED; +hash_free(void *p, size_t s UNUSED, void *u UNUSED) { free(p); } void * -element_alloc(s, u) - size_t s; - void *u UNUSED; +element_alloc(size_t s, void *u UNUSED) { return xalloc(s, "element alloc"); } void -init_macros() +init_macros(void) { ohash_init(¯os, 10, ¯o_info); } diff --git a/usr.bin/m4/m4.1 b/usr.bin/m4/m4.1 index 339a1afcf..b074a448b 100644 --- a/usr.bin/m4/m4.1 +++ b/usr.bin/m4/m4.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: m4.1,v 1.22 2010/05/14 17:14:28 joerg Exp $ +.\" $NetBSD: m4.1,v 1.23 2012/04/08 22:00:39 wiz Exp $ .\" @(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $ .\" .\" Copyright (c) 1989, 1993 @@ -48,11 +48,9 @@ .Op Fl d Ar flags .Op Fl I Ar dirname .Op Fl o Ar filename -.Bk -words .Op Fl t Ar macro .Op Fl U Ns Ar name .Op Ar -.Ek .Sh DESCRIPTION The .Nm m4 diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index 734d6d7b7..ba76b8584 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -1,5 +1,5 @@ /* $OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $ */ -/* $NetBSD: main.c,v 1.39 2009/11/06 15:13:27 joerg Exp $ */ +/* $NetBSD: main.c,v 1.42 2012/04/25 18:23:58 christos Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -42,7 +42,7 @@ #include "nbtool_config.h" #endif #include -__RCSID("$NetBSD: main.c,v 1.39 2009/11/06 15:13:27 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.42 2012/04/25 18:23:58 christos Exp $"); #include #include #include @@ -167,7 +167,22 @@ static void reallyputchar(int); static void enlarge_stack(void); -int main(int, char *[]); +__dead static void +usage(void) +{ + fprintf(stderr, "usage: %s [-gPs] [-Dname[=value]] [-d flags] " + "[-I dirname] [-o filename]\n" + "\t[-t macro] [-Uname] [file ...]\n", getprogname()); + exit(1); +} + +__dead static void +onintr(int signo) +{ + char intrmessage[] = "m4: interrupted.\n"; + write(STDERR_FILENO, intrmessage, sizeof(intrmessage)-1); + _exit(1); +} int main(int argc, char *argv[]) @@ -479,7 +494,7 @@ macro(void) default: if (LOOK_AHEAD(t, scommt)) { char *q; - for (q = scommt; *q; p++) + for (q = scommt; *q; q++) chrsave(*q); for(;;) { t = gpbc(); @@ -572,7 +587,7 @@ inspect(int c, char *tp) return NULL; } - p = ohash_find(¯os, ohash_qlookupi(¯os, name, (const char **)&tp)); + p = ohash_find(¯os, ohash_qlookupi(¯os, name, (void *)&tp)); if (p == NULL) return NULL; if (macro_getdef(p) == NULL) diff --git a/usr.bin/m4/mdef.h b/usr.bin/m4/mdef.h index b9a57846c..7788ef38c 100644 --- a/usr.bin/m4/mdef.h +++ b/usr.bin/m4/mdef.h @@ -1,5 +1,5 @@ /* $OpenBSD: mdef.h,v 1.29 2006/03/20 20:27:45 espie Exp $ */ -/* $NetBSD: mdef.h,v 1.13 2009/10/26 21:11:28 christos Exp $ */ +/* $NetBSD: mdef.h,v 1.14 2011/03/05 16:37:50 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -166,6 +166,8 @@ struct input_file { #define CURRENT_NAME (infile[ilevel].name) #define CURRENT_LINE (infile[ilevel].lineno) +#define TOKEN_LINE(f) (f->lineno - (f->c == '\n' ? 1 : 0)) + /* * macros for readibility and/or speed * diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c index d06b27578..38f765007 100644 --- a/usr.bin/m4/misc.c +++ b/usr.bin/m4/misc.c @@ -1,5 +1,5 @@ /* $OpenBSD: misc.c,v 1.41 2009/10/14 17:19:47 sthen Exp $ */ -/* $NetBSD: misc.c,v 1.20 2009/11/06 15:13:27 joerg Exp $ */ +/* $NetBSD: misc.c,v 1.23 2012/03/20 20:34:58 matt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -36,7 +36,7 @@ #include "nbtool_config.h" #endif #include -__RCSID("$NetBSD: misc.c,v 1.20 2009/11/06 15:13:27 joerg Exp $"); +__RCSID("$NetBSD: misc.c,v 1.23 2012/03/20 20:34:58 matt Exp $"); #include #include #include @@ -160,7 +160,7 @@ pbunsigned(unsigned long n) } void -initspaces() +initspaces(void) { int i; @@ -176,7 +176,7 @@ initspaces() } void -enlarge_strspace() +enlarge_strspace(void) { char *newstrspace; int i; @@ -197,7 +197,7 @@ enlarge_strspace() } void -enlarge_bufspace() +enlarge_bufspace(void) { unsigned char *newbuf; int i; @@ -240,19 +240,11 @@ getdiv(int n) outfile[n] = NULL; } -void -onintr(int signo) -{ -#define intrmessage "m4: interrupted.\n" - write(STDERR_FILENO, intrmessage, sizeof(intrmessage)-1); - _exit(1); -} - /* * killdiv - get rid of the diversion files */ void -killdiv() +killdiv(void) { int n; @@ -340,15 +332,6 @@ xstrdup(const char *s) return p; } -void -usage(void) -{ - fprintf(stderr, "usage: %s [-gPs] [-Dname[=value]] [-d flags] " - "[-I dirname] [-o filename]\n" - "\t[-t macro] [-Uname] [file ...]\n", getprogname()); - exit(1); -} - int obtain_char(struct input_file *f) { @@ -373,7 +356,7 @@ set_input(struct input_file *f, FILE *real, const char *name) } void -do_emit_synchline() +do_emit_synchline(void) { fprintf(active, "#line %lu \"%s\"\n", infile[ilevel].lineno, infile[ilevel].name); @@ -395,7 +378,7 @@ release_input(struct input_file *f) void doprintlineno(struct input_file *f) { - pbunsigned(f->lineno); + pbunsigned(TOKEN_LINE(f)); } void @@ -411,7 +394,7 @@ doprintfilename(struct input_file *f) * and later dump everything that was added since then to a file. */ size_t -buffer_mark() +buffer_mark(void) { return bp - buf; } diff --git a/usr.bin/m4/pathnames.h b/usr.bin/m4/pathnames.h index 8ff2c23eb..ef788e068 100644 --- a/usr.bin/m4/pathnames.h +++ b/usr.bin/m4/pathnames.h @@ -1,4 +1,4 @@ -/* $NetBSD: pathnames.h,v 1.13 2009/10/31 23:25:04 joerg Exp $ */ +/* $NetBSD: pathnames.h,v 1.15 2011/03/08 23:55:19 riz Exp $ */ /* * Copyright (c) 1989, 1993 diff --git a/usr.bin/m4/tokenizer.l b/usr.bin/m4/tokenizer.l index 2bbfe3ecb..fc4ebf1ca 100644 --- a/usr.bin/m4/tokenizer.l +++ b/usr.bin/m4/tokenizer.l @@ -1,5 +1,5 @@ %{ -/* $NetBSD: tokenizer.l,v 1.4 2009/10/29 14:49:03 christos Exp $ */ +/* $NetBSD: tokenizer.l,v 1.6 2012/03/20 20:34:58 matt Exp $ */ /* $OpenBSD: tokenizer.l,v 1.6 2008/08/21 21:00:14 espie Exp $ */ /* * Copyright (c) 2004 Marc Espie @@ -20,7 +20,7 @@ #include "nbtool_config.h" #endif #include "parser.h" -__RCSID("$NetBSD: tokenizer.l,v 1.4 2009/10/29 14:49:03 christos Exp $"); +__RCSID("$NetBSD: tokenizer.l,v 1.6 2012/03/20 20:34:58 matt Exp $"); #include #include #include @@ -37,6 +37,7 @@ int32_t parse_radix(void); %} %option nounput +%option noinput delim [ \t\n] ws {delim}+ @@ -66,7 +67,7 @@ radix 0[rR][0-9]+:[0-9a-zA-Z]+ %% int32_t -number() +number(void) { long l; @@ -80,7 +81,7 @@ number() } int32_t -parse_radix() +parse_radix(void) { long base; char *next; diff --git a/usr.bin/m4/trace.c b/usr.bin/m4/trace.c index 284d7c97d..bb9397fed 100644 --- a/usr.bin/m4/trace.c +++ b/usr.bin/m4/trace.c @@ -1,4 +1,4 @@ -/* $NetBSD: trace.c,v 1.6 2009/10/26 21:11:28 christos Exp $ */ +/* $NetBSD: trace.c,v 1.8 2012/03/20 20:34:58 matt Exp $ */ /* $OpenBSD: trace.c,v 1.15 2006/03/24 08:03:44 espie Exp $ */ /* * Copyright (c) 2001 Marc Espie. @@ -28,7 +28,7 @@ #include "nbtool_config.h" #endif #include -__RCSID("$NetBSD: trace.c,v 1.6 2009/10/26 21:11:28 christos Exp $"); +__RCSID("$NetBSD: trace.c,v 1.8 2012/03/20 20:34:58 matt Exp $"); #include #include @@ -125,7 +125,7 @@ set_trace_flags(const char *s) } static int -frame_level() +frame_level(void) { int level; int framep; @@ -143,7 +143,7 @@ print_header(struct input_file *inp) if (trace_flags & TRACE_FILENAME) fprintf(traceout, "%s:", inp->name); if (trace_flags & TRACE_LINENO) - fprintf(traceout, "%lu:", inp->lineno); + fprintf(traceout, "%lu:", TOKEN_LINE(inp)); fprintf(traceout, " -%d- ", frame_level()); if (trace_flags & TRACE_ID) fprintf(traceout, "id %lu: ", expansion_id);