return true;
}
-static char *_strchr_with_nth(char *end_pointer, char *s, int c, int nth)
+static char *_strchr_with_nth(char *end_pointer, char *s, char *delimiters, int nth)
{
+ RETV_IF(NULL == delimiters, s);
+ RETV_IF('\0' == *delimiters, s);
+
+ int i;
char *cursor = s;
+ int len_delimiters = strlen(delimiters);
+
while (*cursor) {
if (end_pointer <= cursor) {
ERR("over end");
return end_pointer;
}
- if (*cursor == c)
- nth--;
-
+ for (i = 0; i < len_delimiters; i++) {
+ if (*cursor == delimiters[i]) {
+ nth--;
+ break;
+ }
+ }
if (nth < 0)
break;
return cursor;
}
-static char *_strrchr_with_nth(char *start_pointer, char *s, int c, int nth)
+static char *_strrchr_with_nth(char *start_pointer, char *s, char *delimiters, int nth)
{
+ RETV_IF(NULL == delimiters, s);
+ RETV_IF('\0' == *delimiters, s);
+
+ int i;
char *cursor = s;
+ int len_delimiters = strlen(delimiters);
+
while (*cursor) {
if (cursor <= start_pointer) {
/* LCOV_EXCL_START */
return start_pointer;
/* LCOV_EXCL_STOP */
}
- if (*cursor == c)
- nth--;
-
+ for (i = 0; i < len_delimiters; i++) {
+ if (*cursor == delimiters[i]) {
+ nth--;
+ break;
+ }
+ }
if (nth < 0)
break;
return mod_temp;
char *cursor = NULL;
- cursor = _strchr_with_nth(mod_temp + len_full, keyword_start, ' ', token_number);
+ cursor = _strchr_with_nth(mod_temp + len_full, keyword_start, " \n", token_number);
*cursor = '\0';
- cursor = _strrchr_with_nth(mod_temp, keyword_start, ' ', token_number);
+ cursor = _strrchr_with_nth(mod_temp, keyword_start, " \n", token_number);
memcpy(mod_temp, cursor, len_full);
return mod_temp;