Trims extra spaces in the configuration file.

This commit is contained in:
Andrea Mazzoleni 2011-06-21 21:18:06 +02:00
parent 2aa36a5df5
commit 09b8a3cd7c
4 changed files with 36 additions and 10 deletions

21
util.h
View file

@ -35,9 +35,28 @@ static inline char* strtoken(char* s)
return s;
}
/**
* Like strtoken() but trim spaces.
*/
static inline char* strtoken_trim(char* s)
{
while (*s && !isspace(*s))
++s;
if (*s) {
*s = 0;
++s;
}
/* skip ending spaces */
while (*s && isspace(*s))
++s;
return s;
}
/**
* Gets a text line from a file.
* Returns -1 on error, 0 on oef, and 1 if more data is available.
* Returns -1 on error, 0 on oef, or the number of chars read.
*/
int strgets(char* s, unsigned size, FILE* f);