mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-26 11:47:31 +00:00
Use err(3) instead of local redefinition. Remove progname.
This commit is contained in:
parent
176d344d18
commit
9510535891
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27625
@ -35,7 +35,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)eval.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -45,11 +49,11 @@ static char sccsid[] = "@(#)eval.c 8.1 (Berkeley) 6/6/93";
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "mdef.h"
|
||||
#include "stdd.h"
|
||||
#include "extern.h"
|
||||
@ -190,7 +194,7 @@ register int td;
|
||||
case INCLTYPE:
|
||||
if (argc > 2)
|
||||
if (!doincl(argv[2]))
|
||||
oops("%s: %s", argv[2], strerror(errno));
|
||||
err(1, "%s", argv[2]);
|
||||
break;
|
||||
|
||||
case SINCTYPE:
|
||||
@ -201,7 +205,7 @@ register int td;
|
||||
case PASTTYPE:
|
||||
if (argc > 2)
|
||||
if (!dopaste(argv[2]))
|
||||
oops("%s: %s", argv[2], strerror(errno));
|
||||
err(1, "%s", argv[2]);
|
||||
break;
|
||||
|
||||
case SPASTYPE:
|
||||
@ -367,7 +371,7 @@ register int td;
|
||||
break;
|
||||
|
||||
default:
|
||||
oops("%s: major botch.", "eval");
|
||||
errx(1, "eval: major botch");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -455,9 +459,9 @@ register char *defn;
|
||||
register ndptr p;
|
||||
|
||||
if (!*name)
|
||||
oops("null definition.");
|
||||
errx(1, "null definition");
|
||||
if (STREQ(name, defn))
|
||||
oops("%s: recursive definition.", name);
|
||||
errx(1, "%s: recursive definition", name);
|
||||
if ((p = lookup(name)) == nil)
|
||||
p = addent(name);
|
||||
else if (p->defn != null)
|
||||
@ -501,9 +505,9 @@ register char *defn;
|
||||
register ndptr p;
|
||||
|
||||
if (!*name)
|
||||
oops("null definition");
|
||||
errx(1, "null definition");
|
||||
if (STREQ(name, defn))
|
||||
oops("%s: recursive definition.", name);
|
||||
errx(1, "%s: recursive definition", name);
|
||||
p = addent(name);
|
||||
if (!*defn)
|
||||
p->defn = null;
|
||||
@ -569,7 +573,7 @@ doincl(ifile)
|
||||
char *ifile;
|
||||
{
|
||||
if (ilevel + 1 == MAXINP)
|
||||
oops("too many include files.");
|
||||
errx(1, "too many include files");
|
||||
if ((infile[ilevel + 1] = fopen(ifile, "r")) != NULL) {
|
||||
ilevel++;
|
||||
bbase[ilevel] = bufbase = bp;
|
||||
@ -662,7 +666,7 @@ register int n;
|
||||
if (outfile[n] == NULL) {
|
||||
m4temp[UNIQUE] = n + '0';
|
||||
if ((outfile[n] = fopen(m4temp, "w")) == NULL)
|
||||
oops("%s: cannot divert.", m4temp);
|
||||
errx(1, "%s: cannot divert", m4temp);
|
||||
}
|
||||
oindex = n;
|
||||
active = outfile[n];
|
||||
|
@ -63,7 +63,6 @@ void killdiv __P((void));
|
||||
ndptr lookup __P((char *));
|
||||
void map __P((char *, char *, char *, char *));
|
||||
void onintr __P((int));
|
||||
void oops __P((const char *, ...));
|
||||
void pbnum __P((int));
|
||||
void pbstr __P((unsigned char *));
|
||||
void putback __P((int));
|
||||
@ -91,6 +90,5 @@ extern char lquote; /* left quote character (`) */
|
||||
extern char *m4temp; /* filename for diversions */
|
||||
extern char *m4wraps; /* m4wrap string default. */
|
||||
extern char *null; /* as it says.. just a null. */
|
||||
extern char *progname; /* program name */
|
||||
extern char rquote; /* right quote character (') */
|
||||
extern char scommt; /* start character for comment */
|
||||
|
@ -35,13 +35,17 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
static const char copyright[] =
|
||||
"@(#) Copyright (c) 1989, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -51,12 +55,12 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "mdef.h"
|
||||
#include "stdd.h"
|
||||
#include "extern.h"
|
||||
@ -82,7 +86,6 @@ int ilevel = 0; /* input file stack pointer */
|
||||
int oindex = 0; /* diversion index.. */
|
||||
char *null = ""; /* as it says.. just a null.. */
|
||||
char *m4wraps = ""; /* m4wrap string default.. */
|
||||
char *progname; /* name of this program */
|
||||
char lquote = LQUOTE; /* left quote character (`) */
|
||||
char rquote = RQUOTE; /* right quote character (') */
|
||||
char scommt = SCOMMT; /* start character for comment */
|
||||
@ -153,8 +156,6 @@ main(argc,argv)
|
||||
char *p;
|
||||
register FILE *ifp;
|
||||
|
||||
progname = basename(argv[0]);
|
||||
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||
signal(SIGINT, onintr);
|
||||
|
||||
@ -198,7 +199,7 @@ main(argc,argv)
|
||||
if (p[0] == '-' && p[1] == '\0')
|
||||
ifp = stdin;
|
||||
else if ((ifp = fopen(p, "r")) == NULL)
|
||||
oops("%s: %s", p, strerror(errno));
|
||||
err(1, "%s", p);
|
||||
sp = -1;
|
||||
fp = 0;
|
||||
infile[0] = ifp;
|
||||
@ -282,7 +283,7 @@ macro() {
|
||||
}
|
||||
else if (t == EOF) {
|
||||
if (sp > -1)
|
||||
oops("unexpected end of input", "");
|
||||
errx(1, "unexpected end of input");
|
||||
if (ilevel <= 0)
|
||||
break; /* all done thanks.. */
|
||||
--ilevel;
|
||||
@ -302,7 +303,7 @@ macro() {
|
||||
else if (l == lquote)
|
||||
nlpar++;
|
||||
else if (l == EOF)
|
||||
oops("missing right quote", "");
|
||||
errx(1, "missing right quote");
|
||||
if (nlpar > 0) {
|
||||
if (sp < 0)
|
||||
putc(l, active);
|
||||
@ -340,7 +341,7 @@ macro() {
|
||||
chrsave(EOS);
|
||||
|
||||
if (sp == STACKMAX)
|
||||
oops("internal stack overflow", "");
|
||||
errx(1, "internal stack overflow");
|
||||
|
||||
if (CALTYP == MACRTYPE)
|
||||
expand((char **) mstack+fp+1, sp-fp);
|
||||
@ -390,7 +391,7 @@ register char *tp;
|
||||
h = (h << 5) + h + (*tp++ = c);
|
||||
putback(c);
|
||||
if (tp == etp)
|
||||
oops("token too long", "");
|
||||
errx(1, "token too long");
|
||||
|
||||
*tp = EOS;
|
||||
|
||||
|
@ -35,15 +35,19 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "mdef.h"
|
||||
#include "stdd.h"
|
||||
#include "extern.h"
|
||||
@ -82,7 +86,7 @@ int c;
|
||||
if (bp < endpbb)
|
||||
*bp++ = c;
|
||||
else
|
||||
oops("too many characters pushed back");
|
||||
errx(1, "too many characters pushed back");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -107,7 +111,7 @@ register unsigned char *s;
|
||||
if (zp < endpbb)
|
||||
*zp++ = *es--;
|
||||
if ((bp = zp) == endpbb)
|
||||
oops("too many characters pushed back");
|
||||
errx(1, "too many characters pushed back");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -139,7 +143,7 @@ char c;
|
||||
if (ep < endest)
|
||||
*ep++ = c;
|
||||
else
|
||||
oops("string space overflow");
|
||||
errx(1, "string space overflow");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -153,12 +157,12 @@ int n;
|
||||
register FILE *dfil;
|
||||
|
||||
if (active == outfile[n])
|
||||
oops("%s: diversion still active.", "undivert");
|
||||
errx(1, "undivert: diversion still active");
|
||||
(void) fclose(outfile[n]);
|
||||
outfile[n] = NULL;
|
||||
m4temp[UNIQUE] = n + '0';
|
||||
if ((dfil = fopen(m4temp, "r")) == NULL)
|
||||
oops("%s: cannot undivert.", m4temp);
|
||||
errx(1, "%s: cannot undivert", m4temp);
|
||||
else
|
||||
while ((c = getc(dfil)) != EOF)
|
||||
putc(c, active);
|
||||
@ -169,14 +173,14 @@ int n;
|
||||
#else
|
||||
if (unlink(m4temp) == -1)
|
||||
#endif
|
||||
oops("%s: cannot unlink.", m4temp);
|
||||
errx(1, "%s: cannot unlink", m4temp);
|
||||
}
|
||||
|
||||
void
|
||||
onintr(signo)
|
||||
int signo;
|
||||
{
|
||||
oops("interrupted.");
|
||||
errx(1, "interrupted");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -206,7 +210,7 @@ unsigned long n;
|
||||
register char *p = malloc(n);
|
||||
|
||||
if (p == NULL)
|
||||
oops("malloc: %s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -216,7 +220,7 @@ const char *s;
|
||||
{
|
||||
register char *p = strdup(s);
|
||||
if (p == NULL)
|
||||
oops("strdup: %s", strerror(errno));
|
||||
err(1, "strdup");
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -239,32 +243,3 @@ usage()
|
||||
fprintf(stderr, "usage: m4 [-Dname[=val]] [-Uname]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
oops(const char *fmt, ...)
|
||||
#else
|
||||
oops(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "%s: ", progname);
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user