moving some string functions from inpcom.c

This commit is contained in:
dwarning 2008-04-06 19:36:06 +00:00
parent 94323196ff
commit 9cbf5a91ee
2 changed files with 52 additions and 0 deletions

View File

@ -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;
}

View File

@ -4,6 +4,7 @@
************/
#include "config.h"
#include "bool.h"
#ifndef STRING_H_INCLUDED
#define STRING_H_INCLUDED
@ -35,4 +36,9 @@ void bzero(void *ptr, size_t num);
#endif /* HAVE_BCOPY */
bool isquote(char ch);
bool is_arith_char(char c);
bool str_has_arith_char(char *s);
int get_comma_separated_values( char *values[], char *str );
#endif