mirror of
https://github.com/openbsd/src.git
synced 2025-01-09 22:38:01 -08:00
Split error() into error() and warning() so error() can be marked __dead to
appease gcc. ok procter@ deraadt@
This commit is contained in:
parent
19b4f733e9
commit
5c4e30b8f3
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: compile.c,v 1.40 2015/10/26 22:24:44 jca Exp $ */
|
||||
/* $OpenBSD: compile.c,v 1.41 2017/01/20 10:26:16 krw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -520,14 +520,12 @@ compile_subst(char *p, struct s_subst *s)
|
||||
} else if (*p == '\n') {
|
||||
error(COMPILE,
|
||||
"unescaped newline inside substitute pattern");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
*sp++ = *p;
|
||||
}
|
||||
size += sp - op;
|
||||
} while ((p = cu_fgets(&lbuf, &bufsize)));
|
||||
error(COMPILE, "unterminated substitute in regular expression");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -578,7 +576,7 @@ compile_flags(char *p, struct s_subst *s)
|
||||
p++;
|
||||
#ifdef HISTORIC_PRACTICE
|
||||
if (*p != ' ') {
|
||||
error(WARNING, "space missing before w wfile");
|
||||
warning("space missing before w wfile");
|
||||
return (p);
|
||||
}
|
||||
#endif
|
||||
@ -750,7 +748,7 @@ duptoeol(char *s, char *ctype, char **semi)
|
||||
*s = '\0';
|
||||
}
|
||||
if (ws)
|
||||
error(WARNING, "whitespace after %s", ctype);
|
||||
warning("whitespace after %s", ctype);
|
||||
len = s - start + 1;
|
||||
if (semi)
|
||||
*semi = s;
|
||||
@ -854,7 +852,7 @@ uselabel(void)
|
||||
for (lh = labels[i]; lh != NULL; lh = next) {
|
||||
next = lh->lh_next;
|
||||
if (!lh->lh_ref)
|
||||
error(WARNING, "unused label '%s'",
|
||||
warning("unused label '%s'",
|
||||
lh->lh_cmd->t);
|
||||
free(lh);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: defs.h,v 1.7 2015/10/26 22:24:44 jca Exp $ */
|
||||
/* $OpenBSD: defs.h,v 1.8 2017/01/20 10:26:16 krw Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -136,7 +136,6 @@ typedef struct {
|
||||
/*
|
||||
* Error severity codes:
|
||||
*/
|
||||
#define WARNING 0 /* Just print the warning */
|
||||
#define FATAL 1 /* Exit immediately with 1 */
|
||||
#define COMPILE 2 /* Print error, count and finish script */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: extern.h,v 1.11 2015/10/26 14:08:47 mmcc Exp $ */
|
||||
/* $OpenBSD: extern.h,v 1.12 2017/01/20 10:26:16 krw Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -48,7 +48,8 @@ void cfclose(struct s_command *, struct s_command *);
|
||||
void compile(void);
|
||||
void cspace(SPACE *, const char *, size_t, enum e_spflag);
|
||||
char *cu_fgets(char **, size_t *);
|
||||
void error(int, const char *, ...);
|
||||
__dead void error(int, const char *, ...);
|
||||
void warning(const char *, ...);
|
||||
int mf_fgets(SPACE *, enum e_spflag);
|
||||
int lastline(void);
|
||||
void process(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.33 2016/07/14 08:31:18 semarie Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.34 2017/01/20 10:26:16 krw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -285,7 +285,8 @@ again:
|
||||
}
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -329,7 +330,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag)
|
||||
fclose(infile);
|
||||
if (*oldfname != '\0') {
|
||||
if (rename(fname, oldfname) != 0) {
|
||||
error(WARNING, "rename()");
|
||||
warning("rename()");
|
||||
unlink(tmpfname);
|
||||
exit(1);
|
||||
}
|
||||
@ -389,7 +390,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag)
|
||||
outfname = "stdout";
|
||||
}
|
||||
if ((infile = fopen(fname, "r")) == NULL) {
|
||||
error(WARNING, "%s", strerror(errno));
|
||||
warning("%s", strerror(errno));
|
||||
rval = 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: misc.c,v 1.11 2015/10/26 14:08:47 mmcc Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.12 2017/01/20 10:26:16 krw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -101,7 +101,7 @@ strregerror(int errcode, regex_t *preg)
|
||||
/*
|
||||
* Error reporting function
|
||||
*/
|
||||
void
|
||||
__dead void
|
||||
error(int severity, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@ -109,15 +109,24 @@ error(int severity, const char *fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
(void)fprintf(stderr, "sed: ");
|
||||
switch (severity) {
|
||||
case WARNING:
|
||||
case COMPILE:
|
||||
(void)fprintf(stderr, "%lu: %s: ", linenum, fname);
|
||||
}
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
if (severity == WARNING)
|
||||
return;
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
warning(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
(void)fprintf(stderr, "sed: ");
|
||||
(void)fprintf(stderr, "%lu: %s: ", linenum, fname);
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: process.c,v 1.29 2016/10/11 19:27:39 martijn Exp $ */
|
||||
/* $OpenBSD: process.c,v 1.30 2017/01/20 10:26:16 krw Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -539,7 +539,6 @@ regexec_e(regex_t *preg, const char *string, int eflags,
|
||||
return (0);
|
||||
}
|
||||
error(FATAL, "RE error: %s", strregerror(eval, defpreg));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user