diff --git a/exec.c b/exec.c index c5120e8..75dceb7 100644 --- a/exec.c +++ b/exec.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.35 2007/07/22 13:38:26 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.36 2007/07/22 14:01:48 tg Exp $"); static int comexec(struct op *, struct tbl *volatile, const char **, int volatile); @@ -95,7 +95,7 @@ execute(struct op *volatile t, */ if (tp && tp->type == CSHELL && (tp->flag & SPEC_BI)) - errorf(""); + errorfz(); /* Deal with FERREXIT, quitenv(), etc. */ goto Break; } diff --git a/expr.c b/expr.c index df75f90..79f4980 100644 --- a/expr.c +++ b/expr.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.11 2007/07/22 13:34:49 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.12 2007/07/22 14:01:48 tg Exp $"); /* The order of these enums is constrained by the order of opinfo[] */ enum token { @@ -178,7 +178,7 @@ v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok, if (i == LAEXPR) { if (error_ok == KSH_RETURN_ERROR) return (0); - errorf(""); + errorfz(); } unwind(i); /* NOTREACHED */ diff --git a/funcs.c b/funcs.c index 222493a..7fa786d 100644 --- a/funcs.c +++ b/funcs.c @@ -5,7 +5,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.59 2007/07/22 13:34:49 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.60 2007/07/22 14:01:48 tg Exp $"); int c_cd(const char **wp) @@ -1142,7 +1142,7 @@ c_kill(const char **wp) "Usage: kill [ -s signame | -signum | -signame ] {pid|job}...\n" " kill -l [exit_status]\n"); #endif - bi_errorf(""); + bi_errorfz(); return 1; } diff --git a/histrap.c b/histrap.c index c1e3901..0062292 100644 --- a/histrap.c +++ b/histrap.c @@ -3,7 +3,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.52 2007/07/22 13:34:50 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.53 2007/07/22 14:01:49 tg Exp $"); Trap sigtraps[NSIG + 1]; static struct sigaction Sigact_ign; @@ -173,7 +173,6 @@ c_fc(const char **wp) /* List history */ if (lflag) { char *s, *t; - const char *nfmt = nflag ? "\t" : "%d\t"; for (hp = rflag ? hlast : hfirst; hp >= hfirst && hp <= hlast; hp += rflag ? -1 : 1) { diff --git a/lex.c b/lex.c index e083b9e..fd3f43d 100644 --- a/lex.c +++ b/lex.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.44 2007/07/22 13:34:51 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.45 2007/07/22 14:01:49 tg Exp $"); /* Structure to keep track of the lexing state and the various pieces of info * needed for each particular state. */ @@ -905,7 +905,7 @@ yyerror(const char *fmt, ...) va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); va_end(va); - errorf(""); + errorfz(); } /* diff --git a/misc.c b/misc.c index e96db67..fa60198 100644 --- a/misc.c +++ b/misc.c @@ -6,7 +6,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.62 2007/07/22 13:38:26 tg Exp $\t" +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.63 2007/07/22 14:01:49 tg Exp $\t" MKSH_SH_H_ID); #undef USE_CHVT @@ -853,7 +853,7 @@ ksh_getopt(const char **argv, Getopt *go, const char *optionsp) (go->flags & GF_NONAME) ? "" : argv[0], (go->flags & GF_NONAME) ? "" : ": ", c); if (go->flags & GF_ERROR) - bi_errorf(""); + bi_errorfz(); } return '?'; } @@ -879,7 +879,7 @@ ksh_getopt(const char **argv, Getopt *go, const char *optionsp) (go->flags & GF_NONAME) ? "" : argv[0], (go->flags & GF_NONAME) ? "" : ": ", c); if (go->flags & GF_ERROR) - bi_errorf(""); + bi_errorfz(); return '?'; } go->p = 0; diff --git a/sh.h b/sh.h index 0669114..6fa72ad 100644 --- a/sh.h +++ b/sh.h @@ -8,7 +8,7 @@ /* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */ -#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.160 2007/07/22 13:46:15 tg Exp $" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.161 2007/07/22 14:01:50 tg Exp $" #define MKSH_VERSION "R30 2007/07/22" #if HAVE_SYS_PARAM_H @@ -1338,6 +1338,18 @@ void warningf(bool, const char *, ...) __attribute__((format (printf, 2, 3))); void bi_errorf(const char *, ...) __attribute__((format (printf, 1, 2))); +/* + * circumvent compiler format string nonnull checking + * we teach xlC to not bitch about zero-lengths, want + * gcc to do it, and so gain double-checking benefits + */ +#if defined(__xlC__) +#define errorfz() errorf("") +#define bi_errorfz() bi_errorf("") +#else +#define errorfz() errorf(null) +#define bi_errorfz() bi_errorf(null) +#endif void internal_errorf(const char *, ...) __attribute__((noreturn)) __attribute__((format (printf, 1, 2))); diff --git a/var.c b/var.c index 01d3b52..4fa3c09 100644 --- a/var.c +++ b/var.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.41 2007/07/22 13:34:52 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.42 2007/07/22 14:01:50 tg Exp $"); /* * Variables @@ -341,7 +341,7 @@ setstr(struct tbl *vq, const char *s, int error_ok) if ((vq->flag & RDONLY) && !no_ro_check) { warningf(true, "%s: is read only", vq->name); if (!error_ok) - errorf(""); + errorfz(); return 0; } if (!(vq->flag&INTEGER)) { /* string dest */ @@ -690,7 +690,7 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base) } } if (!ok) - errorf(""); + errorfz(); } if (val != NULL) {