[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
init patch
From: |
James A Morrison |
Subject: |
init patch |
Date: |
Mon, 20 Jan 2003 20:15:25 -0500 (EST) |
This patch allows the computer to reboot if the user does not enter
a value for the path to a server.
James A. Morrison
2003-01-20 James A. Morrison <ja2morri@uwaterloo.ca>
* init.c (getstring): Return 0 if the user only presses enter.
Index: init.c
===================================================================
RCS file: /cvsroot/hurd/hurd/init/init.c,v
retrieving revision 1.129
diff -u -r1.129 init.c
--- init.c 8 May 2002 09:20:38 -0000 1.129
+++ init.c 21 Jan 2003 01:05:24 -0000
@@ -145,14 +145,15 @@
static int
getstring (char *buf, size_t bufsize)
{
- if (fgets (buf, bufsize, stdin) != NULL && buf[0] != '\0')
- {
- size_t len = strlen (buf);
- if (buf[len - 1] == '\n' || buf[len - 1] == '\r')
- buf[len - 1] = '\0';
- return 1;
- }
- return 0;
+ /* fail if fgets fails or the uses simply presses enter */
+ if (fgets (buf, bufsize, stdin) == NULL || buf[0] == '\0'
+ || buf[0] == '\n' || buf[0] == '\r')
+ return 0;
+
+ size_t len = strlen (buf);
+ if (buf[len - 1] == '\n' || buf[len - 1] == '\r')
+ buf[len - 1] = '\0';
+ return 1;
}
- init patch,
James A Morrison <=
Re: init patch, James Morrison, 2003/01/21