[TRE-general] Using TRE with other regex libraries

Reuben Thomas rrt at sc3d.org
Wed May 2 15:44:58 EEST 2007


There are two problems with using TRE's POSIX API:

1. On systems whose libc implements it too, it can be impossible to use 
libtre in some circumstances. For example, on Linux, if libtre is used in a 
module which is itself dynamically loaded, then if the main program is not 
itself linked against libtre, the libc functions will be used in preference 
to libtre's.

2. It can't be used from a program which also uses another POSIX-exporting 
API.

There is any easy solution to this, which PCRE uses: use #define to rename 
POSIX regex functions

i.e. define tre's functions as

tre_regcomp
tre_regfree
...

and then in regex.h, do

#define regcomp tre_regcomp

&c.

My particular application is lrexlib (http://luaforge.net/projects/lrexlib), 
as regular expression library for the scripting language Lua 
(http://www.lua.org/) which allows POSIX, PCRE and TRE regexs to be used; 
each is compiled as a separate dynamically loaded module. Until this problem 
is fixed we can't ship TRE support on Linux (or, quite probably, anything 
but Windows) unless we patch and compile it ourselves.

-- 
http://rrt.sc3d.org/ | fantasize, a.  the largest you can imagine


More information about the TRE-general mailing list