diff options
author | mmcc <mmcc@cvs.openbsd.org> | 2015-10-26 14:08:48 +0000 |
---|---|---|
committer | mmcc <mmcc@cvs.openbsd.org> | 2015-10-26 14:08:48 +0000 |
commit | 5e701c3561a431edec485a910a13d7831bcbd8a9 (patch) | |
tree | 02cd867285783a6ba63e43ac325063b6d0fceaa8 /usr.bin/sed | |
parent | be4886ff1fd83ffcf5cd655eda7721157ecac683 (diff) |
Rename err() to error() to prevent confusion with the stdlib function.
Discussed with jca@.
Diffstat (limited to 'usr.bin/sed')
-rw-r--r-- | usr.bin/sed/compile.c | 80 | ||||
-rw-r--r-- | usr.bin/sed/extern.h | 4 | ||||
-rw-r--r-- | usr.bin/sed/main.c | 30 | ||||
-rw-r--r-- | usr.bin/sed/misc.c | 10 | ||||
-rw-r--r-- | usr.bin/sed/process.c | 24 |
5 files changed, 74 insertions, 74 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); } diff --git a/usr.bin/sed/extern.h b/usr.bin/sed/extern.h index 16b58ac94e1..ea51bdba9ea 100644 --- a/usr.bin/sed/extern.h +++ b/usr.bin/sed/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.10 2015/07/17 20:38:57 jasper Exp $ */ +/* $OpenBSD: extern.h,v 1.11 2015/10/26 14:08:47 mmcc Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. * Copyright (c) 1992, 1993 @@ -48,7 +48,7 @@ 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 err(int, const char *, ...); +void error(int, const char *, ...); int mf_fgets(SPACE *, enum e_spflag); int lastline(void); void process(void); diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 7df35bbbd26..6042d9efbc4 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.28 2015/10/25 20:18:37 tobias Exp $ */ +/* $OpenBSD: main.c,v 1.29 2015/10/26 14:08:47 mmcc Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -161,10 +161,10 @@ main(int argc, char *argv[]) if (inplace != NULL) { if (pledge("stdio rpath wpath cpath fattr", NULL) == -1) - err(1, "pledge"); + error(1, "pledge"); } else { if (pledge("stdio rpath wpath cpath", NULL) == -1) - err(1, "pledge"); + error(1, "pledge"); } /* First usage case; script is the first arg */ @@ -184,7 +184,7 @@ main(int argc, char *argv[]) process(); cfclose(prog, NULL); if (fclose(stdout)) - err(FATAL, "stdout: %s", strerror(errno)); + error(FATAL, "stdout: %s", strerror(errno)); exit (rval); } @@ -214,7 +214,7 @@ again: switch (script->type) { case CU_FILE: if ((f = fopen(script->s, "r")) == NULL) - err(FATAL, + error(FATAL, "%s: %s", script->s, strerror(errno)); fname = script->s; state = ST_FILE; @@ -305,7 +305,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) /* stdin? */ if (files->fname == NULL) { if (inplace != NULL) - err(FATAL, "-i may not be used with stdin"); + error(FATAL, "-i may not be used with stdin"); infile = stdin; fname = "stdin"; outfile = stdout; @@ -329,7 +329,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) fclose(infile); if (*oldfname != '\0') { if (rename(fname, oldfname) != 0) { - err(WARNING, "rename()"); + error(WARNING, "rename()"); unlink(tmpfname); exit(1); } @@ -355,10 +355,10 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) fname = files->fname; if (inplace != NULL) { if (lstat(fname, &sb) != 0) - err(1, "%s: %s", fname, + error(1, "%s: %s", fname, strerror(errno ? errno : EIO)); if (!S_ISREG(sb.st_mode)) - err(FATAL, "%s: %s %s", fname, + error(FATAL, "%s: %s %s", fname, "in-place editing only", "works for regular files"); if (*inplace != '\0') { @@ -367,17 +367,17 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) len = strlcat(oldfname, inplace, sizeof(oldfname)); if (len > sizeof(oldfname)) - err(FATAL, "%s: name too long", fname); + error(FATAL, "%s: name too long", fname); } len = snprintf(tmpfname, sizeof(tmpfname), "%s/sedXXXXXXXXXX", dirname(fname)); if (len >= sizeof(tmpfname)) - err(FATAL, "%s: name too long", fname); + error(FATAL, "%s: name too long", fname); if ((fd = mkstemp(tmpfname)) == -1) - err(FATAL, "%s", fname); + error(FATAL, "%s", fname); if ((outfile = fdopen(fd, "w")) == NULL) { unlink(tmpfname); - err(FATAL, "%s", fname); + error(FATAL, "%s", fname); } fchown(fileno(outfile), sb.st_uid, sb.st_gid); fchmod(fileno(outfile), sb.st_mode & ALLPERMS); @@ -389,7 +389,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) outfname = "stdout"; } if ((infile = fopen(fname, "r")) == NULL) { - err(WARNING, "%s", strerror(errno)); + error(WARNING, "%s", strerror(errno)); rval = 1; continue; } @@ -405,7 +405,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) */ p = fgetln(infile, &len); if (ferror(infile)) - err(FATAL, "%s: %s", fname, strerror(errno ? errno : EIO)); + error(FATAL, "%s: %s", fname, strerror(errno ? errno : EIO)); if (len != 0 && p[len - 1] == '\n') { sp->append_newline = 1; len--; diff --git a/usr.bin/sed/misc.c b/usr.bin/sed/misc.c index 212074a2c3e..e0611b8c731 100644 --- a/usr.bin/sed/misc.c +++ b/usr.bin/sed/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.10 2014/10/08 04:19:08 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.11 2015/10/26 14:08:47 mmcc Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -54,7 +54,7 @@ xmalloc(size_t size) void *p; if ((p = malloc(size)) == NULL) - err(FATAL, "%s", strerror(errno)); + error(FATAL, "%s", strerror(errno)); return (p); } @@ -64,7 +64,7 @@ xreallocarray(void *o, size_t nmemb, size_t size) void *p; if ((p = reallocarray(o, nmemb, size)) == NULL) - err(FATAL, "%s", strerror(errno)); + error(FATAL, "%s", strerror(errno)); return (p); } @@ -76,7 +76,7 @@ xrealloc(void *p, size_t size) { if ((p = realloc(p, size)) == NULL) - err(FATAL, "%s", strerror(errno)); + error(FATAL, "%s", strerror(errno)); return (p); } @@ -102,7 +102,7 @@ strregerror(int errcode, regex_t *preg) * Error reporting function */ void -err(int severity, const char *fmt, ...) +error(int severity, const char *fmt, ...) { va_list ap; diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index 7a2d46a8063..f4d801b263c 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process.c,v 1.26 2015/07/20 18:24:15 jasper Exp $ */ +/* $OpenBSD: process.c,v 1.27 2015/10/26 14:08:47 mmcc Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -226,11 +226,11 @@ redirect: if (cp->u.fd == -1 && (cp->u.fd = open(cp->t, O_WRONLY|O_APPEND|O_CREAT|O_TRUNC, DEFFILEMODE)) == -1) - err(FATAL, "%s: %s", + error(FATAL, "%s: %s", cp->t, strerror(errno)); if (write(cp->u.fd, ps, psl) != psl || write(cp->u.fd, "\n", 1) != 1) - err(FATAL, "%s: %s", + error(FATAL, "%s: %s", cp->t, strerror(errno)); break; case 'x': @@ -342,7 +342,7 @@ substitute(struct s_command *cp) if (re == NULL) { if (defpreg != NULL && cp->u.s->maxbref > defpreg->re_nsub) { linenum = cp->u.s->linenum; - err(COMPILE, "\\%d not defined in the RE", + error(COMPILE, "\\%d not defined in the RE", cp->u.s->maxbref); } } @@ -422,10 +422,10 @@ substitute(struct s_command *cp) if (cp->u.s->wfile && !pd) { if (cp->u.s->wfd == -1 && (cp->u.s->wfd = open(cp->u.s->wfile, O_WRONLY|O_APPEND|O_CREAT|O_TRUNC, DEFFILEMODE)) == -1) - err(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno)); + error(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno)); if (write(cp->u.s->wfd, ps, psl) != psl || write(cp->u.s->wfd, "\n", 1) != 1) - err(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno)); + error(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno)); } return (1); } @@ -464,7 +464,7 @@ flush_appends(void) break; } if (ferror(outfile)) - err(FATAL, "%s: %s", outfname, strerror(errno ? errno : EIO)); + error(FATAL, "%s: %s", outfname, strerror(errno ? errno : EIO)); appendx = sdone = 0; } @@ -504,7 +504,7 @@ lputs(char *s) (void)fputc('$', outfile); (void)fputc('\n', outfile); if (ferror(outfile)) - err(FATAL, "%s: %s", outfname, strerror(errno ? errno : EIO)); + error(FATAL, "%s: %s", outfname, strerror(errno ? errno : EIO)); } static inline int @@ -515,7 +515,7 @@ regexec_e(regex_t *preg, const char *string, int eflags, if (preg == NULL) { if (defpreg == NULL) - err(FATAL, "first RE may not be empty"); + error(FATAL, "first RE may not be empty"); } else defpreg = preg; @@ -531,7 +531,7 @@ regexec_e(regex_t *preg, const char *string, int eflags, case REG_NOMATCH: return (0); } - err(FATAL, "RE error: %s", strregerror(eval, defpreg)); + error(FATAL, "RE error: %s", strregerror(eval, defpreg)); /* NOTREACHED */ } @@ -616,13 +616,13 @@ cfclose(struct s_command *cp, struct s_command *end) switch (cp->code) { case 's': if (cp->u.s->wfd != -1 && close(cp->u.s->wfd)) - err(FATAL, + error(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno)); cp->u.s->wfd = -1; break; case 'w': if (cp->u.fd != -1 && close(cp->u.fd)) - err(FATAL, "%s: %s", cp->t, strerror(errno)); + error(FATAL, "%s: %s", cp->t, strerror(errno)); cp->u.fd = -1; break; case '{': |