From 5386859b3f99bd84a486eaa6e44864cfa9aa6fcc Mon Sep 17 00:00:00 2001 From: tg Date: Mon, 25 Jun 2012 16:31:18 +0000 Subject: [PATCH] also get back octal crap for LEGACY KSH --- check.t | 12 +++++++++++- var.c | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/check.t b/check.t index 8ba1d61..e5f8ebd 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.540 2012/06/25 16:17:51 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.541 2012/06/25 16:31:16 tg Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ @@ -3653,11 +3653,21 @@ name: integer-base-check-flat description: Check behaviour does not match POSuX, because a not type-safe scripting language has *no* business interpreting "010" as octal +category: shell:legacy-no stdin: echo :$((10)).$((010)).$((0x10)). expected-stdout: :10.10.16. --- +name: integer-base-check-flat-legacy +description: + Check behaviour matches POSuX for LEGACY KSH +category: shell:legacy-yes +stdin: + echo :$((10)).$((010)).$((0x10)). +expected-stdout: + :10.8.16. +--- name: integer-base-check-numeric-from description: Check behaviour for base one to 36, and that 37 errors out diff --git a/var.c b/var.c index bbae1a1..71efb4d 100644 --- a/var.c +++ b/var.c @@ -27,7 +27,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.149 2012/05/09 23:21:00 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.150 2012/06/25 16:31:18 tg Exp $"); /*- * Variables @@ -493,6 +493,14 @@ getint(struct tbl *vp, mksh_ari_t *nump, bool arith) base = 16; have_base = true; } +#ifdef MKSH_LEGACY_MODE + if (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++;