diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2006-01-12 00:51:50 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2006-01-12 00:51:50 +0000 |
commit | 542797377aabd9af067909fd14af08b1081b250c (patch) | |
tree | 653d363b018b51c0fdf62723f33a370d53b929f3 /Src/Zle/zle_main.c | |
parent | e46d08523fd44432448c9c15bcec5977fd817e7d (diff) | |
download | zsh-542797377aabd9af067909fd14af08b1081b250c.tar.gz zsh-542797377aabd9af067909fd14af08b1081b250c.tar.xz 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/zle_main.c')
-rw-r--r-- | Src/Zle/zle_main.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 840abe4b7..a4ea10339 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -761,7 +761,7 @@ getrestchar(int inchar) char c = inchar; wchar_t outchar; int timeout; - static mbstate_t ps; + static mbstate_t mbs; /* * We are guaranteed to set a valid wide last character, @@ -772,7 +772,7 @@ getrestchar(int inchar) if (inchar == EOF) { /* End of input, so reset the shift state. */ - memset(&ps, 0, sizeof(ps)); + memset(&mbs, 0, sizeof mbs); return lastchar_wide = WEOF; } @@ -781,15 +781,15 @@ getrestchar(int inchar) * any other character. */ while (1) { - size_t cnt = mbrtowc(&outchar, &c, 1, &ps); - if (cnt == (size_t)-1) { + size_t cnt = mbrtowc(&outchar, &c, 1, &mbs); + if (cnt == MB_INVALID) { /* * Invalid input. Hmm, what's the right thing to do here? */ - memset(&ps, 0, sizeof(ps)); + memset(&mbs, 0, sizeof mbs); return lastchar_wide = WEOF; } - if (cnt != (size_t)-2) + if (cnt != MB_INCOMPLETE) break; /* @@ -802,7 +802,7 @@ getrestchar(int inchar) /* getbyte deliberately resets lastchar_wide_valid */ lastchar_wide_valid = 1; if (inchar == EOF) { - memset(&ps, 0, sizeof(ps)); + memset(&mbs, 0, sizeof mbs); if (timeout) { /* |