about summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c48
1 files changed, 30 insertions, 18 deletions
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 == ' ') {