mirror of
https://git.code.sf.net/p/ngspice/ngspice
synced 2026-09-06 03:51:27 +02:00
moving some string functions from inpcom.c
This commit is contained in:
@@ -439,3 +439,49 @@ bzero(void *vptr, size_t num)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
bool
|
||||
isquote( char ch )
|
||||
{
|
||||
return ( ch == '\'' || ch == '"' );
|
||||
}
|
||||
|
||||
bool
|
||||
is_arith_char( char c )
|
||||
{
|
||||
if ( c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')' || c == '<' ||
|
||||
c == '>' || c == '?' || c == '|' || c == '&' )
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool
|
||||
str_has_arith_char( char *s )
|
||||
{
|
||||
while ( *s && *s != '\0' ) {
|
||||
if ( is_arith_char(*s) ) return TRUE;
|
||||
s++;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
get_comma_separated_values( char *values[], char *str ) {
|
||||
int count = 0;
|
||||
char *ptr, *comma_ptr, keep;
|
||||
|
||||
while ( ( comma_ptr = strstr( str, "," ) ) ) {
|
||||
ptr = comma_ptr - 1;
|
||||
while ( isspace(*ptr) ) ptr--;
|
||||
ptr++; keep = *ptr; *ptr = '\0';
|
||||
values[count++] = strdup(str);
|
||||
*ptr = keep;
|
||||
str = comma_ptr + 1;
|
||||
while ( isspace(*str) ) str++;
|
||||
}
|
||||
values[count++] = strdup(str);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user