summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-10-02 01:16:03 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-10-02 01:16:03 +0000
commiteb8314a3055a8defbec460dee9e94064b0a9e756 (patch)
treef7efe1d6c472deffc6e6fbf77f280b35d7967dc4 /sbin
parentc94a9b958e52c06995a9e9f4ae375d1ca2d85211 (diff)
Deal with ^D sanely and kill unused get_yn().
Diffstat (limited to 'sbin')
-rw-r--r--sbin/disklabel/disklabel.c5
-rw-r--r--sbin/disklabel/editor.c35
2 files changed, 17 insertions, 23 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 07fcbeeb3e1..6654e969ced 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.40 1997/10/02 00:49:11 millert Exp $ */
+/* $OpenBSD: disklabel.c,v 1.41 1997/10/02 01:16:02 millert Exp $ */
/* $NetBSD: disklabel.c,v 1.30 1996/03/14 19:49:24 ghudson Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char rcsid[] = "$OpenBSD: disklabel.c,v 1.40 1997/10/02 00:49:11 millert Exp $";
+static char rcsid[] = "$OpenBSD: disklabel.c,v 1.41 1997/10/02 01:16:02 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -134,7 +134,6 @@ int checklabel __P((struct disklabel *));
void setbootflag __P((struct disklabel *));
void usage __P((void));
u_short dkcksum __P((struct disklabel *));
-char get_yn __P((char *));
int
main(argc, argv)
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index ff8c2dbd8c9..e95e3c81e07 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.3 1997/10/02 00:51:58 millert Exp $ */
+/* $OpenBSD: editor.c,v 1.4 1997/10/02 01:16:01 millert Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -31,7 +31,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: editor.c,v 1.3 1997/10/02 00:51:58 millert Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.4 1997/10/02 01:16:01 millert Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -62,7 +62,6 @@ void editor_display __P((struct disklabel *, u_int32_t *, char));
void editor_change __P((struct disklabel *, u_int32_t *, char *));
char *getstring __P((struct disklabel *, char *, char *, char *));
u_int32_t getuint __P((struct disklabel *, int, char *, char *, u_int32_t, u_int32_t, int));
-char get_yn __P((char *));
int has_overlap __P((struct disklabel *, u_int32_t *, int));
void make_contiguous __P((struct disklabel *));
u_int32_t next_offset __P((struct disklabel *));
@@ -112,7 +111,11 @@ editor(lp, f)
fputs("> ", stdout);
fflush(stdout);
rewind(stdin);
- fgets(buf, sizeof(buf), stdin);
+ if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ putchar('\n');
+ buf[0] = 'q';
+ buf[1] = '\0';
+ }
cmd = strtok(buf, " \t");
arg = strtok(NULL, " \t");
@@ -874,7 +877,10 @@ getstring(lp, prompt, helpstring, oval)
printf("%s: [%s] ", prompt, oval ? oval : "");
fflush(stdout);
rewind(stdin);
- fgets(buf, sizeof(buf), stdin);
+ if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ putchar('\n');
+ buf[0] == '\0';
+ }
n = strlen(buf);
if (n > 0 && buf[n-1] == '\n')
buf[--n] = '\0';
@@ -914,7 +920,10 @@ getuint(lp, partno, prompt, helpstring, oval, maxval, flags)
printf("%s: [%u] ", prompt, oval);
fflush(stdout);
rewind(stdin);
- fgets(buf, sizeof(buf), stdin);
+ if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ putchar('\n');
+ buf[0] = '\0';
+ }
n = strlen(buf);
if (n > 0 && buf[n-1] == '\n')
buf[--n] = '\0';
@@ -1187,17 +1196,3 @@ edit_parms(lp, freep)
}
lp->d_rpm = ui;
}
-
-char
-get_yn(prompt)
- char *prompt;
-{
- int c;
-
- do {
- printf("%s [y/n] ", prompt);
- c = tolower(getchar());
- } while (c != EOF && c != 'y' && c != 'n');
-
- return((char)c);
-}