=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sed/compile.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- src/usr.bin/sed/compile.c 2015/06/23 22:52:55 1.38 +++ src/usr.bin/sed/compile.c 2015/10/26 14:08:47 1.39 @@ -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 @@ 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 @@ 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 @@ */ cmd->nonsel = 1; if (stack == 0) - err(COMPILE, "unexpected }"); + error(COMPILE, "unexpected }"); cmd2 = stack; stack = cmd2->next; cmd2->next = cmd; @@ -240,19 +240,19 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } *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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ *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 @@ 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 @@ 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 @@ 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); }