summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/grijp.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/grijp.c b/src/grijp.c
index add2806..a616959 100644
--- a/src/grijp.c
+++ b/src/grijp.c
@@ -96,16 +96,22 @@ static void parse_patterns() {
patterns = calloc(cappat, sizeof(char*));
char *s = gpats;
- char *pat = NULL;
- while ((pat = strtok(s, "\n")) != NULL) {
- s = NULL;
+ size_t cursor = 0;
+ while (true) {
+ const size_t lfidx = strchrnul(s + cursor, '\n') - s;
+ const bool last = s[lfidx] == '\0';
+ s[lfidx] = '\0';
if (npat == cappat) {
cappat *= 2;
patterns = realloc(patterns, sizeof(char*)*cappat);
}
- patterns[npat] = strdup(pat);
+ patterns[npat] = strdup(s + cursor);
npat++;
+
+ cursor = lfidx + 1;
+
+ if (last) break;
}
}