• support IBM xlC on AIX

• fix all bugs it could find ☺
This commit is contained in:
tg
2007-07-22 13:34:52 +00:00
parent 211ecedf4e
commit 979406bba7
12 changed files with 74 additions and 50 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/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 # Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM # 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' cat >scn.c <<-'EOF'
#if defined(__ICC) || defined(__INTEL_COMPILER) #if defined(__ICC) || defined(__INTEL_COMPILER)
ct=icc ct=icc
#elif defined(__xlC__)
ct=xlc
#elif defined(__SUNPRO_C) #elif defined(__SUNPRO_C)
ct=sunpro ct=sunpro
#elif defined(__BORLANDC__) #elif defined(__BORLANDC__)
@ -354,7 +356,7 @@ test $h = 1 && sed 's/^/[ /' x
eval `cat x` eval `cat x`
rm -f x rm -f x
case $ct in case $ct in
bcc|dmc|gcc|hpcc|icc|msc|sunpro) ;; bcc|dmc|gcc|hpcc|icc|msc|sunpro|xlc) ;;
*) ct=unknown ;; *) ct=unknown ;;
esac esac
$e "$bi==> which compiler we seem to use...$ao $ui$ct$ao" $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 elif test $ct = bcc; then
save_NOWARN="${ccpc}-w" save_NOWARN="${ccpc}-w"
DOWARN="${ccpc}-w!" DOWARN="${ccpc}-w!"
elif test $ct = xlc; then
save_NOWARN=-qflag=i:e
DOWARN=-qflag=i:i
else else
test x"$save_NOWARN" = x"" && save_NOWARN=-Wno-error test x"$save_NOWARN" = x"" && save_NOWARN=-Wno-error
ac_flags 0 wnoerror "$save_NOWARN" ac_flags 0 wnoerror "$save_NOWARN"
@ -447,6 +452,9 @@ test x"$i" = x"" && if test $ct = sunpro; then
rm -f x rm -f x
elif test $ct = hpcc; then elif test $ct = hpcc; then
ac_flags 1 otwo +O2 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 else
ac_flags 1 otwo -O2 ac_flags 1 otwo -O2
test 1 = $HAVE_CAN_OTWO || ac_flags 1 optimise -O test 1 = $HAVE_CAN_OTWO || ac_flags 1 optimise -O
@ -485,6 +493,14 @@ elif test $ct = msc; then
rm -f x rm -f x
ac_flags 1 wall "${ccpc}/Wall" 'to enable all warnings' ac_flags 1 wall "${ccpc}/Wall" 'to enable all warnings'
ac_flags 1 wp64 "${ccpc}/Wp64" 'to enable 64-bit 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 fi
# flags common to a subset of compilers # flags common to a subset of compilers
if test 1 = $i; then 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 EOF
if test 0 = $HAVE_MKSH_FULL; then if test 0 = $HAVE_MKSH_FULL; then
if test $ct = xlc; then
ac_flags 1 fnoinline -qnoinline
else
ac_flags 1 fnoinline -fno-inline ac_flags 1 fnoinline -fno-inline
fi
: ${HAVE_SETLOCALE_CTYPE=0} : ${HAVE_SETLOCALE_CTYPE=0}
check_categories=$check_categories,smksh check_categories=$check_categories,smksh

20
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #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 */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -2792,7 +2792,7 @@ x_expand(int c __unused)
x_delete(end - start, false); x_delete(end - start, false);
for (i = 0; i < nwords;) { for (i = 0; i < nwords;) {
if (x_escape(words[i], strlen(words[i]), x_do_ins) < 0 || 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); x_e_putc2(7);
return KSTD; return KSTD;
} }
@ -2838,7 +2838,7 @@ do_complete(int flags, /* XCF_{COMMAND,FILE,COMMAND_FILE} */
} }
/* add space if single non-dir match */ /* add space if single non-dir match */
if (nwords == 1 && words[0][nlen - 1] != '/') { if (nwords == 1 && words[0][nlen - 1] != '/') {
x_ins(space); x_ins(" ");
completed = 1; completed = 1;
} }
if (type == CT_COMPLIST && !completed) { if (type == CT_COMPLIST && !completed) {
@ -4255,10 +4255,14 @@ vi_cmd(int argcnt, const char *cmd)
argcnt = source->line + 1 argcnt = source->line + 1
- (hlast - hnum); - (hlast - hnum);
} }
shf_snprintf(es->cbuf, es->cbufsize, if (argcnt)
argcnt ? "%s %d" : "%s", shf_snprintf(es->cbuf, es->cbufsize, "%s %d",
"fc -e ${VISUAL:-${EDITOR:-vi}} --", "fc -e ${VISUAL:-${EDITOR:-vi}} --",
argcnt); argcnt);
else
strlcpy(es->cbuf,
"fc -e ${VISUAL:-${EDITOR:-vi}} --",
es->cbufsize);
es->linelen = strlen(es->cbuf); es->linelen = strlen(es->cbuf);
return 2; return 2;
@ -4376,7 +4380,7 @@ vi_cmd(int argcnt, const char *cmd)
argcnt++; argcnt++;
p++; p++;
} }
if (putbuf(space, 1, 0) != 0) if (putbuf(" ", 1, 0) != 0)
argcnt = -1; argcnt = -1;
else if (putbuf(sp, argcnt, 0) != 0) else if (putbuf(sp, argcnt, 0) != 0)
argcnt = -1; argcnt = -1;
@ -5216,7 +5220,7 @@ expand_word(int cmd)
rval = -1; rval = -1;
break; break;
} }
if (++i < nwords && putbuf(space, 1, 0) != 0) { if (++i < nwords && putbuf(" ", 1, 0) != 0) {
rval = -1; rval = -1;
break; break;
} }
@ -5325,7 +5329,7 @@ complete_word(int cmd, int count)
/* If not a directory, add a space to the end... */ /* If not a directory, add a space to the end... */
if (match_len > 0 && match[match_len - 1] != '/') if (match_len > 0 && match[match_len - 1] != '/')
rval = putbuf(space, 1, 0); rval = putbuf(" ", 1, 0);
} }
x_free_words(nwords, words); x_free_words(nwords, words);

12
exec.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #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 **, static int comexec(struct op *, struct tbl *volatile, const char **,
int volatile); int volatile);
@ -70,8 +70,8 @@ execute(struct op *volatile t,
shf_fprintf(shl_out, "%s", shf_fprintf(shl_out, "%s",
substitute(str_val(global("PS4")), 0)); substitute(str_val(global("PS4")), 0));
for (i = 0; ap[i]; i++) for (i = 0; ap[i]; i++)
shf_fprintf(shl_out, "%s%s", ap[i], shf_fprintf(shl_out, "%s%c", ap[i],
ap[i + 1] ? space : newline); ap[i + 1] ? ' ' : '\n');
shf_flush(shl_out); shf_flush(shl_out);
} }
if (ap[0]) if (ap[0])
@ -95,7 +95,7 @@ execute(struct op *volatile t,
*/ */
if (tp && tp->type == CSHELL && if (tp && tp->type == CSHELL &&
(tp->flag & SPEC_BI)) (tp->flag & SPEC_BI))
errorf(null); errorf("");
/* Deal with FERREXIT, quitenv(), etc. */ /* Deal with FERREXIT, quitenv(), etc. */
goto Break; goto Break;
} }
@ -486,8 +486,8 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
if (i == 0) if (i == 0)
shf_fprintf(shl_out, "%s", shf_fprintf(shl_out, "%s",
substitute(str_val(global("PS4")), 0)); substitute(str_val(global("PS4")), 0));
shf_fprintf(shl_out, "%s%s", cp, shf_fprintf(shl_out, "%s%c", cp,
t->vars[i + 1] ? space : newline); t->vars[i + 1] ? ' ' : '\n');
if (!t->vars[i + 1]) if (!t->vars[i + 1])
shf_flush(shl_out); shf_flush(shl_out);
} }

4
expr.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #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[] */ /* The order of these enums is constrained by the order of opinfo[] */
enum token { enum token {
@ -178,7 +178,7 @@ v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok,
if (i == LAEXPR) { if (i == LAEXPR) {
if (error_ok == KSH_RETURN_ERROR) if (error_ok == KSH_RETURN_ERROR)
return (0); return (0);
errorf(null); errorf("");
} }
unwind(i); unwind(i);
/* NOTREACHED */ /* NOTREACHED */

12
funcs.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #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 int
c_cd(const char **wp) c_cd(const char **wp)
@ -494,7 +494,7 @@ c_whence(const char **wp)
break; break;
} }
if (vflag || !ret) if (vflag || !ret)
shprintf(newline); shf_putc('\n', shl_stdout);
} }
return ret; return ret;
} }
@ -793,7 +793,7 @@ c_typeset(const char **wp)
else else
print_value_quoted(s); print_value_quoted(s);
} }
shprintf(newline); shf_putc('\n', shl_stdout);
} }
/* Only report first 'element' of an array with /* Only report first 'element' of an array with
* no set elements. * no set elements.
@ -887,7 +887,7 @@ c_alias(const char **wp)
shf_putc('=', shl_stdout); shf_putc('=', shl_stdout);
print_value_quoted(ap->val.s); 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); shf_putc('=', shl_stdout);
print_value_quoted(ap->val.s); print_value_quoted(ap->val.s);
} }
shprintf(newline); shf_putc('\n', shl_stdout);
} else { } else {
shprintf("%s alias not found\n", alias); shprintf("%s alias not found\n", alias);
rv = 1; rv = 1;
@ -1142,7 +1142,7 @@ c_kill(const char **wp)
"Usage: kill [ -s signame | -signum | -signame ] {pid|job}...\n" "Usage: kill [ -s signame | -signum | -signame ] {pid|job}...\n"
" kill -l [exit_status]\n"); " kill -l [exit_status]\n");
#endif #endif
bi_errorf(null); bi_errorf("");
return 1; return 1;
} }

View File

@ -3,7 +3,7 @@
#include "sh.h" #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]; Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign; static struct sigaction Sigact_ign;
@ -177,8 +177,10 @@ c_fc(const char **wp)
for (hp = rflag ? hlast : hfirst; for (hp = rflag ? hlast : hfirst;
hp >= hfirst && hp <= hlast; hp += rflag ? -1 : 1) { hp >= hfirst && hp <= hlast; hp += rflag ? -1 : 1) {
shf_fprintf(shl_stdout, nfmt, if (!nflag)
hist_source->line - (int) (histptr - hp)); shf_fprintf(shl_stdout, "%d",
hist_source->line - (int)(histptr - hp));
shf_putc('\t', shl_stdout);
/* print multi-line commands correctly */ /* print multi-line commands correctly */
for (s = *hp; (t = strchr(s, '\n')); s = t) for (s = *hp; (t = strchr(s, '\n')); s = t)
shf_fprintf(shl_stdout, "%.*s\t", shf_fprintf(shl_stdout, "%.*s\t",

8
jobs.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #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! */ /* Order important! */
#define PRUNNING 0 #define PRUNNING 0
@ -632,7 +632,7 @@ j_resume(const char *cp, int bg)
} }
shprintf("%s%s", p->command, p->next ? "| " : null); shprintf("%s%s", p->command, p->next ? "| " : null);
} }
shprintf(newline); shf_putc('\n', shl_stdout);
shf_flush(shl_stdout); shf_flush(shl_stdout);
if (running) if (running)
j->state = PRUNNING; j->state = PRUNNING;
@ -1283,7 +1283,7 @@ j_print(Job *j, int how, struct shf *shf)
while (p && p->state == state && p->status == status) { while (p && p->state == state && p->status == status) {
if (how == JP_LONG) if (how == JP_LONG)
shf_fprintf(shf, "%s%5d %-20s %s%s", filler, shf_fprintf(shf, "%s%5d %-20s %s%s", filler,
(int)p->pid, space, p->command, (int)p->pid, " ", p->command,
p->next ? "|" : null); p->next ? "|" : null);
else if (how == JP_MEDIUM) else if (how == JP_MEDIUM)
shf_fprintf(shf, " %s%s", p->command, shf_fprintf(shf, " %s%s", p->command,
@ -1292,7 +1292,7 @@ j_print(Job *j, int how, struct shf *shf)
} }
} }
if (output) if (output)
shf_fprintf(shf, newline); shf_putc('\n', shf);
} }
/* Convert % sequence to job /* Convert % sequence to job

8
lex.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #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 /* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state. */ * needed for each particular state. */
@ -905,7 +905,7 @@ yyerror(const char *fmt, ...)
va_start(va, fmt); va_start(va, fmt);
shf_vfprintf(shl_out, fmt, va); shf_vfprintf(shl_out, fmt, va);
va_end(va); va_end(va);
errorf(null); errorf("");
} }
/* /*
@ -967,10 +967,10 @@ getsc__(void)
case SWORDSEP: case SWORDSEP:
if (*s->u.strv == NULL) { if (*s->u.strv == NULL) {
s->start = s->str = newline; s->start = s->str = "\n";
s->type = SEOF; s->type = SEOF;
} else { } else {
s->start = s->str = space; s->start = s->str = " ";
s->type = SWORDS; s->type = SWORDS;
} }
break; break;

4
main.c
View File

@ -13,7 +13,7 @@
#include <locale.h> #include <locale.h>
#endif #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; extern char **environ;
@ -484,7 +484,7 @@ shell(Source * volatile s, volatile int toplevel)
case LSHELL: case LSHELL:
if (interactive) { if (interactive) {
if (i == LINTR) if (i == LINTR)
shellf(newline); shellf("\n");
/* Reset any eof that was read as part of a /* Reset any eof that was read as part of a
* multiline command. * multiline command.
*/ */

8
misc.c
View File

@ -6,7 +6,7 @@
#include <grp.h> #include <grp.h>
#endif #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); MKSH_SH_H_ID);
#undef USE_CHVT #undef USE_CHVT
@ -206,7 +206,7 @@ printoptions(int verbose)
for (i = 0; i < NELEM(options); i++) for (i = 0; i < NELEM(options); i++)
if (Flag(i) && options[i].name) if (Flag(i) && options[i].name)
shprintf(" -o %s", 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) ? "" : argv[0],
(go->flags & GF_NONAME) ? "" : ": ", c); (go->flags & GF_NONAME) ? "" : ": ", c);
if (go->flags & GF_ERROR) if (go->flags & GF_ERROR)
bi_errorf(null); bi_errorf("");
} }
return '?'; 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) ? "" : argv[0],
(go->flags & GF_NONAME) ? "" : ": ", c); (go->flags & GF_NONAME) ? "" : ": ", c);
if (go->flags & GF_ERROR) if (go->flags & GF_ERROR)
bi_errorf(null); bi_errorf("");
return '?'; return '?';
} }
go->p = 0; go->p = 0;

4
sh.h
View File

@ -8,7 +8,7 @@
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $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 $ */ /* $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" #define MKSH_VERSION "R30 2007/07/17"
#if HAVE_SYS_PARAM_H #if HAVE_SYS_PARAM_H
@ -432,8 +432,6 @@ enum sh_flag {
EXTERN char shell_flags [FNFLAGS]; EXTERN char shell_flags [FNFLAGS];
EXTERN char null [] I__(""); /* null value for variable */ EXTERN char null [] I__(""); /* null value for variable */
EXTERN char space [] I__(" ");
EXTERN char newline [] I__("\n");
enum temp_type { enum temp_type {
TT_HEREDOC_EXP, /* expanded heredoc */ TT_HEREDOC_EXP, /* expanded heredoc */

6
var.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #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 * Variables
@ -341,7 +341,7 @@ setstr(struct tbl *vq, const char *s, int error_ok)
if ((vq->flag & RDONLY) && !no_ro_check) { if ((vq->flag & RDONLY) && !no_ro_check) {
warningf(true, "%s: is read only", vq->name); warningf(true, "%s: is read only", vq->name);
if (!error_ok) if (!error_ok)
errorf(null); errorf("");
return 0; return 0;
} }
if (!(vq->flag&INTEGER)) { /* string dest */ if (!(vq->flag&INTEGER)) { /* string dest */
@ -690,7 +690,7 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
} }
} }
if (!ok) if (!ok)
errorf(null); errorf("");
} }
if (val != NULL) { if (val != NULL) {