aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/grep.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-02-10 21:05:22 -0600
committerRob Landley <rob@landley.net>2016-02-10 21:05:22 -0600
commitf435f0412aa4ca631aa178d10ed33008e34f37cb (patch)
tree6174226167b101bda2ad4557b6e5b42987e64ad2 /toys/posix/grep.c
parent3684510034450f5f50d1ad9b5acca327a5c484dd (diff)
downloadtoybox-f435f0412aa4ca631aa178d10ed33008e34f37cb.tar.gz
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.
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;
}