From 542797377aabd9af067909fd14af08b1081b250c Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Thu, 12 Jan 2006 00:51:50 +0000 Subject: - 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). --- Src/Zle/zle_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Src/Zle/zle_main.c') 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) { /* -- cgit 1.4.1