switch ${%foo} to wcswidth-like behaviour – slightly problematic, and

the “set +U” case isn’t even handled

committed to branch because I’d like to get more input on this, for now
This commit is contained in:
tg
2009-11-28 14:21:47 +00:00
parent 7063a9a921
commit 883d9d99b3
9 changed files with 37 additions and 21 deletions

7
eval.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.74 2009/11/22 13:49:04 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.75 2009/11/28 14:21:43 tg Exp $");
/*
* string expansion
@ -949,12 +949,13 @@ varsub(Expand *xp, const char *sp, const char *word,
} else {
p = str_val(global(sp));
zero_ok = p != null;
c = stype == '#' ? (int)utflen(p) : utf_mbswidth(p);
c = stype == '#' ? (int)utflen(p) :
utf_mbswidth(p, false);
}
if (Flag(FNOUNSET) && c == 0 && !zero_ok)
errorf("%s: parameter not set", sp);
*stypep = 0; /* unqualified variable/string substitution */
xp->str = shf_smprintf("%u", (unsigned int)c);
xp->str = shf_smprintf("%d", c);
return (XSUB);
}