[LLVMdev] Regular Expression lib support

Török Edwin edwintorok at gmail.com
Tue Aug 25 01:02:02 PDT 2009


On 2009-08-24 20:14, Chris Lattner wrote:
> On Aug 23, 2009, at 11:59 PM, Török Edwin wrote:
>> If LLVM is going to have an integrated regex library I suggest using it
>> regardless if the platform has one.
>> The LLVM integrated regex library will provide consistent behaviour and
>> execution time, the system one will not.
>
> Hi Edwin,
>
> Can you propose the openbsd implementation as a patch to lib/support?
>
> -Chris

Attached is a proposed patch.
The Regex class is a fairly simple wrapper around the
llvm_regcomp/llvm_regexec functions,
maybe the interface could be improved, right now I just focused on
getting it to work.
Also the OpenBSD implementation has some extensions (see docs/regex.7),
if they are useful those can be added to the Regex class also.

A summary of changes from OpenBSD version:
 - rename functions and types to avoid clashes with system one:
regcomp->llvm_regcomp, ..., regex_t -> llvm_regex_t, regoff_t ->
llvm_regoff_t, BAD -> REGEX_BAD ...
 - include strlcpy.c (llvm_strlcpy), a configure check could be added to
use system's one, but the function is so simple I just unconditionally
always use it
 - memcpy -> memmove (parameters may overlap, BSD memcpy allows that but
POSIX doesn't)
 - COPYRIGHT -> COPYRIGHT.regex, engine.c -> engine.inc, regex.h ->
llvm/Support/regex.h
 - char* -> const char* to avoid compiler warnings
 - #define DUPMAX
 
There is also a unittests/Support/RegexTest.cpp that does some very
simple tests.

Let me know how it works on your platform.

Best regards,
--Edwin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-regex-support.patch.gz
Type: application/gzip
Size: 37479 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090825/133946e3/attachment.bin>


More information about the llvm-dev mailing list