From f435f0412aa4ca631aa178d10ed33008e34f37cb Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 10 Feb 2016 21:05:22 -0600 Subject: Factor out strnstr() since posix hasn't got it, and add a config option for the deeply sad passwd heuristics that don't even check numbers and punctuation. --- toys/posix/grep.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'toys/posix/grep.c') 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; } -- cgit v1.2.3