draft a testcase to understand the problem fixed by cid 1004BBF77B81D30DA7C

and make it actually work: the OpenBSD fix failed since 1004BBDD84556472D84
This commit is contained in:
tg 2010-04-09 19:16:31 +00:00
parent 3fa79f3ea4
commit 14ea7e9038
3 changed files with 21 additions and 11 deletions

13
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.372 2010/04/09 14:46:43 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.373 2010/04/09 19:16:29 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 $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2010/04/08
@(#)MIRBSD KSH R39 2010/04/09
description:
Check version of shell.
stdin:
@ -5837,6 +5837,15 @@ expected-stdout:
z w
v u
---
name: varexpand-null-2
description:
Ensure empty strings, when quoted, are expanded as empty strings
stdin:
printf '<%s> ' 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
echo .
expected-stdout:
<1> <> <2> <> <+> <> <3> <> <+> <> .
---
name: print-funny-chars
description:
Check print builtin's capability to output designated characters

15
eval.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.85 2010/04/09 18:53:29 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.86 2010/04/09 19:16:30 tg Exp $");
/*
* string expansion
@ -188,7 +188,8 @@ typedef struct SubType {
short stype; /* [=+-?%#] action after expanded word */
short base; /* begin position of expanded word */
short f; /* saved value of f (DOPAT, etc) */
short quote; /* saved value of quote (for ${..[%#]..}) */
uint8_t quotep; /* saved value of quote (for ${..[%#]..}) */
uint8_t quotew; /* saved value of quote (for ${..[+-=]..}) */
} SubType;
void
@ -263,7 +264,7 @@ expand(const char *cp, /* input word */
quote = 1;
continue;
case CQUOTE:
quote = st->quote; /* XXX correct? */
quote = st->quotew;
continue;
case COMSUB:
tilde_ok = 0;
@ -352,7 +353,7 @@ expand(const char *cp, /* input word */
st->base = Xsavepos(ds, dp);
st->f = f;
st->var = x.var;
st->quote = quote;
st->quotew = st->quotep = quote;
/* skip qualifier(s) */
if (stype)
sp += slen;
@ -517,7 +518,7 @@ expand(const char *cp, /* input word */
/* ! DOBLANK,DOBRACE_,DOTILDE */
f = DOPAT | (f&DONTRUNCOMMAND) |
DOTEMP_;
st->quote = quote = 0;
st->quotew = quote = 0;
/* Prepend open pattern (so |
* in a trim will work as
* expected)
@ -567,7 +568,7 @@ expand(const char *cp, /* input word */
sp++; /* ({) skip the } or x */
tilde_ok = 0; /* in case of ${unset:-} */
*dp = '\0';
quote = st->quote;
quote = st->quotew;
f = st->f;
if (f&DOBLANK)
doblank--;
@ -583,7 +584,7 @@ expand(const char *cp, /* input word */
*/
x.str = trimsub(str_val(st->var),
dp, st->stype);
if (x.str[0] != '\0' || st->quote)
if (x.str[0] != '\0' || st->quotep)
type = XSUB;
else
type = XNULLSUB;

4
sh.h
View File

@ -150,9 +150,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.387 2010/04/08 13:21:08 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.388 2010/04/09 19:16:31 tg Exp $");
#endif
#define MKSH_VERSION "R39 2010/04/08"
#define MKSH_VERSION "R39 2010/04/09"
#ifndef MKSH_INCLUDES_ONLY