logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: f45b273f5204ef5edc63886dda795c6db94d75b0
parent 8599eb816036c79b55dda8c06a13ea4ee75c160f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 11 Dec 2024 22:16:31 +0100

lib/err: prefix v?(err|warn)x? with utils_

This allows to make sure libc equivalents aren't accidentally used.

Diffstat:

MMakefile4++++
Mcmd/expr.y30+++++++++++++++---------------
Mcmd/join.c54++++++++++++++++++++++++++++--------------------------
Mcmd/paste.c16++++++++--------
Mcmd/printf.c34+++++++++++++++++-----------------
Mcmd/tr.c2+-
Mcmd/whoami.c6++++--
Mlib/err.c24++++++++++++------------
Mlib/err.h16++++++++--------
Mlib/tr_str.c18+++++++++---------
10 files changed, 106 insertions(+), 98 deletions(-)

diff --git a/Makefile b/Makefile @@ -222,3 +222,7 @@ cmd/paste: cmd/paste.c lib/err.c lib/err.h Makefile config.mk cmd/join: cmd/join.c lib/err.c lib/err.h Makefile config.mk $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno} $(CC) -std=c99 $(CFLAGS) -o cmd/join cmd/join.c lib/err.c $(LDFLAGS) $(LDSTATIC) + +cmd/whoami: cmd/whoami.c lib/err.c lib/err.h Makefile config.mk + $(RM) -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno} + $(CC) -std=c99 $(CFLAGS) -o cmd/whoami cmd/whoami.c lib/err.c $(LDFLAGS) $(LDSTATIC) diff --git a/cmd/expr.y b/cmd/expr.y @@ -133,7 +133,7 @@ make_integer(intmax_t i) vp = (struct val *)malloc(sizeof(*vp)); if (vp == NULL) - errx(ERR_EXIT, "malloc(vp) failed"); + utils_errx(ERR_EXIT, "malloc(vp) failed"); vp->type = integer; vp->u.i = i; @@ -147,10 +147,10 @@ make_str(const char *s) vp = (struct val *)malloc(sizeof(*vp)); if (vp == NULL) - errx(ERR_EXIT, "malloc(vp) failed"); + utils_errx(ERR_EXIT, "malloc(vp) failed"); if ((vp->u.s = strdup(s)) == NULL) - errx(ERR_EXIT, "strdup(s) failed"); + utils_errx(ERR_EXIT, "strdup(s) failed"); if (is_integer(s)) vp->type = numeric_string; @@ -193,9 +193,9 @@ static void assert_to_integer(struct val *vp) { if (vp->type == string) - errx(ERR_EXIT, "not a decimal number: '%s'", vp->u.s); + utils_errx(ERR_EXIT, "not a decimal number: '%s'", vp->u.s); if (!to_integer(vp)) - errx(ERR_EXIT, "operand too large: '%s'", vp->u.s); + utils_errx(ERR_EXIT, "operand too large: '%s'", vp->u.s); } static void @@ -214,7 +214,7 @@ to_string(struct val *vp) #define NDIGITS(x) (3 * (sizeof(x) * CHAR_BIT) / 10 + 1 + 1 + 1) tmp = malloc(NDIGITS(vp->u.i)); if (tmp == NULL) - errx(ERR_EXIT, "malloc() failed"); + utils_errx(ERR_EXIT, "malloc() failed"); sprintf(tmp, "%jd", vp->u.i); vp->type = string; @@ -297,10 +297,10 @@ main(int argc, char *argv[]) nonposix = 1; break; case ':': - errx(1, "Missing operand for option: '-%c'\n", optopt); + utils_errx(1, "Missing operand for option: '-%c'\n", optopt); break; case '?': - errx(1, "Unrecognised option: '-%c'\n", optopt); + utils_errx(1, "Unrecognised option: '-%c'\n", optopt); break; default: abort(); @@ -327,7 +327,7 @@ main(int argc, char *argv[]) static int yyerror(const char *s) { - errx(ERR_EXIT, "syntax error: %s", s); + utils_errx(ERR_EXIT, "syntax error: %s", s); } static struct val * @@ -427,7 +427,7 @@ assert_plus(intmax_t a, intmax_t b, intmax_t r) */ if ((a > 0 && b > 0 && r <= 0) || (a < 0 && b < 0 && r >= 0)) - errx(ERR_EXIT, "overflow"); + utils_errx(ERR_EXIT, "overflow"); } static struct val * @@ -450,7 +450,7 @@ assert_minus(intmax_t a, intmax_t b, intmax_t r) { if ((a >= 0 && b < 0 && r <= 0) || (a < 0 && b > 0 && r >= 0)) - errx(ERR_EXIT, "overflow"); + utils_errx(ERR_EXIT, "overflow"); } static struct val * @@ -488,7 +488,7 @@ assert_times(intmax_t a, intmax_t b, volatile intmax_t r) * instead of a SIGFPE. */ if ((a == -1 && b == INTMAX_MIN) || (a != 0 && r / a != b)) - errx(ERR_EXIT, "overflow"); + utils_errx(ERR_EXIT, "overflow"); } static struct val * @@ -510,10 +510,10 @@ static void assert_div(intmax_t a, intmax_t b) { if (b == 0) - errx(ERR_EXIT, "division by zero"); + utils_errx(ERR_EXIT, "division by zero"); /* only INTMAX_MIN / -1 causes overflow */ if (a == INTMAX_MIN && b == -1) - errx(ERR_EXIT, "overflow"); + utils_errx(ERR_EXIT, "overflow"); } static struct val * @@ -564,7 +564,7 @@ op_colon(struct val *a, struct val *b) /* compile regular expression */ if ((eval = regcomp(&rp, b->u.s, 0)) != 0) { regerror(eval, &rp, errbuf, sizeof(errbuf)); - errx(ERR_EXIT, "%s", errbuf); + utils_errx(ERR_EXIT, "%s", errbuf); } /* compare string against pattern */ diff --git a/cmd/join.c b/cmd/join.c @@ -125,13 +125,15 @@ main(int argc, char *argv[]) switch(ch) { case '1': - if((F1->joinf = strtol(optarg, &end, 10)) < 1) errx(1, "-1 option field number less than 1"); - if(*end) errx(1, "illegal field number -- %s", optarg); + if((F1->joinf = strtol(optarg, &end, 10)) < 1) + utils_errx(1, "-1 option field number less than 1"); + if(*end) utils_errx(1, "illegal field number -- %s", optarg); --F1->joinf; break; case '2': - if((F2->joinf = strtol(optarg, &end, 10)) < 1) errx(1, "-2 option field number less than 1"); - if(*end) errx(1, "illegal field number -- %s", optarg); + if((F2->joinf = strtol(optarg, &end, 10)) < 1) + utils_errx(1, "-2 option field number less than 1"); + if(*end) utils_errx(1, "illegal field number -- %s", optarg); --F2->joinf; break; case 'a': @@ -145,18 +147,18 @@ main(int argc, char *argv[]) F2->unpair = 1; break; default: - errx(1, "-a option file number not 1 or 2"); + utils_errx(1, "-a option file number not 1 or 2"); break; } - if(*end) errx(1, "illegal file number -- %s", optarg); + if(*end) utils_errx(1, "illegal file number -- %s", optarg); break; case 'e': empty = optarg; break; case 'j': if((F1->joinf = F2->joinf = strtol(optarg, &end, 10)) < 1) - errx(1, "-j option field number less than 1"); - if(*end) errx(1, "illegal field number -- %s", optarg); + utils_errx(1, "-j option field number less than 1"); + if(*end) utils_errx(1, "illegal field number -- %s", optarg); --F1->joinf; --F2->joinf; break; @@ -166,7 +168,7 @@ main(int argc, char *argv[]) case 't': spans = 0; if(mbrtowc(&tabchar[0], optarg, MB_LEN_MAX, NULL) != strlen(optarg)) - errx(1, "illegal tab character specification"); + utils_errx(1, "illegal tab character specification"); tabchar[1] = L'\0'; break; case 'v': @@ -181,10 +183,10 @@ main(int argc, char *argv[]) F2->unpair = 1; break; default: - errx(1, "-v option file number not 1 or 2"); + utils_errx(1, "-v option file number not 1 or 2"); break; } - if(*end) errx(1, "illegal file number -- %s", optarg); + if(*end) utils_errx(1, "illegal file number -- %s", optarg); break; case ':': fprintf(stderr, "%s: error: Missing operand for option: '-%c'\n", argv0, optopt); @@ -201,7 +203,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if(aflag && vflag) errx(1, "the -a and -v options are mutually exclusive"); + if(aflag && vflag) utils_errx(1, "the -a and -v options are mutually exclusive"); if(argc != 2) { @@ -213,13 +215,13 @@ main(int argc, char *argv[]) if(!strcmp(*argv, "-")) F1->fp = stdin; else if((F1->fp = fopen(*argv, "r")) == NULL) - err(1, "%s", *argv); + utils_err(1, "%s", *argv); ++argv; if(!strcmp(*argv, "-")) F2->fp = stdin; else if((F2->fp = fopen(*argv, "r")) == NULL) - err(1, "%s", *argv); - if(F1->fp == stdin && F2->fp == stdin) errx(1, "only one input file may be stdin"); + utils_err(1, "%s", *argv); + if(F1->fp == stdin && F2->fp == stdin) utils_errx(1, "only one input file may be stdin"); slurp(F1); slurp(F2); @@ -290,7 +292,7 @@ slurp(INPUT *F) { cnt = F->setalloc; F->setalloc += 50; - if((F->set = realloc(F->set, F->setalloc * sizeof(LINE))) == NULL) err(1, NULL); + if((F->set = realloc(F->set, F->setalloc * sizeof(LINE))) == NULL) utils_err(1, NULL); memset(F->set + cnt, 0, 50 * sizeof(LINE)); /* re-set lastlp in case it moved */ @@ -318,7 +320,7 @@ slurp(INPUT *F) if(lp->linealloc <= len + 1) { lp->linealloc += MAX(100, len + 1 - lp->linealloc); - if((lp->line = realloc(lp->line, lp->linealloc)) == NULL) err(1, NULL); + if((lp->line = realloc(lp->line, lp->linealloc)) == NULL) utils_err(1, NULL); } memmove(lp->line, bp, len); @@ -338,7 +340,7 @@ slurp(INPUT *F) { lp->fieldalloc += 50; if((lp->fields = realloc(lp->fields, lp->fieldalloc * sizeof(char *))) == NULL) - err(1, NULL); + utils_err(1, NULL); } lp->fields[lp->fieldcnt++] = fieldp; } @@ -402,7 +404,7 @@ mbscoll(const char *s1, const char *s2) int ret; if(MB_CUR_MAX == 1) return (strcoll(s1, s2)); - if((w1 = towcs(s1)) == NULL || (w2 = towcs(s2)) == NULL) err(1, NULL); /* XXX */ + if((w1 = towcs(s1)) == NULL || (w2 = towcs(s2)) == NULL) utils_err(1, NULL); /* XXX */ ret = wcscoll(w1, w2); free(w1); free(w2); @@ -472,7 +474,7 @@ outoneline(INPUT *F, LINE *lp) if(F->joinf != cnt) outfield(lp, cnt, 0); } (void)printf("\n"); - if(ferror(stdout)) err(1, "stdout"); + if(ferror(stdout)) utils_err(1, "stdout"); needsep = 0; } @@ -508,7 +510,7 @@ outtwoline(INPUT *F1, LINE *lp1, INPUT *F2, LINE *lp2) if(F2->joinf != cnt) outfield(lp2, cnt, 0); } (void)printf("\n"); - if(ferror(stdout)) err(1, "stdout"); + if(ferror(stdout)) utils_err(1, "stdout"); needsep = 0; } @@ -528,7 +530,7 @@ outfield(LINE *lp, unsigned long fieldno, int out_empty) (void)printf("%s", lp->fields[fieldno]); } } - if(ferror(stdout)) err(1, "stdout"); + if(ferror(stdout)) utils_err(1, "stdout"); } /* @@ -550,16 +552,16 @@ fieldarg(char *option) { filenum = token[0] - '0'; fieldno = strtol(token + 2, &end, 10); - if(*end) errx(1, "malformed -o option field"); - if(fieldno == 0) errx(1, "field numbers are 1 based"); + if(*end) utils_errx(1, "malformed -o option field"); + if(fieldno == 0) utils_errx(1, "field numbers are 1 based"); --fieldno; } else - errx(1, "malformed -o option field"); + utils_errx(1, "malformed -o option field"); if(olistcnt == olistalloc) { olistalloc += 50; - if((olist = realloc(olist, olistalloc * sizeof(OLIST))) == NULL) err(1, NULL); + if((olist = realloc(olist, olistalloc * sizeof(OLIST))) == NULL) utils_err(1, NULL); } olist[olistcnt].filenum = filenum; olist[olistcnt].fieldno = fieldno; diff --git a/cmd/paste.c b/cmd/paste.c @@ -73,11 +73,11 @@ parallel(char **argv) for(cnt = 0, head = tmp = NULL; (p = *argv); ++argv, ++cnt) { - if((lp = malloc(sizeof(LIST))) == NULL) err(1, NULL); + if((lp = malloc(sizeof(LIST))) == NULL) utils_err(1, NULL); if(p[0] == '-' && !p[1]) lp->fp = stdin; else if(!(lp->fp = fopen(p, "r"))) - err(1, "%s", p); + utils_err(1, "%s", p); lp->next = NULL; lp->cnt = cnt; lp->name = p; @@ -145,7 +145,7 @@ sequential(char **argv) fp = stdin; else if(!(fp = fopen(p, "r"))) { - warn("%s", p); + utils_warn("%s", p); failed = 1; continue; } @@ -195,7 +195,7 @@ tr(wchar_t *arg) else *arg = ch; - if(!cnt) errx(1, "no delimiters specified"); + if(!cnt) utils_errx(1, "no delimiters specified"); return (cnt); } @@ -226,13 +226,13 @@ main(int argc, char *argv[]) { const char *arg = optarg; size_t len = mbsrtowcs(NULL, &arg, 0, NULL); - if(len == (size_t)-1) err(1, "delimiters"); - if(len == SIZE_MAX) err(1, NULL); + if(len == (size_t)-1) utils_err(1, "delimiters"); + if(len == SIZE_MAX) utils_err(1, NULL); wchar_t *warg = calloc((len + 1), sizeof(*warg)); - if(warg == NULL) err(1, NULL); + if(warg == NULL) utils_err(1, NULL); arg = optarg; len = mbsrtowcs(warg, &arg, len + 1, NULL); - if(len == (size_t)-1) err(1, "delimiters"); + if(len == (size_t)-1) utils_err(1, "delimiters"); delimcnt = tr(delim = warg); break; } diff --git a/cmd/printf.c b/cmd/printf.c @@ -167,7 +167,7 @@ main(int argc, char *argv[]) if(end == 1) { - warnx("missing format character"); + utils_warnx("missing format character"); return (1); } fwrite(start, 1, fmt - start, stdout); @@ -240,7 +240,7 @@ printf_doformat(char *fmt, int *rval) int idx = atoi(fmt); if(fargv == NULL) { - warnx("incomplete use of n$"); + utils_warnx("incomplete use of n$"); return (NULL); } if(idx <= myargc) @@ -255,7 +255,7 @@ printf_doformat(char *fmt, int *rval) } else if(fargv != NULL) { - warnx("incomplete use of n$"); + utils_warnx("incomplete use of n$"); return (NULL); } @@ -294,7 +294,7 @@ printf_doformat(char *fmt, int *rval) int idx = atoi(fmt); if(fargv == NULL) { - warnx("incomplete use of n$"); + utils_warnx("incomplete use of n$"); return (NULL); } if(idx <= myargc) @@ -309,7 +309,7 @@ printf_doformat(char *fmt, int *rval) } else if(fargv != NULL) { - warnx("incomplete use of n$"); + utils_warnx("incomplete use of n$"); return (NULL); } @@ -335,7 +335,7 @@ printf_doformat(char *fmt, int *rval) haveprec = 0; if(!*fmt) { - warnx("missing format character"); + utils_warnx("missing format character"); return (NULL); } *dptr++ = *fmt; @@ -357,7 +357,7 @@ printf_doformat(char *fmt, int *rval) fmt++; if(!strchr("aAeEfFgG", *fmt)) { - warnx("bad modifier L for %%%c", *fmt); + utils_warnx("bad modifier L for %%%c", *fmt); return (NULL); } } @@ -388,7 +388,7 @@ printf_doformat(char *fmt, int *rval) start[strlen(start) - 1] = 's'; if((p = strdup(getstr())) == NULL) { - warnx("%s", strerror(ENOMEM)); + utils_warnx("%s", strerror(ENOMEM)); return (NULL); } getout = escape(p, 0, &len); @@ -455,7 +455,7 @@ printf_doformat(char *fmt, int *rval) break; } default: - warnx("illegal format character %c", convch); + utils_warnx("illegal format character %c", convch); return (NULL); } *fmt = nextch; @@ -478,7 +478,7 @@ mknum(char *str, char ch) assert(newlen != 0); if((newcopy = realloc(copy, newlen)) == NULL) { - warnx("%s", strerror(ENOMEM)); + utils_warnx("%s", strerror(ENOMEM)); return (NULL); } copy = newcopy; @@ -621,7 +621,7 @@ getint(int *ip) rval = 0; if(val < INT_MIN || val > INT_MAX) { - warnx("%s: %s", *gargv, strerror(ERANGE)); + utils_warnx("%s: %s", *gargv, strerror(ERANGE)); rval = 1; } *ip = (int)val; @@ -655,17 +655,17 @@ getnum(intmax_t *ip, uintmax_t *uip, int signedconv) *uip = strtoumax(*gargv, &ep, 0); if(ep == *gargv) { - warnx("%s: expected numeric value", *gargv); + utils_warnx("%s: expected numeric value", *gargv); rval = 1; } else if(*ep != '\0') { - warnx("%s: not completely converted", *gargv); + utils_warnx("%s: not completely converted", *gargv); rval = 1; } if(errno == ERANGE) { - warnx("%s: %s", *gargv, strerror(ERANGE)); + utils_warnx("%s: %s", *gargv, strerror(ERANGE)); rval = 1; } ++gargv; @@ -696,17 +696,17 @@ getfloating(long double *dp, int mod_ldbl) *dp = strtod(*gargv, &ep); if(ep == *gargv) { - warnx("%s: expected numeric value", *gargv); + utils_warnx("%s: expected numeric value", *gargv); rval = 1; } else if(*ep != '\0') { - warnx("%s: not completely converted", *gargv); + utils_warnx("%s: not completely converted", *gargv); rval = 1; } if(errno == ERANGE) { - warnx("%s: %s", *gargv, strerror(ERANGE)); + utils_warnx("%s: %s", *gargv, strerror(ERANGE)); rval = 1; } ++gargv; diff --git a/cmd/tr.c b/cmd/tr.c @@ -179,7 +179,7 @@ main(int argc, char *argv[]) for(cnt = NCHARS, p = translate; cnt--;) *p++ = OOBCH; - if(!next(&s2)) errx(1, "empty string2"); + if(!next(&s2)) utils_errx(1, "empty string2"); /* If string2 runs out of characters, use the last one specified. */ ch = s2.lastch; diff --git a/cmd/whoami.c b/cmd/whoami.c @@ -6,8 +6,10 @@ #include <string.h> // strerror #include <unistd.h> // geteuid +const char *argv0 = "whoami"; + int -main(int argc, char *argv[]) +main(void) { uid_t euid = geteuid(); struct passwd *pw = getpwuid(euid); @@ -18,7 +20,7 @@ main(int argc, char *argv[]) if(errno == 0) errstr = "Not Found"; - errx(1, "Failed getting name for user ID %d: %s", euid, errstr); + utils_errx(1, "Failed getting name for user ID %d: %s", euid, errstr); } puts(pw->pw_name); diff --git a/lib/err.c b/lib/err.c @@ -10,7 +10,7 @@ #include <stdlib.h> void -vwarn(const char *fmt, va_list ap) +utils_vwarn(const char *fmt, va_list ap) { fprintf(stderr, "%s: warning: ", argv0); if(fmt) @@ -22,7 +22,7 @@ vwarn(const char *fmt, va_list ap) } void -vwarnx(const char *fmt, va_list ap) +utils_vwarnx(const char *fmt, va_list ap) { fprintf(stderr, "%s: warning: ", argv0); if(fmt) vfprintf(stderr, fmt, ap); @@ -30,7 +30,7 @@ vwarnx(const char *fmt, va_list ap) } _Noreturn void -verr(int status, const char *fmt, va_list ap) +utils_verr(int status, const char *fmt, va_list ap) { fprintf(stderr, "%s: error: ", argv0); if(fmt) @@ -43,7 +43,7 @@ verr(int status, const char *fmt, va_list ap) } _Noreturn void -verrx(int status, const char *fmt, va_list ap) +utils_verrx(int status, const char *fmt, va_list ap) { fprintf(stderr, "%s: error: ", argv0); if(fmt) vfprintf(stderr, fmt, ap); @@ -52,37 +52,37 @@ verrx(int status, const char *fmt, va_list ap) } void -warn(const char *fmt, ...) +utils_warn(const char *fmt, ...) { va_list ap; va_start(ap, fmt); - vwarn(fmt, ap); + utils_vwarn(fmt, ap); va_end(ap); } void -warnx(const char *fmt, ...) +utils_warnx(const char *fmt, ...) { va_list ap; va_start(ap, fmt); - vwarnx(fmt, ap); + utils_vwarnx(fmt, ap); va_end(ap); } _Noreturn void -err(int status, const char *fmt, ...) +utils_err(int status, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - verr(status, fmt, ap); + utils_verr(status, fmt, ap); va_end(ap); } _Noreturn void -errx(int status, const char *fmt, ...) +utils_errx(int status, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - verrx(status, fmt, ap); + utils_verrx(status, fmt, ap); va_end(ap); } diff --git a/lib/err.h b/lib/err.h @@ -6,14 +6,14 @@ extern const char *argv0; -void vwarn(const char *fmt, va_list ap); -void vwarnx(const char *fmt, va_list ap); +void utils_vwarn(const char *fmt, va_list ap); +void utils_vwarnx(const char *fmt, va_list ap); -_Noreturn void verr(int status, const char *fmt, va_list ap); -_Noreturn void verrx(int status, const char *fmt, va_list ap); +_Noreturn void utils_verr(int status, const char *fmt, va_list ap); +_Noreturn void utils_verrx(int status, const char *fmt, va_list ap); -void warn(const char *fmt, ...); -void warnx(const char *fmt, ...); +void utils_warn(const char *fmt, ...); +void utils_warnx(const char *fmt, ...); -_Noreturn void err(int status, const char *fmt, ...); -_Noreturn void errx(int status, const char *fmt, ...); +_Noreturn void utils_err(int status, const char *fmt, ...); +_Noreturn void utils_errx(int status, const char *fmt, ...); diff --git a/lib/tr_str.c b/lib/tr_str.c @@ -177,7 +177,7 @@ genclass(STR *s) tmp.name = (char *)s->str; if((cp = (CLASS *)bsearch( &tmp, classes, sizeof(classes) / sizeof(CLASS), sizeof(CLASS), c_class)) == NULL) - errx(1, "unknown class %s", s->str); + utils_errx(1, "unknown class %s", s->str); /* * Generate the set of characters in the class if we haven't @@ -188,7 +188,7 @@ genclass(STR *s) len = NCHARS + 1; assert(len != 0); cp->set = reallocarray(NULL, len, sizeof(*cp->set)); - if(cp->set == NULL) err(1, NULL); + if(cp->set == NULL) utils_err(1, NULL); len = 0; for(i = 0; i < NCHARS; i++) @@ -199,7 +199,7 @@ genclass(STR *s) assert(len != 0); cp->set = reallocarray(cp->set, len, sizeof(*cp->set)); - if(cp->set == NULL) err(1, NULL); + if(cp->set == NULL) utils_err(1, NULL); } s->cnt = 0; @@ -223,12 +223,12 @@ genequiv(STR *s) if(*s->str == '\\') { s->equiv[0] = backslash(s); - if(*s->str != '=') errx(1, "misplaced equivalence equals sign"); + if(*s->str != '=') utils_errx(1, "misplaced equivalence equals sign"); } else { s->equiv[0] = s->str[0]; - if(s->str[1] != '=') errx(1, "misplaced equivalence equals sign"); + if(s->str[1] != '=') utils_errx(1, "misplaced equivalence equals sign"); } s->str += 2; s->cnt = 0; @@ -260,13 +260,13 @@ genseq(STR *s) { char *ep; - if(s->which == STRING1) errx(1, "sequences only valid in string2"); + if(s->which == STRING1) utils_errx(1, "sequences only valid in string2"); if(*s->str == '\\') s->lastch = backslash(s); else s->lastch = *s->str++; - if(*s->str != '*') errx(1, "misplaced sequence asterisk"); + if(*s->str != '*') utils_errx(1, "misplaced sequence asterisk"); switch(*++s->str) { @@ -287,7 +287,7 @@ genseq(STR *s) break; } } - errx(1, "illegal sequence count"); + utils_errx(1, "illegal sequence count"); /* NOTREACHED */ } @@ -322,7 +322,7 @@ backslash(STR *s) } if(i > 0) { - if(val > UCHAR_MAX) errx(1, "octal value out of range: %d", val); + if(val > UCHAR_MAX) utils_errx(1, "octal value out of range: %d", val); s->str += i; return (val); }