after enough complaints by POSIX sh advocates,

• make parsing numbers with leading digit-zero as octal independent of
  mksh/lksh and dependent on set -o posix; adjust manpages to match
• warn about these changes and why mksh uses 32-bit consistent arithmetics
  and point people to lksh for host-long undefined-behaviour arithmetics
• point out, explicitly, that it is *legal* for the operating environment
  to make 'print $((2147483647 + 1))' (on a 32-bit system; adjust for a
  64-bit system) to run 'rm -rf ~ /' instead
This commit is contained in:
tg
2013-04-27 18:50:25 +00:00
parent 496988e27a
commit dc94c3d205
5 changed files with 59 additions and 39 deletions

6
var.c
View File

@ -27,7 +27,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.170 2013/04/07 14:11:54 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.171 2013/04/27 18:50:25 tg Exp $");
/*-
* Variables
@ -495,14 +495,12 @@ getint(struct tbl *vp, mksh_ari_u *nump, bool arith)
base = 16;
have_base = true;
}
#ifdef MKSH_LEGACY_MODE
if (arith && s[0] == '0' && ksh_isdigit(s[1]) &&
if (Flag(FPOSIX) && arith && s[0] == '0' && ksh_isdigit(s[1]) &&
!(vp->flag & ZEROFIL)) {
/* interpret as octal (deprecated) */
base = 8;
have_base = true;
}
#endif
while ((c = *s++)) {
if (c == '-') {
neg = true;