summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/compile.c
diff options
context:
space:
mode:
authormmcc <mmcc@openbsd.org>2015-10-26 14:08:47 +0000
committermmcc <mmcc@openbsd.org>2015-10-26 14:08:47 +0000
commit3ec97946df46c47ec067d0f890b14394b6601b6a (patch)
tree233ab1b09a29e17efa52b47711d34c981b435533 /usr.bin/sed/compile.c
parentremove the silly username cache here and use libc user_from_uid. (diff)
downloadwireguard-openbsd-3ec97946df46c47ec067d0f890b14394b6601b6a.tar.xz
wireguard-openbsd-3ec97946df46c47ec067d0f890b14394b6601b6a.zip
Rename err() to error() to prevent confusion with the stdlib function.
Discussed with jca@.
Diffstat (limited to 'usr.bin/sed/compile.c')
-rw-r--r--usr.bin/sed/compile.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index 5e8cce91eaf..e26e4c89778 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: compile.c,v 1.38 2015/06/23 22:52:55 millert Exp $ */
+/* $OpenBSD: compile.c,v 1.39 2015/10/26 14:08:47 mmcc Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
@@ -153,7 +153,7 @@ compile_stream(struct s_command **link)
for (;;) {
if ((p = cu_fgets(&lbuf, &bufsize)) == NULL) {
if (stack != 0)
- err(COMPILE, "unexpected EOF (pending }'s)");
+ error(COMPILE, "unexpected EOF (pending }'s)");
return (link);
}
@@ -193,15 +193,15 @@ semicolon: EATSPACE();
nonsel: /* Now parse the command */
if (!*p)
- err(COMPILE, "command expected");
+ error(COMPILE, "command expected");
cmd->code = *p;
for (fp = cmd_fmts; fp->code; fp++)
if (fp->code == *p)
break;
if (!fp->code)
- err(COMPILE, "invalid command code %c", *p);
+ error(COMPILE, "invalid command code %c", *p);
if (naddr > fp->naddr)
- err(COMPILE,
+ error(COMPILE,
"command %c expects up to %d address(es), found %d",
*p, fp->naddr, naddr);
switch (fp->args) {
@@ -226,7 +226,7 @@ nonsel: /* Now parse the command */
*/
cmd->nonsel = 1;
if (stack == 0)
- err(COMPILE, "unexpected }");
+ error(COMPILE, "unexpected }");
cmd2 = stack;
stack = cmd2->next;
cmd2->next = cmd;
@@ -240,19 +240,19 @@ nonsel: /* Now parse the command */
goto semicolon;
}
if (*p)
- err(COMPILE,
+ error(COMPILE,
"extra characters at the end of %c command", cmd->code);
break;
case TEXT: /* a c i */
p++;
EATSPACE();
if (*p != '\\')
- err(COMPILE, "command %c expects \\ followed by"
+ error(COMPILE, "command %c expects \\ followed by"
" text", cmd->code);
p++;
EATSPACE();
if (*p)
- err(COMPILE, "extra characters after \\ at the"
+ error(COMPILE, "extra characters after \\ at the"
" end of %c command", cmd->code);
cmd->t = compile_text();
break;
@@ -262,14 +262,14 @@ nonsel: /* Now parse the command */
p++;
EATSPACE();
if (*p == '\0')
- err(COMPILE, "filename expected");
+ error(COMPILE, "filename expected");
cmd->t = duptoeol(p, "w command", NULL);
if (aflag)
cmd->u.fd = -1;
else if ((cmd->u.fd = open(p,
O_WRONLY|O_APPEND|O_CREAT|O_TRUNC,
DEFFILEMODE)) == -1)
- err(FATAL, "%s: %s", p, strerror(errno));
+ error(FATAL, "%s: %s", p, strerror(errno));
break;
case RFILE: /* r */
p++;
@@ -293,7 +293,7 @@ nonsel: /* Now parse the command */
EATSPACE();
cmd->t = duptoeol(p, "label", &p);
if (strlen(cmd->t) == 0)
- err(COMPILE, "empty label");
+ error(COMPILE, "empty label");
enterlabel(cmd);
if (*p == ';') {
p++;
@@ -303,12 +303,12 @@ nonsel: /* Now parse the command */
case SUBST: /* s */
p++;
if (*p == '\0' || *p == '\\')
- err(COMPILE, "substitute pattern can not be"
+ error(COMPILE, "substitute pattern can not be"
" delimited by newline or backslash");
cmd->u.s = xmalloc(sizeof(struct s_subst));
p = compile_re(p, &cmd->u.s->re);
if (p == NULL)
- err(COMPILE, "unterminated substitute pattern");
+ error(COMPILE, "unterminated substitute pattern");
--p;
p = compile_subst(p, cmd->u.s);
p = compile_flags(p, cmd->u.s);
@@ -329,7 +329,7 @@ nonsel: /* Now parse the command */
goto semicolon;
}
if (*p)
- err(COMPILE, "extra text at the end of a"
+ error(COMPILE, "extra text at the end of a"
" transform command");
break;
}
@@ -354,13 +354,13 @@ compile_delimited(char *p, char *d, int is_tr)
if (c == '\0')
return (NULL);
else if (c == '\\')
- err(COMPILE, "\\ can not be used as a string delimiter");
+ error(COMPILE, "\\ can not be used as a string delimiter");
else if (c == '\n')
- err(COMPILE, "newline can not be used as a string delimiter");
+ error(COMPILE, "newline can not be used as a string delimiter");
while (*p) {
if (*p == '[' && *p != c) {
if ((d = compile_ccl(&p, d)) == NULL)
- err(COMPILE, "unbalanced brackets ([])");
+ error(COMPILE, "unbalanced brackets ([])");
continue;
} else if (*p == '\\' && p[1] == '[') {
*d++ = *p++;
@@ -439,7 +439,7 @@ compile_re(char *p, regex_t **repp)
}
*repp = xmalloc(sizeof(regex_t));
if (p && (eval = regcomp(*repp, re, Eflag ? REG_EXTENDED : 0)) != 0)
- err(COMPILE, "RE error: %s", strregerror(eval, *repp));
+ error(COMPILE, "RE error: %s", strregerror(eval, *repp));
if (maxnsub < (*repp)->re_nsub)
maxnsub = (*repp)->re_nsub;
free(re);
@@ -505,7 +505,7 @@ compile_subst(char *p, struct s_subst *s)
ref = *p - '0';
if (s->re != NULL &&
ref > s->re->re_nsub)
- err(COMPILE,
+ error(COMPILE,
"\\%c not defined in the RE", *p);
if (s->maxbref < ref)
s->maxbref = ref;
@@ -518,7 +518,7 @@ compile_subst(char *p, struct s_subst *s)
s->new = xrealloc(text, size);
return (p);
} else if (*p == '\n') {
- err(COMPILE,
+ error(COMPILE,
"unescaped newline inside substitute pattern");
/* NOTREACHED */
}
@@ -526,7 +526,7 @@ compile_subst(char *p, struct s_subst *s)
}
size += sp - op;
} while ((p = cu_fgets(&lbuf, &bufsize)));
- err(COMPILE, "unterminated substitute in regular expression");
+ error(COMPILE, "unterminated substitute in regular expression");
/* NOTREACHED */
}
@@ -549,7 +549,7 @@ compile_flags(char *p, struct s_subst *s)
switch (*p) {
case 'g':
if (gn)
- err(COMPILE, "more than one number or 'g' in"
+ error(COMPILE, "more than one number or 'g' in"
" substitute flags");
gn = 1;
s->n = 0;
@@ -565,12 +565,12 @@ compile_flags(char *p, struct s_subst *s)
case '4': case '5': case '6':
case '7': case '8': case '9':
if (gn)
- err(COMPILE, "more than one number or 'g' in"
+ error(COMPILE, "more than one number or 'g' in"
" substitute flags");
gn = 1;
l = strtol(p, &p, 10);
if (l <= 0 || l >= INT_MAX)
- err(COMPILE,
+ error(COMPILE,
"number in substitute flags out of range");
s->n = (int)l;
continue;
@@ -578,7 +578,7 @@ compile_flags(char *p, struct s_subst *s)
p++;
#ifdef HISTORIC_PRACTICE
if (*p != ' ') {
- err(WARNING, "space missing before w wfile");
+ error(WARNING, "space missing before w wfile");
return (p);
}
#endif
@@ -589,20 +589,20 @@ compile_flags(char *p, struct s_subst *s)
if (*p == '\n')
break;
if (q >= eq)
- err(COMPILE, "wfile too long");
+ error(COMPILE, "wfile too long");
*q++ = *p++;
}
*q = '\0';
if (q == wfile)
- err(COMPILE, "no wfile specified");
+ error(COMPILE, "no wfile specified");
s->wfile = strdup(wfile);
if (!aflag && (s->wfd = open(wfile,
O_WRONLY|O_APPEND|O_CREAT|O_TRUNC,
DEFFILEMODE)) == -1)
- err(FATAL, "%s: %s", wfile, strerror(errno));
+ error(FATAL, "%s: %s", wfile, strerror(errno));
return (p);
default:
- err(COMPILE,
+ error(COMPILE,
"bad flag in substitute command: '%c'", *p);
break;
}
@@ -621,23 +621,23 @@ compile_tr(char *p, char **transtab)
char *old = NULL, *new = NULL;
if (*p == '\0' || *p == '\\')
- err(COMPILE,
+ error(COMPILE,
"transform pattern can not be delimited by newline or backslash");
old = xmalloc(strlen(p) + 1);
p = compile_delimited(p, old, 1);
if (p == NULL) {
- err(COMPILE, "unterminated transform source string");
+ error(COMPILE, "unterminated transform source string");
goto bad;
}
new = xmalloc(strlen(p) + 1);
p = compile_delimited(--p, new, 1);
if (p == NULL) {
- err(COMPILE, "unterminated transform target string");
+ error(COMPILE, "unterminated transform target string");
goto bad;
}
EATSPACE();
if (strlen(new) != strlen(old)) {
- err(COMPILE, "transform strings are not the same length");
+ error(COMPILE, "transform strings are not the same length");
goto bad;
}
/* We assume characters are 8 bits */
@@ -710,7 +710,7 @@ compile_addr(char *p, struct s_addr *a)
case '/': /* Context address */
p = compile_re(p, &a->u.r);
if (p == NULL)
- err(COMPILE, "unterminated regular expression");
+ error(COMPILE, "unterminated regular expression");
a->type = AT_RE;
return (p);
@@ -724,7 +724,7 @@ compile_addr(char *p, struct s_addr *a)
a->u.l = strtoul(p, &end, 10);
return (end);
default:
- err(COMPILE, "expected context address");
+ error(COMPILE, "expected context address");
return (NULL);
}
}
@@ -750,7 +750,7 @@ duptoeol(char *s, char *ctype, char **semi)
*s = '\0';
}
if (ws)
- err(WARNING, "whitespace after %s", ctype);
+ error(WARNING, "whitespace after %s", ctype);
len = s - start + 1;
if (semi)
*semi = s;
@@ -784,7 +784,7 @@ fixuplabel(struct s_command *cp, struct s_command *end)
break;
}
if ((cp->u.c = findlabel(cp->t)) == NULL)
- err(COMPILE2, "undefined label '%s'", cp->t);
+ error(COMPILE2, "undefined label '%s'", cp->t);
free(cp->t);
break;
case '{':
@@ -809,7 +809,7 @@ enterlabel(struct s_command *cp)
lhp = &labels[h & LHMASK];
for (lh = *lhp; lh != NULL; lh = lh->lh_next)
if (lh->lh_hash == h && strcmp(cp->t, lh->lh_cmd->t) == 0)
- err(COMPILE2, "duplicate label '%s'", cp->t);
+ error(COMPILE2, "duplicate label '%s'", cp->t);
lh = xmalloc(sizeof *lh);
lh->lh_next = *lhp;
lh->lh_hash = h;
@@ -854,7 +854,7 @@ uselabel(void)
for (lh = labels[i]; lh != NULL; lh = next) {
next = lh->lh_next;
if (!lh->lh_ref)
- err(WARNING, "unused label '%s'",
+ error(WARNING, "unused label '%s'",
lh->lh_cmd->t);
free(lh);
}