#61 Replace egrep with perl compatible regex (libpcre)


Replace the egrep findregex() function in find.c to make use of libpcre. Also use libpcreposix, to make all regex.h function calls use the PCRE regex engine. Change all references in display.c from "Egrep" to "PCRE".

The motivation behind this is to give cscope regexes the power of perl's regex language. In particular, non-greedy matches, and character classes such as \d, \w, \s, etc... None of which are supported by egrep. There are many more advantages to using libpcre, over egrep.


  • Michael Brailsford

    replace egrep regex with libpcre

  • Michael Brailsford

    Logged In: YES
    Originator: YES

    Here is an improved version of the patch. The configure script will now fallback to the original regex.h code if pcre.h and/or pcreposix.h is not found. This makes the patch much more passive than the first version, and allows cscope to continue to work exactly as before on systems without libpcre.

    Again, this is a patch from the cscope 15.6 tarball.
    File Added: egrep2pcre_v2.diff

  • Willi Mann

    Willi Mann - 2008-12-10

    This patch is buggy: src/find.c 547: The prev_offset might not 0 in subsequent iterations of the loop, but fread always reads 4 times BUFSIZ instead of "4 * BUFSIZ - prev_offset" - buffer overflow.


Log in to post a comment.