|
68 | 68 | ;;; Common Lisp Y-OR-N-P function
|
69 | 69 | ;;;
|
70 | 70 | (defun y-or-n-p (&optional format-string &rest arguments)
|
71 |
| - (let ((stream *query-io*)) |
72 |
| - (if format-string |
73 |
| - (progn |
74 |
| - (fresh-line stream) |
75 |
| - (apply #'format stream format-string arguments))) |
76 |
| - (format stream "(Y/N)~%") |
77 |
| - (do ((response-char)) |
78 |
| - (nil nil) |
79 |
| - (setq response-char (char-upcase (read-char stream))) |
80 |
| - (cond |
81 |
| - ((not (graphic-char-p response-char))) |
82 |
| - ((eq response-char #\Y) (return-from y-or-n-p t)) |
83 |
| - ((eq response-char #\N) (return-from y-or-n-p nil)) |
84 |
| - (t (format stream "(Y/N)~%")))))) |
| 71 | + (let ((stream *query-io*)) |
| 72 | + (if format-string |
| 73 | + (progn |
| 74 | + (fresh-line stream) |
| 75 | + (apply #'format stream format-string arguments))) |
| 76 | + (format stream "(Y/N)~%") |
| 77 | + (do ((response-char)) |
| 78 | + (nil nil) |
| 79 | + (setq response-char (char-upcase (read-char stream))) |
| 80 | + ;; remove newline character when reading from console input |
| 81 | + (let ((ch (peek-char nil stream nil 'Eof nil))) |
| 82 | + (when (char= ch #\Newline) |
| 83 | + (read-char stream nil nil nil))) |
| 84 | + (cond |
| 85 | + ((not (graphic-char-p response-char))) |
| 86 | + ((eq response-char #\Y) (return-from y-or-n-p t)) |
| 87 | + ((eq response-char #\N) (return-from y-or-n-p nil)) |
| 88 | + (t (format stream "(Y/N)~%")))))) |
85 | 89 |
|
86 | 90 | (defun yes-or-no-p (&optional format-string &rest arguments)
|
87 |
| - (let ((stream *query-io*)) |
88 |
| - (if format-string |
89 |
| - (progn |
90 |
| - (fresh-line stream) |
91 |
| - (apply #'format stream format-string arguments))) |
92 |
| - (format stream "(Yes/No)~%") |
93 |
| - (do ((response)) |
94 |
| - (nil nil) |
95 |
| - (setq response (read stream)) |
96 |
| - (cond |
97 |
| - ((string-equal response "YES")(return-from yes-or-no-p t)) |
98 |
| - ((string-equal response "NO") (return-from yes-or-no-p nil)) |
99 |
| - (t (format stream "(Yes/No)~%")))))) |
| 91 | + (let ((stream *query-io*)) |
| 92 | + (if format-string |
| 93 | + (progn |
| 94 | + (fresh-line stream) |
| 95 | + (apply #'format stream format-string arguments))) |
| 96 | + (format stream "(Yes/No)~%") |
| 97 | + (do ((response)) |
| 98 | + (nil nil) |
| 99 | + ;; remove newline character when reading from console input |
| 100 | + (setq response (read stream)) |
| 101 | + (let ((ch (peek-char nil stream nil 'Eof nil))) |
| 102 | + (when (char= ch #\Newline) |
| 103 | + (read-char stream nil nil nil))) |
| 104 | + (cond |
| 105 | + ((string-equal response "YES")(return-from yes-or-no-p t)) |
| 106 | + ((string-equal response "NO") (return-from yes-or-no-p nil)) |
| 107 | + (t (format stream "(Yes/No)~%")))))) |
100 | 108 |
|
101 | 109 | ;;;
|
102 | 110 | ;;; Corman Lisp WEAK-POINTER-OBJ function.
|
|
0 commit comments