first cut at LP#1381993 (probably incomplete) plus test coverage

also remove fbsd testsuite link, it’s gone during cvs→svn of theirs ☹
This commit is contained in:
tg 2014-10-19 21:53:08 +00:00
parent cf2609f3fa
commit 44dc99cb35
4 changed files with 36 additions and 15 deletions

29
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.665 2014/10/19 21:39:35 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.666 2014/10/19 21:53:05 tg Exp $
# OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -22,9 +22,6 @@
#-
# You may also want to test IFS with the script at
# http://www.research.att.com/~gsf/public/ifs.sh
#
# More testsuites at:
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout:
@(#)MIRBSD KSH R50 2014/10/19
@ -4177,6 +4174,30 @@ expected-stdout:
<A B C>
=b8iqa
---
name: IFS-subst-6
description:
Regression wrt. vector expansion in trim
stdin:
showargs() { for x in "$@"; do echo -n "<$x> "; done; echo .; }
IFS=
x=abc
set -- a b
showargs ${x#$*}
expected-stdout:
<c> .
---
name: IFS-subst-7
description:
ksh93 bug wrt. vector expansion in trim
stdin:
showargs() { for x in "$@"; do echo -n "<$x> "; done; echo .; }
IFS="*"
a=abcd
set -- '' c
showargs "$*" ${a##"$*"}
expected-stdout:
<*c> <abcd> .
---
name: IFS-arith-1
description:
http://austingroupbugs.net/view.php?id=832

14
eval.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.157 2014/10/19 21:39:37 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.158 2014/10/19 21:53:07 tg Exp $");
/*
* string expansion
@ -246,7 +246,7 @@ expand(
/* for alias, readonly, set, typeset commands */
if ((f & DOVACHECK) && is_wdvarassign(ccp)) {
f &= ~(DOVACHECK | DOBLANK | DOGLOB | DOTILDE);
f |= DOASNTILDE | DOASNFIELD;
f |= DOASNTILDE | DOSCALAR;
}
if (Flag(FNOGLOB))
f &= ~DOGLOB;
@ -622,7 +622,7 @@ expand(
case '%':
/* ! DOBLANK,DOBRACE,DOTILDE */
f = (f & DONTRUNCOMMAND) |
DOPAT | DOTEMP;
DOPAT | DOTEMP | DOSCALAR;
st->quotew = quote = 0;
/*
* Prepend open pattern (so |
@ -747,7 +747,7 @@ expand(
if (f & DOBLANK)
doblank++;
st = st->prev;
word = quote || (!*x.str && (f & DOASNFIELD)) ? IFS_WORD : IFS_IWS;
word = quote || (!*x.str && (f & DOSCALAR)) ? IFS_WORD : IFS_IWS;
continue;
case '?': {
char *s = Xrestpos(ds, dp, st->base);
@ -763,7 +763,7 @@ expand(
case 0x100 | 'Q':
dp = Xrestpos(ds, dp, st->base);
type = XSUB;
word = quote || (!*x.str && (f & DOASNFIELD)) ? IFS_WORD : IFS_IWS;
word = quote || (!*x.str && (f & DOSCALAR)) ? IFS_WORD : IFS_IWS;
if (f & DOBLANK)
doblank++;
st = st->prev;
@ -839,8 +839,8 @@ expand(
continue;
}
c = ifs0;
if ((f & DOASNFIELD)) {
/* assignment, do not field-split */
if ((f & DOSCALAR)) {
/* do not field-split */
if (x.split) {
c = ' ';
break;

4
exec.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.136 2014/10/12 21:58:50 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.137 2014/10/19 21:53:07 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -640,7 +640,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
for (i = 0; t->vars[i]; i++) {
/* do NOT lookup in the new var/fn block just created */
e->loc = l_expand;
cp = evalstr(t->vars[i], DOASNTILDE | DOASNFIELD);
cp = evalstr(t->vars[i], DOASNTILDE | DOSCALAR);
e->loc = l_assign;
if (Flag(FXTRACE)) {
const char *ccp;

4
sh.h
View File

@ -169,7 +169,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.700 2014/10/19 20:56:33 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.701 2014/10/19 21:53:08 tg Exp $");
#endif
#define MKSH_VERSION "R50 2014/10/19"
@ -1396,7 +1396,7 @@ struct ioword {
#define DOVACHECK BIT(9) /* var assign check (for typeset, set, etc) */
#define DOMARKDIRS BIT(10) /* force markdirs behaviour */
#define DOTCOMEXEC BIT(11) /* not an eval flag, used by sh -c hack */
#define DOASNFIELD BIT(12) /* is assignment, change field handling */
#define DOSCALAR BIT(12) /* change field handling to non-list context */
#define X_EXTRA 20 /* this many extra bytes in X string */