diff --git a/Build.sh b/Build.sh index 3ace40d..9aced4f 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirOS: src/bin/mksh/Build.sh,v 1.240 2007/07/22 13:08:54 tg Exp $ +# $MirOS: src/bin/mksh/Build.sh,v 1.241 2007/07/22 13:34:48 tg Exp $ #- # Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS # CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM @@ -332,6 +332,8 @@ $e ... which compiler we seem to use cat >scn.c <<-'EOF' #if defined(__ICC) || defined(__INTEL_COMPILER) ct=icc + #elif defined(__xlC__) + ct=xlc #elif defined(__SUNPRO_C) ct=sunpro #elif defined(__BORLANDC__) @@ -354,7 +356,7 @@ test $h = 1 && sed 's/^/[ /' x eval `cat x` rm -f x case $ct in -bcc|dmc|gcc|hpcc|icc|msc|sunpro) ;; +bcc|dmc|gcc|hpcc|icc|msc|sunpro|xlc) ;; *) ct=unknown ;; esac $e "$bi==> which compiler we seem to use...$ao $ui$ct$ao" @@ -419,6 +421,9 @@ elif test $ct = dmc; then elif test $ct = bcc; then save_NOWARN="${ccpc}-w" DOWARN="${ccpc}-w!" +elif test $ct = xlc; then + save_NOWARN=-qflag=i:e + DOWARN=-qflag=i:i else test x"$save_NOWARN" = x"" && save_NOWARN=-Wno-error ac_flags 0 wnoerror "$save_NOWARN" @@ -447,6 +452,9 @@ test x"$i" = x"" && if test $ct = sunpro; then rm -f x elif test $ct = hpcc; then ac_flags 1 otwo +O2 +elif test $ct = xlc; then + ac_flags 1 othree "-O3 -qstrict" + test 1 = $HAVE_CAN_OTHREE || ac_flags 1 otwo -O2 else ac_flags 1 otwo -O2 test 1 = $HAVE_CAN_OTWO || ac_flags 1 optimise -O @@ -485,6 +493,14 @@ elif test $ct = msc; then rm -f x ac_flags 1 wall "${ccpc}/Wall" 'to enable all warnings' ac_flags 1 wp64 "${ccpc}/Wp64" 'to enable 64-bit warnings' +elif test $ct = xlc; then + ac_flags 1 x99 -qlanglvl=extc99 + test 1 = $HAVE_CAN_X99 || ac_flags 1 c99 -qlanglvl=stdc99 + ac_flags 1 rodata "-qro -qroconst -qroptr" + ac_flags 1 rtcheck -qcheck=all + ac_flags 1 rtchkc -qextchk + ac_flags 1 wformat "-qformat=all -qformat=nozln" + #ac_flags 1 wp64 -qwarn64 # too verbose for now fi # flags common to a subset of compilers if test 1 = $i; then @@ -561,7 +577,11 @@ ac_testn mksh_need_mknod '!' mksh_full 1 'if we still want c_mknod()' <<-'EOF' EOF if test 0 = $HAVE_MKSH_FULL; then - ac_flags 1 fnoinline -fno-inline + if test $ct = xlc; then + ac_flags 1 fnoinline -qnoinline + else + ac_flags 1 fnoinline -fno-inline + fi : ${HAVE_SETLOCALE_CTYPE=0} check_categories=$check_categories,smksh diff --git a/edit.c b/edit.c index 144102f..5092c03 100644 --- a/edit.c +++ b/edit.c @@ -5,7 +5,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.105 2007/07/01 21:10:27 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.106 2007/07/22 13:34:48 tg Exp $"); /* tty driver characters we are interested in */ typedef struct { @@ -2792,7 +2792,7 @@ x_expand(int c __unused) x_delete(end - start, false); for (i = 0; i < nwords;) { if (x_escape(words[i], strlen(words[i]), x_do_ins) < 0 || - (++i < nwords && x_ins(space) < 0)) { + (++i < nwords && x_ins(" ") < 0)) { x_e_putc2(7); return KSTD; } @@ -2838,7 +2838,7 @@ do_complete(int flags, /* XCF_{COMMAND,FILE,COMMAND_FILE} */ } /* add space if single non-dir match */ if (nwords == 1 && words[0][nlen - 1] != '/') { - x_ins(space); + x_ins(" "); completed = 1; } if (type == CT_COMPLIST && !completed) { @@ -4255,10 +4255,14 @@ vi_cmd(int argcnt, const char *cmd) argcnt = source->line + 1 - (hlast - hnum); } - shf_snprintf(es->cbuf, es->cbufsize, - argcnt ? "%s %d" : "%s", - "fc -e ${VISUAL:-${EDITOR:-vi}} --", - argcnt); + if (argcnt) + shf_snprintf(es->cbuf, es->cbufsize, "%s %d", + "fc -e ${VISUAL:-${EDITOR:-vi}} --", + argcnt); + else + strlcpy(es->cbuf, + "fc -e ${VISUAL:-${EDITOR:-vi}} --", + es->cbufsize); es->linelen = strlen(es->cbuf); return 2; @@ -4376,7 +4380,7 @@ vi_cmd(int argcnt, const char *cmd) argcnt++; p++; } - if (putbuf(space, 1, 0) != 0) + if (putbuf(" ", 1, 0) != 0) argcnt = -1; else if (putbuf(sp, argcnt, 0) != 0) argcnt = -1; @@ -5216,7 +5220,7 @@ expand_word(int cmd) rval = -1; break; } - if (++i < nwords && putbuf(space, 1, 0) != 0) { + if (++i < nwords && putbuf(" ", 1, 0) != 0) { rval = -1; break; } @@ -5325,7 +5329,7 @@ complete_word(int cmd, int count) /* If not a directory, add a space to the end... */ if (match_len > 0 && match[match_len - 1] != '/') - rval = putbuf(space, 1, 0); + rval = putbuf(" ", 1, 0); } x_free_words(nwords, words); diff --git a/exec.c b/exec.c index 171e100..1466990 100644 --- a/exec.c +++ b/exec.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.33 2007/06/15 21:22:40 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.34 2007/07/22 13:34:49 tg Exp $"); static int comexec(struct op *, struct tbl *volatile, const char **, int volatile); @@ -70,8 +70,8 @@ execute(struct op *volatile t, shf_fprintf(shl_out, "%s", substitute(str_val(global("PS4")), 0)); for (i = 0; ap[i]; i++) - shf_fprintf(shl_out, "%s%s", ap[i], - ap[i + 1] ? space : newline); + shf_fprintf(shl_out, "%s%c", ap[i], + ap[i + 1] ? ' ' : '\n'); shf_flush(shl_out); } if (ap[0]) @@ -95,7 +95,7 @@ execute(struct op *volatile t, */ if (tp && tp->type == CSHELL && (tp->flag & SPEC_BI)) - errorf(null); + errorf(""); /* Deal with FERREXIT, quitenv(), etc. */ goto Break; } @@ -486,8 +486,8 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap, if (i == 0) shf_fprintf(shl_out, "%s", substitute(str_val(global("PS4")), 0)); - shf_fprintf(shl_out, "%s%s", cp, - t->vars[i + 1] ? space : newline); + shf_fprintf(shl_out, "%s%c", cp, + t->vars[i + 1] ? ' ' : '\n'); if (!t->vars[i + 1]) shf_flush(shl_out); } diff --git a/expr.c b/expr.c index 3ecde99..df75f90 100644 --- a/expr.c +++ b/expr.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.10 2007/03/04 03:04:25 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.11 2007/07/22 13:34:49 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(null); + errorf(""); } unwind(i); /* NOTREACHED */ diff --git a/funcs.c b/funcs.c index 7a9447f..222493a 100644 --- a/funcs.c +++ b/funcs.c @@ -5,7 +5,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.58 2007/07/01 21:10:28 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.59 2007/07/22 13:34:49 tg Exp $"); int c_cd(const char **wp) @@ -494,7 +494,7 @@ c_whence(const char **wp) break; } if (vflag || !ret) - shprintf(newline); + shf_putc('\n', shl_stdout); } return ret; } @@ -793,7 +793,7 @@ c_typeset(const char **wp) else print_value_quoted(s); } - shprintf(newline); + shf_putc('\n', shl_stdout); } /* Only report first 'element' of an array with * no set elements. @@ -887,7 +887,7 @@ c_alias(const char **wp) shf_putc('=', shl_stdout); print_value_quoted(ap->val.s); } - shprintf(newline); + shf_putc('\n', shl_stdout); } } @@ -912,7 +912,7 @@ c_alias(const char **wp) shf_putc('=', shl_stdout); print_value_quoted(ap->val.s); } - shprintf(newline); + shf_putc('\n', shl_stdout); } else { shprintf("%s alias not found\n", alias); rv = 1; @@ -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(null); + bi_errorf(""); return 1; } diff --git a/histrap.c b/histrap.c index 65a0a01..c1e3901 100644 --- a/histrap.c +++ b/histrap.c @@ -3,7 +3,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.51 2007/07/01 21:10:28 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.52 2007/07/22 13:34:50 tg Exp $"); Trap sigtraps[NSIG + 1]; static struct sigaction Sigact_ign; @@ -177,8 +177,10 @@ c_fc(const char **wp) for (hp = rflag ? hlast : hfirst; hp >= hfirst && hp <= hlast; hp += rflag ? -1 : 1) { - shf_fprintf(shl_stdout, nfmt, - hist_source->line - (int) (histptr - hp)); + if (!nflag) + shf_fprintf(shl_stdout, "%d", + hist_source->line - (int)(histptr - hp)); + shf_putc('\t', shl_stdout); /* print multi-line commands correctly */ for (s = *hp; (t = strchr(s, '\n')); s = t) shf_fprintf(shl_stdout, "%.*s\t", diff --git a/jobs.c b/jobs.c index 13e4a1b..14fba66 100644 --- a/jobs.c +++ b/jobs.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.24 2007/06/06 23:41:24 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.25 2007/07/22 13:34:50 tg Exp $"); /* Order important! */ #define PRUNNING 0 @@ -632,7 +632,7 @@ j_resume(const char *cp, int bg) } shprintf("%s%s", p->command, p->next ? "| " : null); } - shprintf(newline); + shf_putc('\n', shl_stdout); shf_flush(shl_stdout); if (running) j->state = PRUNNING; @@ -1283,7 +1283,7 @@ j_print(Job *j, int how, struct shf *shf) while (p && p->state == state && p->status == status) { if (how == JP_LONG) shf_fprintf(shf, "%s%5d %-20s %s%s", filler, - (int)p->pid, space, p->command, + (int)p->pid, " ", p->command, p->next ? "|" : null); else if (how == JP_MEDIUM) shf_fprintf(shf, " %s%s", p->command, @@ -1292,7 +1292,7 @@ j_print(Job *j, int how, struct shf *shf) } } if (output) - shf_fprintf(shf, newline); + shf_putc('\n', shf); } /* Convert % sequence to job diff --git a/lex.c b/lex.c index d2a0443..e083b9e 100644 --- a/lex.c +++ b/lex.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.43 2007/07/07 22:29:36 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.44 2007/07/22 13:34:51 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(null); + errorf(""); } /* @@ -967,10 +967,10 @@ getsc__(void) case SWORDSEP: if (*s->u.strv == NULL) { - s->start = s->str = newline; + s->start = s->str = "\n"; s->type = SEOF; } else { - s->start = s->str = space; + s->start = s->str = " "; s->type = SWORDS; } break; diff --git a/main.c b/main.c index 6b0ab81..be48939 100644 --- a/main.c +++ b/main.c @@ -13,7 +13,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.83 2007/07/17 13:56:51 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.84 2007/07/22 13:34:51 tg Exp $"); extern char **environ; @@ -484,7 +484,7 @@ shell(Source * volatile s, volatile int toplevel) case LSHELL: if (interactive) { if (i == LINTR) - shellf(newline); + shellf("\n"); /* Reset any eof that was read as part of a * multiline command. */ diff --git a/misc.c b/misc.c index ad6815d..15abe55 100644 --- a/misc.c +++ b/misc.c @@ -6,7 +6,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.60 2007/07/01 22:17:29 tg Exp $\t" +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.61 2007/07/22 13:34:51 tg Exp $\t" MKSH_SH_H_ID); #undef USE_CHVT @@ -206,7 +206,7 @@ printoptions(int verbose) for (i = 0; i < NELEM(options); i++) if (Flag(i) && options[i].name) shprintf(" -o %s", options[i].name); - shprintf(newline); + shf_putc('\n', shl_stdout); } } @@ -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(null); + bi_errorf(""); } 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(null); + bi_errorf(""); return '?'; } go->p = 0; diff --git a/sh.h b/sh.h index fba8b89..3e80711 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.157 2007/07/17 13:56:49 tg Exp $" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.158 2007/07/22 13:34:51 tg Exp $" #define MKSH_VERSION "R30 2007/07/17" #if HAVE_SYS_PARAM_H @@ -432,8 +432,6 @@ enum sh_flag { EXTERN char shell_flags [FNFLAGS]; EXTERN char null [] I__(""); /* null value for variable */ -EXTERN char space [] I__(" "); -EXTERN char newline [] I__("\n"); enum temp_type { TT_HEREDOC_EXP, /* expanded heredoc */ diff --git a/var.c b/var.c index 6daffef..01d3b52 100644 --- a/var.c +++ b/var.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.40 2007/07/01 21:10:29 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.41 2007/07/22 13:34:52 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(null); + errorf(""); 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(null); + errorf(""); } if (val != NULL) {