aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-09-07 17:12:57 -0500
committerRob Landley <rob@landley.net>2015-09-07 17:12:57 -0500
commitb1353fb9185928249f273340c601244291e269fe (patch)
treee75f4ee65b3f88a1fd436b9605826c1df160f514
parent960100aa9cb588a73125d43ec0b0a7152a95b43f (diff)
downloadtoybox-b1353fb9185928249f273340c601244291e269fe.tar.gz
Remove prompt argument from yesno(), caller can fprintf(stderr, "blah") itself.
This fixes the build break, the change to yesno() prototype accidentally got checked in last commit. (Oops, sorry.)
-rw-r--r--lib/lib.c4
-rw-r--r--toys/lsb/killall.c4
-rw-r--r--toys/pending/crontab.c4
-rw-r--r--toys/posix/cp.c8
-rw-r--r--toys/posix/find.c6
-rw-r--r--toys/posix/rm.c10
6 files changed, 18 insertions, 18 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 058c6386..c5fca3f7 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -630,11 +630,11 @@ void base64_init(char *p)
*(p++) = '/';
}
-int yesno(char *prompt, int def)
+int yesno(int def)
{
char buf;
- fprintf(stderr, "%s (%c/%c):", prompt, def ? 'Y' : 'y', def ? 'n' : 'N');
+ fprintf(stderr, " (%c/%c):", def ? 'Y' : 'y', def ? 'n' : 'N');
fflush(stderr);
while (fread(&buf, 1, 1, stdin)) {
int new;
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c
index 478f7617..e8927559 100644
--- a/toys/lsb/killall.c
+++ b/toys/lsb/killall.c
@@ -40,8 +40,8 @@ static int kill_process(pid_t pid, char *name)
if (pid == TT.cur_pid) return 0;
if (toys.optflags & FLAG_i) {
- snprintf(toybuf, sizeof(toybuf), "Signal %s(%d) ?", name, (int)pid);
- if (!yesno(toybuf, 0)) return 0;
+ fprintf(stderr, "Signal %s(%d)", name, (int)pid);
+ if (!yesno(0)) return 0;
}
errno = 0;
diff --git a/toys/pending/crontab.c b/toys/pending/crontab.c
index 35f6d659..05c98f2b 100644
--- a/toys/pending/crontab.c
+++ b/toys/pending/crontab.c
@@ -317,9 +317,9 @@ RETRY:
}
printf("%s: installing new crontab\n", toys.which->name);
if (parse_crontab(tname)) {
- snprintf(toybuf, sizeof(toybuf), "errors in crontab file, can't install.\n"
+ fprintf(stderr, "errors in crontab file, can't install.\n"
"Do you want to retry the same edit? ");
- if (!yesno(toybuf, 0)) {
+ if (!yesno(0)) {
error_msg("edits left in '%s'", tname);
return;
}
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index 5a55f40b..2b032fe6 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -173,7 +173,7 @@ int cp_node(struct dirtree *try)
fprintf(stderr, "%s: overwrite '%s'", toys.which->name,
s = dirtree_path(try, 0));
free(s);
- if (!yesno("", 1)) return 0;
+ if (!yesno(1)) return 0;
}
}
@@ -348,11 +348,11 @@ void cp_main(void)
// Try to interpret as letters, commas won't set anything this doesn't.
for (s = TT.c.preserve; *s; s++) {
for (i=0; i<ARRAY_LEN(preserve); i++)
- if (*s == *preserve[i]) TT.pflags |= 1<<i;
+ if (*s == *preserve[i]) break;
if (i == ARRAY_LEN(preserve)) {
if (*s == 'a') TT.pflags = ~0;
else break;
- }
+ } else TT.pflags |= 1<<i;
}
if (*s) error_exit("bad --preserve=%s", pre);
@@ -381,7 +381,7 @@ void cp_main(void)
&& ((toys.optflags & FLAG_i) || !(st.st_mode & 0222)))
{
fprintf(stderr, "%s: overwrite '%s'", toys.which->name, TT.destname);
- if (!yesno("", 1)) rc = 0;
+ if (!yesno(1)) rc = 0;
else unlink(TT.destname);
}
}
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 99cf5e2f..10585294 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -421,10 +421,8 @@ static int do_find(struct dirtree *new)
if (aa->dir) aa->prev = (void *)1;
if (*s == 'o') {
- char *prompt = xmprintf("[%s] %s", ss1, name);
- test = yesno(prompt, 0);
- free(prompt);
- if (!test) {
+ fprintf(stderr, "[%s] %s", ss1, name);
+ if (!(test = yesno(0))) {
free(name);
goto cont;
}
diff --git a/toys/posix/rm.c b/toys/posix/rm.c
index 5523a98c..f591c64d 100644
--- a/toys/posix/rm.c
+++ b/toys/posix/rm.c
@@ -39,9 +39,10 @@ static int do_rm(struct dirtree *try)
&& (!S_ISLNK(try->st.st_mode) && faccessat(fd, try->name, W_OK, 0))) or++;
if (!(dir && try->again) && ((or && isatty(0)) || (flags & FLAG_i))) {
char *s = dirtree_path(try, 0);
- fprintf(stderr, "rm %s%s", or ? "ro " : "", dir ? "dir " : "");
- or = yesno(s, 0);
+
+ fprintf(stderr, "rm %s%s%s", or ? "ro " : "", dir ? "dir " : "", s);
free(s);
+ or = yesno(0);
if (!or) goto nodelete;
}
@@ -57,10 +58,11 @@ static int do_rm(struct dirtree *try)
if (try->symlink) goto skip;
if (flags & FLAG_i) {
char *s = dirtree_path(try, 0);
+
// This is the section 2(d) prompt. (Yes, posix says to prompt twice.)
- fprintf(stderr, "rmdir ");
- or = yesno(s, 0);
+ fprintf(stderr, "rmdir %s", s);
free(s);
+ or = yesno(0);
if (!or) goto nodelete;
}
}