summaryrefslogtreecommitdiffstats
path: root/usr.bin/find/misc.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2005-04-02 07:44:12 +0000
committertjr <tjr@FreeBSD.org>2005-04-02 07:44:12 +0000
commit3a8b8f05cd5c0b2d6f806378d6b9702de46bb60b (patch)
tree778202800cf904dfbf2b6df563af45cdbf16d390 /usr.bin/find/misc.c
parent668712e3ddc095a7a77f3595447821ec23070d22 (diff)
downloadFreeBSD-src-3a8b8f05cd5c0b2d6f806378d6b9702de46bb60b.zip
FreeBSD-src-3a8b8f05cd5c0b2d6f806378d6b9702de46bb60b.tar.gz
Use rpmatch() instead of checking for responses that begin with 'y'
in queryuser(). This allows users to respond to -ok and -okdir prompts with any affirmative reply defined by their current locale.
Diffstat (limited to 'usr.bin/find/misc.c')
-rw-r--r--usr.bin/find/misc.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c
index fe11e04df..1532906 100644
--- a/usr.bin/find/misc.c
+++ b/usr.bin/find/misc.c
@@ -83,12 +83,13 @@ brace_subst(char *orig, char **store, char *path, int len)
/*
* queryuser --
* print a message to standard error and then read input from standard
- * input. If the input is 'y' then 1 is returned.
+ * input. If the input is an affirmative response (according to the
+ * current locale) then 1 is returned.
*/
int
queryuser(char *argv[])
{
- int ch, first, nl;
+ char *p, resp[256];
(void)fprintf(stderr, "\"%s", *argv);
while (*++argv)
@@ -96,20 +97,13 @@ queryuser(char *argv[])
(void)fprintf(stderr, "\"? ");
(void)fflush(stderr);
- first = ch = getchar();
- for (nl = 0;;) {
- if (ch == '\n') {
- nl = 1;
- break;
- }
- if (ch == EOF)
- break;
- ch = getchar();
- }
-
- if (!nl) {
+ if (fgets(resp, sizeof(resp), stdin) == NULL)
+ *resp = '\0';
+ if ((p = strchr(resp, '\n')) != NULL)
+ *p = '\0';
+ else {
(void)fprintf(stderr, "\n");
(void)fflush(stderr);
}
- return (first == 'y');
+ return (rpmatch(resp) == 1);
}
OpenPOWER on IntegriCloud