diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2006-12-14 18:47:36 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2006-12-14 18:47:36 +0000 |
commit | 173f47e7cdd05ef594278e63c4b9c41fddd79db9 (patch) | |
tree | 809c1758658d0a60eb92b576934781a71ff85655 /lib/yesno.c | |
parent | 1604f4b50581c276dc7f97962432abeda4e52eb7 (diff) | |
download | gnulib-173f47e7cdd05ef594278e63c4b9c41fddd79db9.tar.gz |
* lib/yesno.c [!ENABLE_NLS]: Don't include getline.h.
(yesno) [!ENABLE_NLS]: Don't invoke getline or rpmatch.
This is for the benefit of gzip, which doesn't do i18n.
Diffstat (limited to 'lib/yesno.c')
-rw-r--r-- | lib/yesno.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/yesno.c b/lib/yesno.c index 930bfb0a71..24006281f0 100644 --- a/lib/yesno.c +++ b/lib/yesno.c @@ -24,7 +24,9 @@ #include <stdlib.h> #include <stdio.h> -#include "getline.h" +#if ENABLE_NLS +# include "getline.h" +#endif /* Return true if we read an affirmative line from standard input. */ @@ -33,10 +35,12 @@ extern int rpmatch (char const *response); bool yesno (void) { + bool yes; + +#if ENABLE_NLS char *response = NULL; size_t response_size = 0; ssize_t response_len = getline (&response, &response_size, stdin); - bool yes; if (response_len <= 0) yes = false; @@ -47,5 +51,14 @@ yesno (void) } free (response); +#else + /* Test against "^[yY]", hardcoded to avoid requiring getline, + regex, and rpmatch. */ + int c = getchar (); + yes = (c == 'y' || c == 'Y'); + while (c != '\n' && c != EOF) + c = getchar (); +#endif + return yes; } |