diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/os_calls.c | 21 | ||||
-rw-r--r-- | common/os_calls.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 16b89201..1d3a71b1 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -2266,6 +2266,27 @@ g_strncmp(const char *c1, const char *c2, int len) } /*****************************************************************************/ +/* compare up to delim */ +int APP_CC +g_strncmp_d(const char *s1, const char *s2, const char delim, int n) +{ + char c1; + char c2; + + while (n > 0) + { + c1 = *s1++; + c2 = *s2++; + if ((c1 == 0) || (c1 != c2) || (c1 == delim) || (c2 == delim)) + { + return c1 - c2; + } + n--; + } + return c1 - c2; +} + +/*****************************************************************************/ int APP_CC g_strcasecmp(const char *c1, const char *c2) { diff --git a/common/os_calls.h b/common/os_calls.h index 3afde05c..1805a6a1 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -115,6 +115,7 @@ char* APP_CC g_strdup(const char* in); char* APP_CC g_strndup(const char* in, const unsigned int maxlen); int APP_CC g_strcmp(const char* c1, const char* c2); int APP_CC g_strncmp(const char* c1, const char* c2, int len); +int APP_CC g_strncmp_d(const char* c1, const char* c2, const char delim, int len); int APP_CC g_strcasecmp(const char* c1, const char* c2); int APP_CC g_strncasecmp(const char* c1, const char* c2, int len); int APP_CC g_atoi(const char* str); |