[pcre-dev] [Bug 1848] pcregrep outputs duplicate matches

Góra strony
Delete this message
Autor: admin
Data:  
Dla: pcre-dev
Stare tematy: [pcre-dev] [Bug 1848] New: pcregrep outputs duplicate matches
Temat: [pcre-dev] [Bug 1848] pcregrep outputs duplicate matches
https://bugs.exim.org/show_bug.cgi?id=1848

--- Comment #5 from Eric Hoffman <ehoffman@???> ---
Indeed...

I think there's missing something though, is to update 'length' in the new
code. Otherwise 'length' is invalid when match_pattern() function get called
just after taking the goto ONLY_MATCHING_RESTART (since match_ptr is updated).

This create bad issue like infinite loop. For example, if you have a file with
an empty line as the last line, and you do:

$ echo "123" > file.txt # That is, "123\n"
$ ./pcregrep -Mo "(\n|.)*" file.txt # Print everything


So, from revision 1678, that give:

Index: pcregrep.c
===================================================================
--- pcregrep.c    (revision 1678)
+++ pcregrep.c    (working copy)
@@ -1826,6 +1826,7 @@
           startoffset -= (int)(linelength + endlinelength);
           t = end_of_line(ptr, endptr, &endlinelength);
           linelength = t - ptr - endlinelength;
+          length = endptr - ptr;
           }              


         goto ONLY_MATCHING_RESTART;


--
You are receiving this mail because:
You are on the CC list for the bug.