summaryrefslogtreecommitdiff
path: root/sbin/raidctl
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-10-20 17:18:33 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-10-20 17:18:33 +0000
commit018b3e58a7c0962cea1605ef4b4114733465fc7a (patch)
tree6b393c2850405dde6958d529ae0dc5dd8e3d731b /sbin/raidctl
parentdb5ced60a56bb8d09d7b16c18b6d92f591d323c6 (diff)
Strip trailing whitespace on input lines. Should make config files more
resistant to careless fingers. A variant of what NetBSD did to achieve the same ends. Feedback, suggestions & "looks good" ray@
Diffstat (limited to 'sbin/raidctl')
-rw-r--r--sbin/raidctl/rf_configure.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sbin/raidctl/rf_configure.c b/sbin/raidctl/rf_configure.c
index c6e4f6b37f6..fdaa5b942a4 100644
--- a/sbin/raidctl/rf_configure.c
+++ b/sbin/raidctl/rf_configure.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rf_configure.c,v 1.18 2007/09/14 14:29:20 chl Exp $ */
+/* $OpenBSD: rf_configure.c,v 1.19 2007/10/20 17:18:32 krw Exp $ */
/* $NetBSD: rf_configure.c,v 1.14 2001/02/04 21:05:42 christos Exp $ */
/*
@@ -454,20 +454,24 @@ rf_search_file_for_start_of(const char *string, char *buf, int len, FILE *fp)
/* reads from file fp into buf until it finds an interesting line */
int
-rf_get_next_nonblank_line(char *buf, int len, FILE *fp,
- const char *errmsg)
+rf_get_next_nonblank_line(char *buf, int len, FILE *fp, const char *errmsg)
{
- char *p;
+ char *p;
+ int i;
- while (fgets(buf,len,fp) != NULL) {
- p = rf_find_non_white(buf);
+ while (fgets(buf,len,fp) != NULL) {
+ for(i = strlen(buf) - 1; i >= 0 && isspace(buf[i]); i--)
+ buf[i] = '\0';
+ p = rf_find_non_white(buf);
if (*p == '\n' || *p == '\0' || *p == '#')
continue;
- return(0);
- }
+ return(0);
+ }
+
if (errmsg)
RF_ERRORMSG1("%s", errmsg);
- return(1);
+
+ return(1);
}
/*