But still buggy.. in fact there was two fatal bugs in my code.
The following has now been committed:
--- cache_cf.c 2001/01/28 00:45:45 1.372
+++ cache_cf.c 2001/01/30 09:43:37
@@ -1699,9 +1699,13 @@
void
parse_eol(char *volatile *var)
{
- char *token = strtok(NULL, null_string);
+ unsigned char *token = strtok(NULL, null_string);
safe_free(*var);
if (token == NULL)
self_destruct();
+ while(*token && isspace(*token))
+ token++;
+ if (!*token)
+ self_destruct();
*var = xstrdup(token);
}
/Henrik
Henrik Nordstrom wrote:
>
> parse_eol is buggy. It should skip leading whitespace but doesn't.
>
> Simple patch:
> while(isspace((unsigned char)*token))
> token++;
> before the assignment.
>
> Should probably check if there is anything left of the string..
>
> Something like this:
> void
> parse_eol(char *volatile *var)
> {
> | unsigned char *token = strtok(NULL, null_string);
> safe_free(*var);
> + while(isspace(*token))
> + token++;
> | if (token == NULL || strlen(token) == 0)
> self_destruct();
> *var = xstrdup(token);
> }
>
> Robert Collins wrote:
> >
> > Is there any expected problems trimming whitespace at the beginning of
> > the token in functions like parse_eol?
> >
> > I'm finding that if I have two spaces on a config line:
> > filter_config onunload search string
> > the parsed string is " string", rather thatn "string"
> >
> > Rob
Received on Tue Jan 30 2001 - 03:09:48 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:13:26 MST