22529: multibyte conversion in math expressions

This commit is contained in:
Peter Stephenson 2006-06-30 09:41:34 +00:00
parent 92737d2c42
commit 4cd7b957f3
5 changed files with 48 additions and 9 deletions

View file

@ -1,3 +1,8 @@
2006-06-30 Peter Stephenson <pws@csr.com>
* 22529: Doc/Zsh/arith.yo, Src/math.c, Src/utils.c,
Test/D07multibyte.ztst: multibyte conversion in math expressions.
2006-06-28 Peter Stephenson <pws@csr.com>
* 22526: Doc/Zsh/expn.yo, Src/subst.c: enhance${(#)...} to output

View file

@ -129,13 +129,14 @@ the tt(zmodload) builtin to provide standard floating point mathematical
functions.
An expression of the form `tt(##)var(x)' where var(x) is any character
sequence such as `tt(a)', `tt(^A)', or `tt(\M-\C-x)' gives the ASCII
value of this character and an expression of the form `tt(#)var(foo)'
gives the ASCII value of the first character of the value of the
parameter var(foo). Note that this is different from the expression
`tt($#)var(foo)', a standard parameter substitution which gives the
length of the parameter var(foo). `tt(#\)' is accepted instead of
`tt(##)', but its use is deprecated.
sequence such as `tt(a)', `tt(^A)', or `tt(\M-\C-x)' gives the value of
this character and an expression of the form `tt(#)var(foo)' gives the
value of the first character of the contents of the parameter var(foo).
Character values are according to the character set used in the current
locale; for multibyte character handling the option tt(MULTIBYTE) must be
set. Note that this form is different from `tt($#)var(foo)', a standard
parameter substitution which gives the length of the parameter var(foo).
`tt(#\)' is accepted instead of `tt(##)', but its use is deprecated.
Named parameters and subscripted arrays can be referenced by name within an
arithmetic expression without using the parameter expansion syntax. For

View file

@ -549,8 +549,20 @@ getcvar(char *s)
queue_signals();
if (!(t = getsparam(s)))
mn.u.l = 0;
else
mn.u.l = STOUC(*t == Meta ? t[1] ^ 32 : *t);
else {
#ifdef MULTIBYTE_SUPPORT
if (isset(MULTIBYTE)) {
wint_t wc;
(void)mb_metacharlenconv(t, &wc);
if (wc != WEOF) {
mn.u.l = (zlong)wc;
unqueue_signals();
return mn;
}
}
#endif
mn.u.l = STOUC(*t == Meta ? t[1] ^ 32 : *t);
}
unqueue_signals();
return mn;
}

View file

@ -4410,6 +4410,17 @@ getkeystring(char *s, int *len, int fromwhere, int *misc)
(fromwhere == 2 || fromwhere == 5 || fromwhere == 6)) {
control = 1;
continue;
#ifdef MULTIBYTE_SUPPORT
} else if (fromwhere == 6 && isset(MULTIBYTE) && STOUC(*s) > 127) {
wint_t wc;
int len;
len = mb_metacharlenconv(s, &wc);
if (wc != WEOF) {
*misc = (int)wc;
return s + len;
}
#endif
} else if (*s == Meta)
*t++ = *++s ^ 32;
else

View file

@ -155,3 +155,13 @@
>ølaf ødd øpened án encyclopædia
>Ølaf Ødd Øpened Án Encyclopædia
>Ølaf Ødd Øpened Án Encyclopædia
print $(( ##¥ ))
pound=£
print $(( #pound ))
alpha=α
print $(( ##α )) $(( #alpha ))
0:Conversion to Unicode in mathematical expressions
>165
>163
>945 945