grep: read -f file with strbuf_getline()
List of patterns file could come from a DOS editor. This is iffy; you may actually be trying to find a line with ^M in it on a system whose line ending is LF. You can of course work it around by having a line that has "^M^M^J", let the strbuf_getline() eat the last "^M^J", leaving just the single "^M" as the pattern. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Oct 28, 2015 at 13:53 UTC
a551843129dc4d329d4f7915a9c10120963acd7d
1 file changed
+1
-1
builtin/grep.c
+1
-1
@@ -562,7 +562,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
562
patterns = from_stdin ? stdin : fopen(arg, "r");
563
if (!patterns)
564
die_errno(_("cannot open '%s'"), arg);
565
- while (strbuf_getline_lf(&sb, patterns) == 0) {
565
+ while (strbuf_getline(&sb, patterns) == 0) {
566
/* ignore empty line like grep does */
567
if (sb.len == 0)
568
continue;