Thanks to Michael sed has moved from an error-prone custom err() function to error(). Here's a cleanup for the arguments you can pass to error().
- some calls to err(1, ...) - as in err(3) - had crept in. But misc.c:err() did exit right away if you passed it 1 - despite the misleading comment about ERROR in defs.h. Make those calls error(FATAL, ...) - some calls used COMPILE2. COMPILE and COMPILE2 are actually the same value, so kill the latter. - also kill ERROR, unused elsewhere. - reorder the remaining defines; put WARNING first since it doesn't cause sed to exit. Comments / oks? Index: compile.c =================================================================== RCS file: /cvs/src/usr.bin/sed/compile.c,v retrieving revision 1.39 diff -u -p -r1.39 compile.c --- compile.c 26 Oct 2015 14:08:47 -0000 1.39 +++ compile.c 26 Oct 2015 19:36:34 -0000 @@ -784,7 +784,7 @@ fixuplabel(struct s_command *cp, struct break; } if ((cp->u.c = findlabel(cp->t)) == NULL) - error(COMPILE2, "undefined label '%s'", cp->t); + error(COMPILE, "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) - error(COMPILE2, "duplicate label '%s'", cp->t); + error(COMPILE, "duplicate label '%s'", cp->t); lh = xmalloc(sizeof *lh); lh->lh_next = *lhp; lh->lh_hash = h; Index: defs.h =================================================================== RCS file: /cvs/src/usr.bin/sed/defs.h,v retrieving revision 1.6 diff -u -p -r1.6 defs.h --- defs.h 17 Jul 2015 20:38:57 -0000 1.6 +++ defs.h 26 Oct 2015 19:36:34 -0000 @@ -136,11 +136,9 @@ typedef struct { /* * Error severity codes: */ -#define FATAL 0 /* Exit immediately with 1 */ -#define ERROR 1 /* Continue, but change exit value */ -#define WARNING 2 /* Just print the warning */ -#define COMPILE 3 /* Print error, count and finish script */ -#define COMPILE2 3 /* Print error, count and finish script */ +#define WARNING 0 /* Just print the warning */ +#define FATAL 1 /* Exit immediately with 1 */ +#define COMPILE 2 /* Print error, count and finish script */ /* * Round up to the nearest multiple of _POSIX2_LINE_MAX Index: main.c =================================================================== RCS file: /cvs/src/usr.bin/sed/main.c,v retrieving revision 1.29 diff -u -p -r1.29 main.c --- main.c 26 Oct 2015 14:08:47 -0000 1.29 +++ main.c 26 Oct 2015 19:36:34 -0000 @@ -161,10 +161,10 @@ main(int argc, char *argv[]) if (inplace != NULL) { if (pledge("stdio rpath wpath cpath fattr", NULL) == -1) - error(1, "pledge"); + error(FATAL, "pledge: %s", strerror(errno)); } else { if (pledge("stdio rpath wpath cpath", NULL) == -1) - error(1, "pledge"); + error(FATAL, "pledge: %s", strerror(errno)); } /* First usage case; script is the first arg */ @@ -355,7 +355,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag fname = files->fname; if (inplace != NULL) { if (lstat(fname, &sb) != 0) - error(1, "%s: %s", fname, + error(FATAL, "%s: %s", fname, strerror(errno ? errno : EIO)); if (!S_ISREG(sb.st_mode)) error(FATAL, "%s: %s %s", fname, -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE