Daily Archives: June 2, 2007

Regexp library chaos

Apache makes some use of regular expressions, for which it uses the Perl-compatible regular expression (pcre) library. And it bundles the library rather than making it a prerequisite: a decision which causes a range of problems (for example here) and sort-of fixed in an uneasy compromise.

APR doesn’t use any regexp support. So when I found myself using regexps in developing a FreeTDS driver for apr_dbd, I faced the decision of whether to use pcre or POSIX regexps. Two ideas led me to pcre:

  • PCRE is nice, and much more versatile/powerful than the (much older) POSIX regexps.
  • The application is within Apache, which already uses PCRE.

However, I then have to link PCRE into apr-util, which then links into an httpd instance linking its own pcre. This caused a whole bunch of trouble, and since I’m under some pressure of time, I abandoned the attempt to make it work and reverted to POSIX regexps. These in turn caused grief until I remembered that little thing, the REG_EXTENDED flag that POSIX requires to enable regexp memory. And a reminder of platform issues, when I debugged in gdb and saw just how different the regexp implementation on the Client’s Solaris platform is from my Linux development platform!

Not a big deal. Just a b***** annoying waste of time on what should be a trivial issue. Grrr …