mirror of
https://git.code.sf.net/p/ngspice/ngspice
synced 2026-09-03 02:53:04 +02:00
gettok_node(), use copy_substring()
This commit is contained in:
+4
-5
@@ -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 ) ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user