diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-06-15 03:09:14 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-06-15 03:09:14 +0000 |
commit | 85b1229b4e9e3cfb5919739bd15708b683ed144d (patch) | |
tree | bdc2c04c06dc0c3eb400e0d078593905bf3d0cf0 /usr.bin | |
parent | c594e2f38499bc46716cad5ce0ff48ddc0e258b2 (diff) |
make further prompts work after eof, don't spam with prompts in
m*() cases; ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ftp/cmds.c | 8 | ||||
-rw-r--r-- | usr.bin/ftp/util.c | 18 |
2 files changed, 19 insertions, 7 deletions
diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c index 8f5c8808c8f..2867cce07cd 100644 --- a/usr.bin/ftp/cmds.c +++ b/usr.bin/ftp/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.58 2008/05/13 02:09:38 ray Exp $ */ +/* $OpenBSD: cmds.c,v 1.59 2008/06/15 03:09:13 martynas Exp $ */ /* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */ /* @@ -60,7 +60,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: cmds.c,v 1.58 2008/05/13 02:09:38 ray Exp $"; +static const char rcsid[] = "$OpenBSD: cmds.c,v 1.59 2008/06/15 03:09:13 martynas Exp $"; #endif /* not lint and not SMALL */ /* @@ -1259,8 +1259,10 @@ user(int argc, char *argv[]) if (argc < 4) { (void)fputs("Account: ", ttyout); (void)fflush(ttyout); - if (fgets(acctname, sizeof(acctname), stdin) == NULL) + if (fgets(acctname, sizeof(acctname), stdin) == NULL) { + clearerr(stdin); goto fail; + } acctname[strcspn(acctname, "\n")] = '\0'; diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index eb8452c4d43..99776bd2b02 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.48 2008/05/13 02:09:38 ray Exp $ */ +/* $OpenBSD: util.c,v 1.49 2008/06/15 03:09:13 martynas Exp $ */ /* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */ /*- @@ -71,7 +71,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: util.c,v 1.48 2008/05/13 02:09:38 ray Exp $"; +static const char rcsid[] = "$OpenBSD: util.c,v 1.49 2008/06/15 03:09:13 martynas Exp $"; #endif /* not lint and not SMALL */ /* @@ -298,6 +298,8 @@ tryagain: if (tmp[0] != '\0') user = tmp; } + else + exit(0); } n = command("USER %s", user); if (n == CONTINUE) { @@ -351,8 +353,10 @@ another(int *pargc, char ***pargv, const char *prompt) } fprintf(ttyout, "(%s) ", prompt); line[len++] = ' '; - if (fgets(&line[len], (int)(sizeof(line) - len), stdin) == NULL) + if (fgets(&line[len], (int)(sizeof(line) - len), stdin) == NULL) { + clearerr(stdin); intr(); + } len += strlen(&line[len]); if (len > 0 && line[len - 1] == '\n') line[len - 1] = '\0'; @@ -459,13 +463,19 @@ confirm(const char *cmd, const char *file) { char str[BUFSIZ]; + if (confirmrest == 2) + return (0); + if (!interactive || confirmrest) return (1); top: fprintf(ttyout, "%s %s? ", cmd, file); (void)fflush(ttyout); - if (fgets(str, sizeof(str), stdin) == NULL) + if (fgets(str, sizeof(str), stdin) == NULL) { + confirmrest = 2; + clearerr(stdin); return (0); + } switch (tolower(*str)) { case 'n': return (0); |