gettok_node(), use copy_substring()

This commit is contained in:
rlar 2013-10-18 21:29:38 +02:00
parent 493aaba468
commit a94170d2ab
1 changed files with 4 additions and 5 deletions

View File

@ -441,7 +441,6 @@ gettok_node(char **s)
{
char c;
char *token ; /* return token */
SPICE_DSTRING buf ; /* allow any length string */
if (*s == NULL)
return NULL;
@ -456,16 +455,18 @@ gettok_node(char **s)
if (!**s)
return (NULL); /* return NULL if we come to end of line */
spice_dstring_init(&buf) ;
token = *s;
while ((c = **s) != '\0' &&
!isspace(c) &&
( **s != '(' ) &&
( **s != ')' ) &&
( **s != ',')
) { /* collect chars until whitespace or ( , ) */
spice_dstring_append_char( &buf, *(*s)++ ) ;
(*s)++;
}
token = copy_substring(token, *s);
/* Now iterate up to next non-whitespace char */
while (isspace(**s) ||
( **s == '(' ) ||
@ -474,8 +475,6 @@ gettok_node(char **s)
)
(*s)++; /* iterate over whitespace and ( , ) */
token = copy( spice_dstring_value(&buf) ) ;
spice_dstring_free(&buf) ;
return ( token ) ;
}