Make compilable from src/tools/m4 on non-NetBSD hosts.
This commit is contained in:
parent
a319f48222
commit
279abfc5d2
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: eval.c,v 1.14 2001/11/14 06:16:08 tv Exp $ */
|
||||
/* $NetBSD: eval.c,v 1.15 2002/01/21 21:49:57 tv Exp $ */
|
||||
/* $OpenBSD: eval.c,v 1.41 2001/10/10 23:25:31 espie Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -42,7 +42,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: eval.c,v 1.14 2001/11/14 06:16:08 tv Exp $");
|
||||
__RCSID("$NetBSD: eval.c,v 1.15 2002/01/21 21:49:57 tv Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -53,7 +53,6 @@ __RCSID("$NetBSD: eval.c,v 1.14 2001/11/14 06:16:08 tv Exp $");
|
|||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: expr.c,v 1.12 2001/11/14 06:16:08 tv Exp $ */
|
||||
/* $NetBSD: expr.c,v 1.13 2002/01/21 21:49:57 tv Exp $ */
|
||||
/* $OpenBSD: expr.c,v 1.11 2000/01/11 14:00:57 espie Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -42,13 +42,12 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)expr.c 8.2 (Berkeley) 4/29/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: expr.c,v 1.12 2001/11/14 06:16:08 tv Exp $");
|
||||
__RCSID("$NetBSD: expr.c,v 1.13 2002/01/21 21:49:57 tv Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include "mdef.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: extern.h,v 1.8 2001/11/14 14:57:04 tv Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.9 2002/01/21 21:49:57 tv Exp $ */
|
||||
/* $OpenBSD: extern.h,v 1.28 2001/10/10 18:12:00 espie Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -39,6 +39,16 @@
|
|||
* @(#)extern.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#else
|
||||
#define HAVE_ERR_H 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ERR_H
|
||||
#include <err.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/* eval.c */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: gnum4.c,v 1.1 2001/11/14 06:16:08 tv Exp $ */
|
||||
/* $NetBSD: gnum4.c,v 1.2 2002/01/21 21:49:57 tv Exp $ */
|
||||
/* $OpenBSD: gnum4.c,v 1.15 2001/10/13 20:18:48 espie Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -34,7 +34,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
#include <regex.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.28 2001/11/14 14:57:04 tv Exp $ */
|
||||
/* $NetBSD: main.c,v 1.29 2002/01/21 21:49:58 tv Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.51 2001/10/06 10:52:25 espie Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.28 2001/11/14 14:57:04 tv Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.29 2002/01/21 21:49:58 tv Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -60,7 +60,6 @@ __RCSID("$NetBSD: main.c,v 1.28 2001/11/14 14:57:04 tv Exp $");
|
|||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
|
@ -570,9 +569,12 @@ initkwds()
|
|||
for (i = 0; i < MAXKEYS; i++) {
|
||||
k = (char *)keywrds[i].knam;
|
||||
if (m4prefix) {
|
||||
if (asprintf(&k, "m4_%s", k) == -1)
|
||||
err(1, "asprintf");
|
||||
keywrds[i].knam = k;
|
||||
size_t klen = strlen(k);
|
||||
char *newk = malloc(klen + 4);
|
||||
|
||||
if (snprintf(newk, klen, "m4_%s", k) == -1)
|
||||
err(1, "snprintf");
|
||||
keywrds[i].knam = newk;
|
||||
}
|
||||
h = hash(k);
|
||||
p = (ndptr) xalloc(sizeof(struct ndblock));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: misc.c,v 1.13 2001/11/14 14:57:04 tv Exp $ */
|
||||
/* $NetBSD: misc.c,v 1.14 2002/01/21 21:49:58 tv Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.25 2001/10/10 11:17:37 espie Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -42,12 +42,11 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: misc.c,v 1.13 2001/11/14 14:57:04 tv Exp $");
|
||||
__RCSID("$NetBSD: misc.c,v 1.14 2002/01/21 21:49:58 tv Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -58,7 +57,6 @@ __RCSID("$NetBSD: misc.c,v 1.13 2001/11/14 14:57:04 tv Exp $");
|
|||
#include "extern.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
|
||||
char *ep; /* first free char in strspace */
|
||||
static char *strspace; /* string space for evaluation */
|
||||
char *endest; /* end of string space */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: trace.c,v 1.3 2001/12/31 18:34:52 thorpej Exp $ */
|
||||
/* $NetBSD: trace.c,v 1.4 2002/01/21 21:49:58 tv Exp $ */
|
||||
/* $OpenBSD: trace.c,v 1.3 2001/09/29 15:47:18 espie Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <err.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -36,7 +35,7 @@
|
|||
#include "stdd.h"
|
||||
#include "extern.h"
|
||||
|
||||
FILE *traceout = stderr;
|
||||
FILE *traceout;
|
||||
|
||||
int traced_macros = 0;
|
||||
|
||||
|
@ -127,7 +126,7 @@ void
|
|||
trace_file(name)
|
||||
const char *name;
|
||||
{
|
||||
if (traceout != stderr)
|
||||
if (traceout)
|
||||
fclose(traceout);
|
||||
traceout = fopen(name, "w");
|
||||
if (!traceout)
|
||||
|
@ -208,14 +207,16 @@ static void
|
|||
print_header(inp)
|
||||
struct input_file *inp;
|
||||
{
|
||||
fprintf(traceout, "m4trace:");
|
||||
FILE *out = traceout ? traceout : stderr;
|
||||
|
||||
fprintf(out, "m4trace:");
|
||||
if (flags & TRACE_FILENAME)
|
||||
fprintf(traceout, "%s:", inp->name);
|
||||
fprintf(out, "%s:", inp->name);
|
||||
if (flags & TRACE_LINENO)
|
||||
fprintf(traceout, "%lu:", inp->lineno);
|
||||
fprintf(traceout, " -%d- ", frame_level());
|
||||
fprintf(out, "%lu:", inp->lineno);
|
||||
fprintf(out, " -%d- ", frame_level());
|
||||
if (flags & TRACE_ID)
|
||||
fprintf(traceout, "id %lu: ", expansion_id);
|
||||
fprintf(out, "id %lu: ", expansion_id);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
|
@ -224,12 +225,14 @@ trace(argv, argc, inp)
|
|||
int argc;
|
||||
struct input_file *inp;
|
||||
{
|
||||
FILE *out = traceout ? traceout : stderr;
|
||||
|
||||
print_header(inp);
|
||||
if (flags & TRACE_CONT) {
|
||||
fprintf(traceout, "%s ...\n", argv[1]);
|
||||
fprintf(out, "%s ...\n", argv[1]);
|
||||
print_header(inp);
|
||||
}
|
||||
fprintf(traceout, "%s", argv[1]);
|
||||
fprintf(out, "%s", argv[1]);
|
||||
if ((flags & TRACE_ARGS) && argc > 2) {
|
||||
char delim[3];
|
||||
int i;
|
||||
|
@ -237,7 +240,7 @@ trace(argv, argc, inp)
|
|||
delim[0] = LPAREN;
|
||||
delim[1] = EOS;
|
||||
for (i = 2; i < argc; i++) {
|
||||
fprintf(traceout, "%s%s%s%s", delim,
|
||||
fprintf(out, "%s%s%s%s", delim,
|
||||
(flags & TRACE_QUOTE) ? lquote : "",
|
||||
argv[i],
|
||||
(flags & TRACE_QUOTE) ? rquote : "");
|
||||
|
@ -245,17 +248,17 @@ trace(argv, argc, inp)
|
|||
delim[1] = ' ';
|
||||
delim[2] = EOS;
|
||||
}
|
||||
fprintf(traceout, "%c", RPAREN);
|
||||
fprintf(out, "%c", RPAREN);
|
||||
}
|
||||
if (flags & TRACE_CONT) {
|
||||
fprintf(traceout, " -> ???\n");
|
||||
fprintf(out, " -> ???\n");
|
||||
print_header(inp);
|
||||
fprintf(traceout, argc > 2 ? "%s(...)" : "%s", argv[1]);
|
||||
fprintf(out, argc > 2 ? "%s(...)" : "%s", argv[1]);
|
||||
}
|
||||
if (flags & TRACE_EXPANSION)
|
||||
return buffer_mark();
|
||||
else {
|
||||
fprintf(traceout, "\n");
|
||||
fprintf(out, "\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -264,11 +267,13 @@ void
|
|||
finish_trace(mark)
|
||||
size_t mark;
|
||||
{
|
||||
fprintf(traceout, " -> ");
|
||||
FILE *out = traceout ? traceout : stderr;
|
||||
|
||||
fprintf(out, " -> ");
|
||||
if (flags & TRACE_QUOTE)
|
||||
fprintf(traceout, "%s", lquote);
|
||||
dump_buffer(traceout, mark);
|
||||
fprintf(out, "%s", lquote);
|
||||
dump_buffer(out, mark);
|
||||
if (flags & TRACE_QUOTE)
|
||||
fprintf(traceout, "%s", rquote);
|
||||
fprintf(traceout, "\n");
|
||||
fprintf(out, "%s", rquote);
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue