summaryrefslogtreecommitdiffstats
path: root/usr.bin/rcs/rcsutil.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2006-11-09 21:47:52 +0000
committermillert <millert@openbsd.org>2006-11-09 21:47:52 +0000
commit9642f3ec121f9fdb34836013fd95aa500e1e8e5c (patch)
treede78d62cfb9da885a8e474e484dde40d50e15785 /usr.bin/rcs/rcsutil.c
parentsync (diff)
downloadwireguard-openbsd-9642f3ec121f9fdb34836013fd95aa500e1e8e5c.tar.xz
wireguard-openbsd-9642f3ec121f9fdb34836013fd95aa500e1e8e5c.zip
Simplify stripping of write bits from file mode.
Add support for reusing the checkin message for multiple files, ala GNU Fix the message when you abort a checkout and the file was not writable. OK joris@ niallo@
Diffstat (limited to 'usr.bin/rcs/rcsutil.c')
-rw-r--r--usr.bin/rcs/rcsutil.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c
index 403b5abad55..98b7c8741f2 100644
--- a/usr.bin/rcs/rcsutil.c
+++ b/usr.bin/rcs/rcsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.c,v 1.22 2006/10/12 17:20:12 niallo Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.23 2006/11/09 21:47:52 millert Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -562,24 +562,27 @@ rcs_patchfile(BUF *data, BUF *patch,
/*
* rcs_yesno()
*
- * Read from standart input for `y' or `Y' character.
- * Returns 0 on success, or -1 on failure.
+ * Read a char from standard input, returns defc if the
+ * user enters an equivalent to defc, else whatever char
+ * was entered. Converts input to lower case.
*/
int
-rcs_yesno(void)
+rcs_yesno(int defc)
{
int c, ret;
- ret = 0;
-
fflush(stderr);
fflush(stdout);
- if ((c = getchar()) != 'y' && c != 'Y')
- ret = -1;
+ if (isalpha(c = getchar()))
+ c = tolower(c);
+ if (c == defc || c == '\n' || (c == EOF && feof(stdin)))
+ ret = defc;
else
- while (c != EOF && c != '\n')
- c = getchar();
+ ret = c;
+
+ while (c != EOF && c != '\n')
+ c = getchar();
return (ret);
}