From bb912594b2325334a603893e90e8d9aa7cc534ca Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 1 Aug 2006 21:28:04 +0000 Subject: 22575: multibyte fixes for bslashquote(), getzlequery() --- Src/Zle/zle_utils.c | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'Src/Zle/zle_utils.c') diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index 2c92c955e..cce162fa0 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -653,50 +653,42 @@ zlinefind(ZLE_STRING_T haystack, int haylen, int pos, } /* - * Query the user, and return a single character response. The question - * is assumed to have been printed already, and the cursor is left - * immediately after the response echoed. (Might cause a problem if - * this takes it onto the next line.) If yesno is non-zero: is - * interpreted as 'y'; any other control character is interpreted as - * 'n'. If there are any characters in the buffer, this is taken as a - * negative response, and no characters are read. Case is folded. - * - * TBD: this may need extending to return a wchar_t or possibly - * a wint_t. + * Query the user, and return 1 for yes, 0 for no. The question is assumed to + * have been printed already, and the cursor is left immediately after the + * response echoed. (Might cause a problem if this takes it onto the next + * line.) is interpreted as 'y'; any other control character is + * interpreted as 'n'. If there are any characters in the buffer, this is + * taken as a negative response, and no characters are read. Case is folded. */ /**/ mod_export int -getzlequery(int yesno) +getzlequery(void) { ZLE_INT_T c; #ifdef FIONREAD int val; - if (yesno) { - /* check for typeahead, which is treated as a negative response */ - ioctl(SHTTY, FIONREAD, (char *)&val); - if (val) { - putc('n', shout); - return 'n'; - } + /* check for typeahead, which is treated as a negative response */ + ioctl(SHTTY, FIONREAD, (char *)&val); + if (val) { + putc('n', shout); + return 0; } #endif /* get a character from the tty and interpret it */ c = getfullchar(0); - if (yesno) { - if (c == ZWC('\t')) - c = ZWC('y'); - else if (ZC_icntrl(c) || c == ZLEEOF) - c = ZWC('n'); - else - c = ZC_tolower(c); - } + if (c == ZWC('\t')) + c = ZWC('y'); + else if (ZC_icntrl(c) || c == ZLEEOF) + c = ZWC('n'); + else + c = ZC_tolower(c); /* echo response and return */ if (c != ZWC('\n')) zwcputc(c); - return c; + return c == ZWC('y'); } /* Format a string, keybinding style. */ -- cgit 1.4.1