Browse Source

gettok_node(), use copy_substring()

pre-master-46
rlar 13 years ago
parent
commit
a94170d2ab
  1. 9
      src/misc/string.c

9
src/misc/string.c

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

Loading…
Cancel
Save