diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2005-09-09 20:34:42 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2005-09-09 20:34:42 +0000 |
commit | d33c6e502ab4d4398efa797702b6b115e6f5ff41 (patch) | |
tree | d0c5ed4be35dd4a11d99050dbac0138ed241b12b /Src/utils.c | |
parent | 58b9e731da1f2a4eac68e06e986c9c25adafc36e (diff) | |
download | zsh-d33c6e502ab4d4398efa797702b6b115e6f5ff41.tar.gz zsh-d33c6e502ab4d4398efa797702b6b115e6f5ff41.tar.xz zsh-d33c6e502ab4d4398efa797702b6b115e6f5ff41.zip |
21722: fix multibyte word stuff
Diffstat (limited to 'Src/utils.c')
-rw-r--r-- | Src/utils.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Src/utils.c b/Src/utils.c index 8a887fa37..8b1326444 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -2469,6 +2469,42 @@ inittyptab(void) typtab[bangchar] |= ISPECIAL; } + +#ifdef ZLE_UNICODE_SUPPORT +/* + * iword() macro extended to support wide characters. + */ + +/**/ +mod_export int +wcsiword(wchar_t c) +{ + int len; + VARARR(char, outstr, MB_CUR_MAX); + /* + * Strategy: the shell requires that the multibyte representation + * be an extension of ASCII. So see if converting the character + * produces an ASCII character. If it does, use iword on that. + * If it doesn't, use iswalnum on the original character. This + * is pretty good most of the time. + * + * TODO: extend WORDCHARS to handle multibyte chars by some kind + * of hierarchical list or hash table. + */ + len = wctomb(outstr, c); + + if (len == 0) { + /* NULL is special */ + return iword(0); + } else if (len == 1 && isascii(*outstr)) { + return iword(*outstr); + } else { + return iswalnum(c); + } +} +#endif + + /**/ mod_export char ** arrdup(char **s) |