From 7acaf53dc9f2d5453a8c00db0d0c642f18d37809 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 21 Jun 2011 21:34:58 +0200 Subject: [PATCH] Allow empty lines in the configuration file. --- state.c | 1 + util.c | 4 ++-- util.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/state.c b/state.c index 584910ea..57fee0ae 100644 --- a/state.c +++ b/state.c @@ -111,6 +111,7 @@ void state_config(struct snapraid_state* state, const char* path, int verbose, i /* here we use strtoken_trim() to eat extra spaces inserted by the user */ /* skip ending spaces */ + --ret; while (ret>0 && isspace(s[ret-1])) { --ret; s[ret] = 0; diff --git a/util.c b/util.c index 8b680ddb..9e481450 100644 --- a/util.c +++ b/util.c @@ -40,7 +40,7 @@ int strgets(char* s, unsigned size, FILE* f) *i++ = c; if (i == send) { - return -1; + return -1; /* return error if the buffer is full */ } } @@ -64,7 +64,7 @@ int strgets(char* s, unsigned size, FILE* f) *i = 0; - return i - s; + return i - s + 1; } int stru32(const char* s, uint32_t* value) diff --git a/util.h b/util.h index e7774913..a6bb4fd7 100644 --- a/util.h +++ b/util.h @@ -47,7 +47,7 @@ static inline char* strtoken_trim(char* s) ++s; } - /* skip ending spaces */ + /* skip spaces */ while (*s && isspace(*s)) ++s; @@ -56,7 +56,7 @@ static inline char* strtoken_trim(char* s) /** * Gets a text line from a file. - * Returns -1 on error, 0 on oef, or the number of chars read. + * Returns -1 on error, 0 on OEF, or the number of chars returned in the buffer, including the ending 0. */ int strgets(char* s, unsigned size, FILE* f);