From 26f15bd938b3da2d0bb4dba02b3bdbf9e5f10a7e Mon Sep 17 00:00:00 2001 From: tg Date: Wed, 3 Sep 2014 19:22:51 +0000 Subject: [PATCH] =?UTF-8?q?permit=20$1,=20$!,=20etc.=20to=20be=20nameref?= =?UTF-8?q?=E2=80=99d=20again=20($=5F=20was);=20spotted=20by=20Jb=5Fboin,?= =?UTF-8?q?=2010x!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Build.sh | 6 +++--- Makefile | 4 ++-- check.t | 6 +++--- sh.h | 6 +++--- var.c | 19 +++++++++++++++++-- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Build.sh b/Build.sh index 8edff14..5aa1a82 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.663 2014/07/04 11:03:52 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.664 2014/09/03 19:22:48 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014 @@ -1784,7 +1784,7 @@ else #define EXTERN #define MKSH_INCLUDES_ONLY #include "sh.h" - __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.663 2014/07/04 11:03:52 tg Exp $"); + __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.664 2014/09/03 19:22:48 tg Exp $"); int main(void) { printf("Hello, World!\n"); return (isatty(0)); } EOF case $cm in @@ -2310,7 +2310,7 @@ addsrcs '!' HAVE_STRLCPY strlcpy.c addsrcs USE_PRINTF_BUILTIN printf.c test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose" -add_cppflags -DMKSH_BUILD_R=501 +add_cppflags -DMKSH_BUILD_R=502 $e $bi$me: Finished configuration testing, now producing output.$ao diff --git a/Makefile b/Makefile index fd3bd20..a87b01b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/Makefile,v 1.135 2014/06/24 20:47:42 tg Exp $ +# $MirOS: src/bin/mksh/Makefile,v 1.136 2014/09/03 19:22:48 tg Exp $ #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014 @@ -55,7 +55,7 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 -DMKSH_DISABLE_DEPRECATED \ -DHAVE_SETGROUPS=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 \ -DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \ -DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \ - -DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=501 + -DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=502 CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U} CPPFLAGS+= -I. COPTS+= -std=c89 -Wall diff --git a/check.t b/check.t index 234e541..fea458e 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.657 2014/07/29 17:56:31 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.658 2014/09/03 19:22:49 tg Exp $ # OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44 #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -27,7 +27,7 @@ # http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD expected-stdout: - @(#)MIRBSD KSH R50 2014/07/28 + @(#)MIRBSD KSH R50 2014/09/03 description: Check version of shell. stdin: @@ -36,7 +36,7 @@ name: KSH_VERSION category: shell:legacy-no --- expected-stdout: - @(#)LEGACY KSH R50 2014/07/28 + @(#)LEGACY KSH R50 2014/09/03 description: Check version of legacy shell. stdin: diff --git a/sh.h b/sh.h index 4723d56..57e40c9 100644 --- a/sh.h +++ b/sh.h @@ -169,9 +169,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.693 2014/07/28 21:45:45 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.694 2014/09/03 19:22:50 tg Exp $"); #endif -#define MKSH_VERSION "R50 2014/07/28" +#define MKSH_VERSION "R50 2014/09/03" /* arithmetic types: C implementation */ #if !HAVE_CAN_INTTYPES @@ -533,7 +533,7 @@ char *ucstrstr(char *, const char *); #define mkssert(e) do { } while (/* CONSTCOND */ 0) #endif -#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 501) +#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 502) #error Must run Build.sh to compile this. extern void thiswillneverbedefinedIhope(void); int diff --git a/var.c b/var.c index ef114e1..91e3068 100644 --- a/var.c +++ b/var.c @@ -28,7 +28,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.180 2014/06/26 20:36:02 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.181 2014/09/03 19:22:51 tg Exp $"); /*- * Variables @@ -789,8 +789,22 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base) } /* check target value for being a valid variable name */ ccp = skip_varname(qval, false); - if (ccp == qval) + if (ccp == qval) { + if (ksh_isdigit(qval[0])) { + int c; + + if (getn(qval, &c)) + goto nameref_rhs_checked; + } else if (qval[1] == '\0') switch (qval[0]) { + case '$': + case '!': + case '?': + case '#': + case '-': + goto nameref_rhs_checked; + } errorf("%s: %s", var, "empty nameref target"); + } len = (*ccp == '[') ? array_ref_len(ccp) : 0; if (ccp[len]) { /* @@ -801,6 +815,7 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base) errorf("%s: %s", qval, "nameref target not a valid parameter name"); } + nameref_rhs_checked: /* prevent nameref loops */ while (qval) { if (!strcmp(qval, tvar))