22 #include <sys/types.h> 29 static void *G__memccpy(
void *,
const void *,
int,
size_t);
30 static int _strncasecmp(
const char *,
const char *,
int);
49 return _strncasecmp(x, y, -1);
71 return _strncasecmp(x, y, n);
160 char *
G_strchg(
char *bug,
char character,
char new)
165 if (*help == character)
189 char *
G_str_replace(
const char *buffer,
const char *old_str,
const char *new_str)
197 if (old_str ==
NULL || new_str ==
NULL)
204 B = strstr(buffer, old_str);
209 if (strlen(new_str) > strlen(old_str)) {
212 len = strlen(old_str);
214 while (B !=
NULL && *B !=
'\0') {
215 B = strstr(B, old_str);
222 len = count * (strlen(new_str) - strlen(old_str))
227 len = strlen(buffer);
237 len = strlen(old_str);
239 if (*B == old_str[0] && strncmp(B, old_str, len) == 0) {
269 const char *sep,
int maxsize)
271 char buffer[maxsize];
273 char *end = buffer + maxsize;
276 if (maxsize < 1 || num_strings < 1)
279 memset(buffer, 0,
sizeof(buffer));
281 for (i = 0; i < num_strings; i++) {
283 p = (
char *)G__memccpy(buffer, src_strings[i],
'\0', maxsize);
286 p = (
char *)G__memccpy(p - 1, sep,
'\0', end - p);
288 p = (
char *)G__memccpy(p - 1, src_strings[i],
'\0', end - p);
305 for (a = b = buf; *a ==
' ' || *a ==
'\t'; a++) ;
307 while ((*b++ = *a++)) ;
309 for (a = buf; *a; a++) ;
311 for (a--; *a ==
' ' || *a ==
'\t'; a--) ;
330 char *f = line, *
t = line;
342 while (isspace(*--t)) ;
368 str[i] = toupper(str[i]);
386 str[i] = tolower(str[i]);
412 if (!(*c >=
'A' && *c <=
'Z') && !(*c >=
'a' && *c <=
'z') &&
413 !(*c >=
'0' && *c <=
'9')) {
421 if (!(*c >=
'A' && *c <=
'Z') && !(*c >=
'a' && *c <=
'z')) {
443 char *f = line, *
t = line;
457 l = strlen(line) - 1;
458 if (*(line + l) ==
'\n')
480 length = strlen(substr);
484 while (*q !=
'\0' && toupper(*q) != toupper(*p)) {
487 }
while (*q !=
'\0' &&
G_strncasecmp(p, q, length) != 0 && q++);
516 static void *G__memccpy(
void *
dst,
const void *src,
int c,
size_t n)
521 for (ret =
dst; n; ++ret, ++s, --n) {
523 if ((
unsigned char)*ret == (
unsigned char)c)
530 static int _strncasecmp(
const char *
x,
const char *y,
int n)
543 if (xx >=
'A' && xx <=
'Z')
545 if (yy >=
'A' && yy <=
'Z')
552 if (n > -1 && i >= n)
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
char * G_strcasestr(const char *str, const char *substr)
Finds the first occurrence of the sub-string in the null-terminated string ignoring case (upper or lo...
void G_strip(char *buf)
Removes all leading and trailing white space from string.
int G_strncasecmp(const char *x, const char *y, int n)
String compare ignoring case (upper or lower) - limited number of characters.
char * G_strchg(char *bug, char character, char new)
Replace all occurrences of character in string bug with new.
char * G_store(const char *s)
Copy string to allocated memory.
char * G_store_lower(const char *s)
Copy string to allocated memory and convert copied string to lower case.
char * G_chop(char *line)
Chop leading and trailing white spaces.
void G_str_to_lower(char *str)
Convert string to lower case.
void G_squeeze(char *line)
Remove superfluous white space.
char * G_store_upper(const char *s)
Copy string to allocated memory and convert copied string to upper case.
char * G_str_replace(const char *buffer, const char *old_str, const char *new_str)
Replace all occurrences of old_str in buffer with new_str.
void G_str_to_upper(char *str)
Convert string to upper case.
char * G_str_concat(const char **src_strings, int num_strings, const char *sep, int maxsize)
String concatenation.
int G_str_to_sql(char *str)
Make string SQL compliant.