fix \u0000 and \x00 being ignored in $'…' and print +r expansion

This commit is contained in:
tg 2015-10-24 19:46:10 +00:00
parent 1a4f644d6e
commit 7a47656efe
3 changed files with 34 additions and 8 deletions

29
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.711 2015/10/13 21:39:53 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.712 2015/10/24 19:46:07 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -30,7 +30,7 @@
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
@(#)MIRBSD KSH R51 2015/10/09
@(#)MIRBSD KSH R51 2015/10/24
description:
Check version of shell.
stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: shell:legacy-no
---
expected-stdout:
@(#)LEGACY KSH R51 2015/10/09
@(#)LEGACY KSH R51 2015/10/24
description:
Check version of legacy shell.
stdin:
@ -8538,13 +8538,36 @@ expected-stdout:
0
1
---
name: varexpand-funny-chars
description:
Check some characters
XXX \uEF80 is asymmetric, possibly buggy so we dont check this
stdin:
x=$'<\x00>'; typeset -p x
x=$'<\x01>'; typeset -p x
x=$'<\u0000>'; typeset -p x
x=$'<\u0001>'; typeset -p x
expected-stdout:
typeset x='<'
typeset x=$'<\001>'
typeset x='<'
typeset x=$'<\001>'
---
name: print-funny-chars
description:
Check print builtin's capability to output designated characters
stdin:
print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
print '<\x00>'
print '<\x01>'
print '<\u0000>'
print '<\u0001>'
expected-stdout:
<däÛÃâ¬Ã@>
<>
<>
<>
<>
---
name: print-bksl-c
description:

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.286 2015/10/09 21:36:55 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.287 2015/10/24 19:46:09 tg Exp $");
#if HAVE_KILLPG
/*
@ -431,8 +431,10 @@ c_print(const char **wp)
char ts[4];
ts[utf_wctomb(ts, c - 0x100)] = 0;
for (c = 0; ts[c]; ++c)
c = 0;
do {
Xput(xs, xp, ts[c]);
} while (ts[++c]);
continue;
}
}

7
lex.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.212 2015/10/09 19:29:48 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.213 2015/10/24 19:46:10 tg Exp $");
/*
* states while lexing word
@ -601,10 +601,11 @@ yylex(int cf)
} else {
cz = utf_wctomb(ts, c2 - 0x100);
ts[cz] = 0;
for (cz = 0; ts[cz]; ++cz) {
cz = 0;
do {
*wp++ = QCHAR;
*wp++ = ts[cz];
}
} while (ts[++cz]);
}
}
} else if (!statep->ls_bool) {