Updating usr.bin/m4

Change-Id: I6edfb294639490da27f6abd132822b901de0d650
This commit is contained in:
Lionel Sambuc 2012-12-11 18:14:47 +01:00
parent 927829ed36
commit 71c7dcb9ce
13 changed files with 68 additions and 76 deletions

View file

@ -120,7 +120,7 @@
2011/01/17 18:11:10,usr.bin/ldd 2011/01/17 18:11:10,usr.bin/ldd
2012/02/10 16:16:12,usr.bin/login 2012/02/10 16:16:12,usr.bin/login
2012/10/17 12:00:00,usr.bin/lorder 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/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
2012/10/17 12:00:00,usr.bin/Makefile.inc 2012/10/17 12:00:00,usr.bin/Makefile.inc

View file

@ -24,7 +24,4 @@ tokenizer.o: parser.h
CLEANFILES+=parser.c parser.h tokenizer.o CLEANFILES+=parser.c parser.h tokenizer.o
# LSC Until it compiles cleanly...
NOGCCERROR:=yes
.include <bsd.prog.mk> .include <bsd.prog.mk>

View file

@ -1,5 +1,5 @@
/* $OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $ */ /* $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 * Copyright (c) 1989, 1993
@ -42,7 +42,7 @@
#include "nbtool_config.h" #include "nbtool_config.h"
#endif #endif
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <sys/types.h> #include <sys/types.h>
#include <err.h> #include <err.h>
@ -52,6 +52,7 @@ __RCSID("$NetBSD: eval.c,v 1.20 2009/10/26 21:11:28 christos Exp $");
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include "mdef.h" #include "mdef.h"
@ -429,8 +430,11 @@ expand_builtin(const char *argv[], int argc, int td)
*/ */
if (argc > 2) { if (argc > 2) {
for (n = 2; n < argc; n++) for (n = 2; n < argc; n++)
fprintf(stderr, "%s ", argv[n]); fprintf(stderr, "%s%s",
fprintf(stderr, "\n"); mimic_gnu && n == 2 ? "" : " ",
argv[n]);
if (!mimic_gnu)
fprintf(stderr, "\n");
} }
break; break;

View file

@ -1,5 +1,5 @@
/* $OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $ */ /* $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 * Copyright (c) 1991, 1993
@ -96,20 +96,19 @@ extern void getdiv(int);
extern ptrdiff_t indx(const char *, const char *); extern ptrdiff_t indx(const char *, const char *);
extern void initspaces(void); extern void initspaces(void);
extern void killdiv(void); extern void killdiv(void);
extern void onintr(int);
extern void pbnum(int); extern void pbnum(int);
extern void pbnumbase(int, int, int); extern void pbnumbase(int, int, int);
extern void pbunsigned(unsigned long); extern void pbunsigned(unsigned long);
extern void pbstr(const char *); extern void pbstr(const char *);
extern void pushback(int); extern void pushback(int);
extern void *xalloc(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, ...); extern void *xrealloc(void *, size_t, const char *fmt, ...)
__printflike(3, 4);
extern char *xstrdup(const char *); extern char *xstrdup(const char *);
extern void usage(void);
extern void resizedivs(int); extern void resizedivs(int);
extern size_t buffer_mark(void); extern size_t buffer_mark(void);
extern void dump_buffer(FILE *, size_t); 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 int obtain_char(struct input_file *);
extern void set_input(struct input_file *, FILE *, const char *); extern void set_input(struct input_file *, FILE *, const char *);

View file

@ -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 $ */ /* $OpenBSD: gnum4.c,v 1.39 2008/08/21 21:01:04 espie Exp $ */
/* /*
@ -33,7 +33,7 @@
#include "nbtool_config.h" #include "nbtool_config.h"
#endif #endif
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <sys/param.h> #include <sys/param.h>
#include <sys/types.h> #include <sys/types.h>
@ -106,7 +106,7 @@ addtoincludepath(const char *dirname)
} }
static void static void
ensure_m4path() ensure_m4path(void)
{ {
static int envpathdone = 0; static int envpathdone = 0;
char *envpath; char *envpath;
@ -203,7 +203,7 @@ static void addchars(const char *, size_t);
static void addchar(int); static void addchar(int);
static char *twiddle(const char *); static char *twiddle(const char *);
static char *getstring(void); 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_subst(const char *, regex_t *, const char *, regmatch_t *);
static void do_regexpindex(const char *, regex_t *, regmatch_t *); static void do_regexpindex(const char *, regex_t *, regmatch_t *);
static void do_regexp(const char *, regex_t *, const char *, regmatch_t *); static void do_regexp(const char *, regex_t *, const char *, regmatch_t *);
@ -241,7 +241,7 @@ addchar(int c)
} }
static char * static char *
getstring() getstring(void)
{ {
addchar('\0'); addchar('\0');
current = 0; current = 0;

View file

@ -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 $ */ /* $OpenBSD: look.c,v 1.21 2009/10/14 17:23:17 sthen Exp $ */
/* /*
@ -42,7 +42,7 @@
#include "nbtool_config.h" #include "nbtool_config.h"
#endif #endif
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@ -67,9 +67,7 @@ struct ohash macros;
/* Support routines for hash tables. */ /* Support routines for hash tables. */
void * void *
hash_alloc(s, u) hash_alloc(size_t s, void *u UNUSED)
size_t s;
void *u UNUSED;
{ {
void *storage = xalloc(s, "hash alloc"); void *storage = xalloc(s, "hash alloc");
if (storage) if (storage)
@ -78,24 +76,19 @@ hash_alloc(s, u)
} }
void void
hash_free(p, s, u) hash_free(void *p, size_t s UNUSED, void *u UNUSED)
void *p;
size_t s UNUSED;
void *u UNUSED;
{ {
free(p); free(p);
} }
void * void *
element_alloc(s, u) element_alloc(size_t s, void *u UNUSED)
size_t s;
void *u UNUSED;
{ {
return xalloc(s, "element alloc"); return xalloc(s, "element alloc");
} }
void void
init_macros() init_macros(void)
{ {
ohash_init(&macros, 10, &macro_info); ohash_init(&macros, 10, &macro_info);
} }

View file

@ -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 $ .\" @(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
.\" .\"
.\" Copyright (c) 1989, 1993 .\" Copyright (c) 1989, 1993
@ -48,11 +48,9 @@
.Op Fl d Ar flags .Op Fl d Ar flags
.Op Fl I Ar dirname .Op Fl I Ar dirname
.Op Fl o Ar filename .Op Fl o Ar filename
.Bk -words
.Op Fl t Ar macro .Op Fl t Ar macro
.Op Fl U Ns Ar name .Op Fl U Ns Ar name
.Op Ar .Op Ar
.Ek
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm m4 .Nm m4

View file

@ -1,5 +1,5 @@
/* $OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $ */ /* $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 * Copyright (c) 1989, 1993
@ -42,7 +42,7 @@
#include "nbtool_config.h" #include "nbtool_config.h"
#endif #endif
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <assert.h> #include <assert.h>
#include <signal.h> #include <signal.h>
#include <err.h> #include <err.h>
@ -167,7 +167,22 @@ static void reallyputchar(int);
static void enlarge_stack(void); 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 int
main(int argc, char *argv[]) main(int argc, char *argv[])
@ -479,7 +494,7 @@ macro(void)
default: default:
if (LOOK_AHEAD(t, scommt)) { if (LOOK_AHEAD(t, scommt)) {
char *q; char *q;
for (q = scommt; *q; p++) for (q = scommt; *q; q++)
chrsave(*q); chrsave(*q);
for(;;) { for(;;) {
t = gpbc(); t = gpbc();
@ -572,7 +587,7 @@ inspect(int c, char *tp)
return NULL; return NULL;
} }
p = ohash_find(&macros, ohash_qlookupi(&macros, name, (const char **)&tp)); p = ohash_find(&macros, ohash_qlookupi(&macros, name, (void *)&tp));
if (p == NULL) if (p == NULL)
return NULL; return NULL;
if (macro_getdef(p) == NULL) if (macro_getdef(p) == NULL)

View file

@ -1,5 +1,5 @@
/* $OpenBSD: mdef.h,v 1.29 2006/03/20 20:27:45 espie Exp $ */ /* $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 * Copyright (c) 1989, 1993
@ -166,6 +166,8 @@ struct input_file {
#define CURRENT_NAME (infile[ilevel].name) #define CURRENT_NAME (infile[ilevel].name)
#define CURRENT_LINE (infile[ilevel].lineno) #define CURRENT_LINE (infile[ilevel].lineno)
#define TOKEN_LINE(f) (f->lineno - (f->c == '\n' ? 1 : 0))
/* /*
* macros for readibility and/or speed * macros for readibility and/or speed
* *

View file

@ -1,5 +1,5 @@
/* $OpenBSD: misc.c,v 1.41 2009/10/14 17:19:47 sthen Exp $ */ /* $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 * Copyright (c) 1989, 1993
@ -36,7 +36,7 @@
#include "nbtool_config.h" #include "nbtool_config.h"
#endif #endif
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@ -160,7 +160,7 @@ pbunsigned(unsigned long n)
} }
void void
initspaces() initspaces(void)
{ {
int i; int i;
@ -176,7 +176,7 @@ initspaces()
} }
void void
enlarge_strspace() enlarge_strspace(void)
{ {
char *newstrspace; char *newstrspace;
int i; int i;
@ -197,7 +197,7 @@ enlarge_strspace()
} }
void void
enlarge_bufspace() enlarge_bufspace(void)
{ {
unsigned char *newbuf; unsigned char *newbuf;
int i; int i;
@ -240,19 +240,11 @@ getdiv(int n)
outfile[n] = NULL; 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 * killdiv - get rid of the diversion files
*/ */
void void
killdiv() killdiv(void)
{ {
int n; int n;
@ -340,15 +332,6 @@ xstrdup(const char *s)
return p; 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 int
obtain_char(struct input_file *f) obtain_char(struct input_file *f)
{ {
@ -373,7 +356,7 @@ set_input(struct input_file *f, FILE *real, const char *name)
} }
void void
do_emit_synchline() do_emit_synchline(void)
{ {
fprintf(active, "#line %lu \"%s\"\n", fprintf(active, "#line %lu \"%s\"\n",
infile[ilevel].lineno, infile[ilevel].name); infile[ilevel].lineno, infile[ilevel].name);
@ -395,7 +378,7 @@ release_input(struct input_file *f)
void void
doprintlineno(struct input_file *f) doprintlineno(struct input_file *f)
{ {
pbunsigned(f->lineno); pbunsigned(TOKEN_LINE(f));
} }
void void
@ -411,7 +394,7 @@ doprintfilename(struct input_file *f)
* and later dump everything that was added since then to a file. * and later dump everything that was added since then to a file.
*/ */
size_t size_t
buffer_mark() buffer_mark(void)
{ {
return bp - buf; return bp - buf;
} }

View file

@ -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 * Copyright (c) 1989, 1993

View file

@ -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 $ */ /* $OpenBSD: tokenizer.l,v 1.6 2008/08/21 21:00:14 espie Exp $ */
/* /*
* Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org> * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
@ -20,7 +20,7 @@
#include "nbtool_config.h" #include "nbtool_config.h"
#endif #endif
#include "parser.h" #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 <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <stdint.h> #include <stdint.h>
@ -37,6 +37,7 @@ int32_t parse_radix(void);
%} %}
%option nounput %option nounput
%option noinput
delim [ \t\n] delim [ \t\n]
ws {delim}+ ws {delim}+
@ -66,7 +67,7 @@ radix 0[rR][0-9]+:[0-9a-zA-Z]+
%% %%
int32_t int32_t
number() number(void)
{ {
long l; long l;
@ -80,7 +81,7 @@ number()
} }
int32_t int32_t
parse_radix() parse_radix(void)
{ {
long base; long base;
char *next; char *next;

View file

@ -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 $ */ /* $OpenBSD: trace.c,v 1.15 2006/03/24 08:03:44 espie Exp $ */
/* /*
* Copyright (c) 2001 Marc Espie. * Copyright (c) 2001 Marc Espie.
@ -28,7 +28,7 @@
#include "nbtool_config.h" #include "nbtool_config.h"
#endif #endif
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <sys/types.h> #include <sys/types.h>
#include <err.h> #include <err.h>
@ -125,7 +125,7 @@ set_trace_flags(const char *s)
} }
static int static int
frame_level() frame_level(void)
{ {
int level; int level;
int framep; int framep;
@ -143,7 +143,7 @@ print_header(struct input_file *inp)
if (trace_flags & TRACE_FILENAME) if (trace_flags & TRACE_FILENAME)
fprintf(traceout, "%s:", inp->name); fprintf(traceout, "%s:", inp->name);
if (trace_flags & TRACE_LINENO) if (trace_flags & TRACE_LINENO)
fprintf(traceout, "%lu:", inp->lineno); fprintf(traceout, "%lu:", TOKEN_LINE(inp));
fprintf(traceout, " -%d- ", frame_level()); fprintf(traceout, " -%d- ", frame_level());
if (trace_flags & TRACE_ID) if (trace_flags & TRACE_ID)
fprintf(traceout, "id %lu: ", expansion_id); fprintf(traceout, "id %lu: ", expansion_id);