summaryrefslogtreecommitdiff
path: root/Src/Zle/compmatch.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2006-01-12 00:51:50 +0000
committerWayne Davison <wayned@users.sourceforge.net>2006-01-12 00:51:50 +0000
commit542797377aabd9af067909fd14af08b1081b250c (patch)
tree653d363b018b51c0fdf62723f33a370d53b929f3 /Src/Zle/compmatch.c
parente46d08523fd44432448c9c15bcec5977fd817e7d (diff)
downloadzsh-542797377aabd9af067909fd14af08b1081b250c.tar.gz
zsh-542797377aabd9af067909fd14af08b1081b250c.zip
- When mbrtowc() returns -2 when given all the remaining chars in a
string, set an end-of-line flag and avoid calling mbrtowc() again for any of the incomplete characters that remain in the string. - Use "mbs" for the multi-byte state variable name (for consistency). - Use the new MB_INVALID and MB_INCOMPLETE defines for the size_t -1 and -2 values (respectively).
Diffstat (limited to 'Src/Zle/compmatch.c')
-rw-r--r--Src/Zle/compmatch.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index ec856041f..26b76ec84 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -1587,7 +1587,7 @@ sub_match(Cmdata md, char *str, int len, int sfx)
#ifdef MULTIBYTE_SUPPORT
int fulllen = len;
char *fullstr = str;
- mbstate_t ps;
+ mbstate_t mbs;
#endif
if (sfx) {
@@ -1629,7 +1629,7 @@ sub_match(Cmdata md, char *str, int len, int sfx)
*/
q = sfx ? str - l : str + l;
if (q != fullstr) {
- memset(&ps, 0, sizeof(ps));
+ memset(&mbs, 0, sizeof mbs);
/*
* Otherwise read characters from the start of the original
* string until we reach or pass the match point. This
@@ -1645,7 +1645,7 @@ sub_match(Cmdata md, char *str, int len, int sfx)
* ret must, in fact, be set by the current logic,
* but gcc doesn't realise (at least some versions don't).
*/
- size_t cnt = (size_t)-1;
+ size_t cnt = MB_INVALID;
int diff;
char *p2;
@@ -1655,12 +1655,12 @@ sub_match(Cmdata md, char *str, int len, int sfx)
*/
for (p2 = p; p2 < fullstr + fulllen; p2++) {
char curchar = (*p2 == Meta) ? (*++p2 ^ 32) : *p2;
- cnt = mbrtowc(&wc, &curchar, 1, &ps);
+ cnt = mbrtowc(&wc, &curchar, 1, &mbs);
/* Continue while character is incomplete. */
- if (cnt != (size_t)-2)
+ if (cnt != MB_INCOMPLETE)
break;
}
- if (cnt == (size_t)-1 || cnt == (size_t)-2) {
+ if (cnt == MB_INVALID || cnt == MB_INCOMPLETE) {
/* not a valid character, give up test */
break;
}