From 245847e9e4a772c1eca3ce695cdf841eab6e0c81 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 21 Feb 2000 03:09:26 +0000 Subject: zsh-workers/9799 --- Src/utils.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index 292bd9249..c6b9dface 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1313,31 +1313,39 @@ read1char(void) /**/ int -getquery(char *valid_chars, int purge) +noquery(int purge) { - int c, d; - int isem = !strcmp(term, "emacs"); + int c, val = 0; #ifdef FIONREAD - int val = 0; + ioctl(SHTTY, FIONREAD, (char *)&val); + if (purge) { + while(val--) + read(SHTTY, &c, 1); + } #endif + return val; +} + +/**/ +int +getquery(char *valid_chars, int purge) +{ + int c, d; + int isem = !strcmp(term, "emacs"); + attachtty(mypgrp); if (!isem) setcbreak(); -#ifdef FIONREAD - ioctl(SHTTY, FIONREAD, (char *)&val); - if(purge) { - while(val--) - read(SHTTY, &c, 1); - } else if (val) { + if (noquery(purge)) { if (!isem) settyinfo(&shttyinfo); write(SHTTY, "n\n", 2); return 'n'; } -#endif + while ((c = read1char()) >= 0) { if (c == 'Y' || c == '\t') c = 'y'; @@ -1494,13 +1502,17 @@ spckword(char **s, int hist, int cmd, int ask) *guess = *best = ztokens[ic - Pound]; } if (ask) { - char *pptbuf; - pptbuf = promptexpand(sprompt, 0, best, guess); - zputs(pptbuf, shout); - free(pptbuf); - fflush(shout); - zbeep(); - x = getquery("nyae ", 0); + if (noquery(0)) { + x = 'n'; + } else { + char *pptbuf; + pptbuf = promptexpand(sprompt, 0, best, guess); + zputs(pptbuf, shout); + free(pptbuf); + fflush(shout); + zbeep(); + x = getquery("nyae ", 0); + } } else x = 'y'; if (x == 'y' || x == ' ') { -- cgit 1.4.1