aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix/grep.c')
-rw-r--r--toys/posix/grep.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/toys/posix/grep.c b/toys/posix/grep.c
index c5d626aa..2ca02d2c 100644
--- a/toys/posix/grep.c
+++ b/toys/posix/grep.c
@@ -125,13 +125,8 @@ static void do_grep(int fd, char *name)
fseek.arg = s = line;
break;
}
- if (toys.optflags & FLAG_i) {
- long ll = strlen(seek->arg);;
-
- // Alas, posix hasn't got strcasestr()
- for (s = line; *s; s++) if (!strncasecmp(s, seek->arg, ll)) break;
- if (!*s) s = 0;
- } else s = strstr(line, seek->arg);
+ if (toys.optflags & FLAG_i) s = strnstr(line, seek->arg);
+ else s = strstr(line, seek->arg);
if (s) break;
}