improve globbing:

• a=blöd; print ${a%???} → now printf 'b' not 'bl' in UTF-8 mode
• a=hä; print ${a%?} still broken
This commit is contained in:
tg 2009-11-21 22:30:36 +00:00
parent d02e6be6cf
commit 6e67920bef
2 changed files with 38 additions and 2 deletions

34
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.338 2009/11/21 22:29:12 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.339 2009/11/21 22:30:34 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 $
@ -1333,6 +1333,38 @@ expected-stdout:
# 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
# 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
---
name: eglob-utf8-1
description:
UTF-8 mode differences for eglobbing
stdin:
s=blÃd
set +U
print 1: ${s%???} .
print 2: ${s/b???d/x} .
set -U
print 3: ${s%???} .
print 4: ${s/b??d/x} .
x=
print 5: ${x%?} ${x%%?} .
x=äh
print 6: ${x#?} ${x##?} .
x=<EFBFBD>
print 7: ${x%?} ${x%%?} .
x=¤
print 8: ${x%?} ${x%%?} .
x=ä½
print 9: ${x%?} ${x%%?} .
expected-stdout:
1: bl .
2: x .
3: b .
4: x .
5: n n .
6: h h .
7: .
8: ¤ ¤ .
9: .
---
name: glob-bad-1
description:
Check that globbing isn't done when glob has syntax error

6
misc.c
View File

@ -29,7 +29,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.129 2009/11/09 23:35:10 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.130 2009/11/21 22:30:36 tg Exp $");
unsigned char chtypes[UCHAR_MAX + 1]; /* type bits for unsigned char */
@ -581,6 +581,10 @@ do_gmatch(const unsigned char *s, const unsigned char *se,
case '?':
if (sc == 0)
return (0);
if (UTFMODE) {
--s;
s += utf_ptradj(s);
}
break;
case '*':