Browse Source

moving some string functions from inpcom.c

pre-master-46
dwarning 18 years ago
parent
commit
9cbf5a91ee
  1. 46
      src/misc/string.c
  2. 6
      src/misc/stringutil.h

46
src/misc/string.c

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

6
src/misc/stringutil.h

@ -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
Loading…
Cancel
Save