summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2010-10-05 15:57:43 +0100
committerReuben Thomas <rrt@sc3d.org>2010-10-05 15:57:43 +0100
commit46f735084490c3b80040ad6ddf1feba963dff1c3 (patch)
tree63e76cd8f553d9ab65cba96e5a56e0c24fc3b86b
parentb9b9d1407309e189c551a9c689c94a2875ec6219 (diff)
parente3c05062b578b9c55e7355f6be11b0561e965fd7 (diff)
downloadlrexlib-46f735084490c3b80040ad6ddf1feba963dff1c3.tar.gz
Merge branch 'master' of github.com:rrthomas/lrexlib
-rw-r--r--ChangeLog.old845
-rw-r--r--Makefile5
-rw-r--r--NEWS7
-rw-r--r--README5
-rwxr-xr-xdoc/.gitignore1
-rw-r--r--doc/manual.txt3
-rw-r--r--src/algo.h2
-rw-r--r--src/defaults.mak1
-rw-r--r--src/gnu/regex.h680
-rw-r--r--src/gnu/regex_internal.h873
-rw-r--r--test/emacs_sets.lua3
-rw-r--r--test/gnu_sets.lua6
-rw-r--r--windows/mingw/Makefile8
-rw-r--r--windows/mingw/_mingw.mak2
14 files changed, 871 insertions, 1570 deletions
diff --git a/ChangeLog.old b/ChangeLog.old
new file mode 100644
index 0000000..f463d1c
--- /dev/null
+++ b/ChangeLog.old
@@ -0,0 +1,845 @@
+2010-07-06 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lonig.c: casts to suppress compiler warnings.
+
+2010-07-05 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre_f.c: added flags up to PCRE version 8.10.
+
+2010-01-19 Shmuel Zeigerman <shmuz@013net.net>
+
+ * several files: luaL_typerror renamed to luaL_typeerror (as in Lua 5.2).
+ * common.h: added a macro for handling luaL_typeerror and luaL_typerror.
+
+2009-11-29 Shmuel Zeigerman <shmuz@013net.net>
+
+ * ltre.c: changes to adapt to TRE 0.8
+ 1) #include <tre/tre.h> (was: <tre/regex.h>).
+ 2) added tre_ prefix to all TRE functions.
+
+2009-11-08 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre_f.c: added flags up to PCRE version 8.00.
+
+2008-08-04 Shmuel Zeigerman <shmuz@013net.net>
+
+ * onig.c: making 'locale' and 'syntax' case sensitive again.
+ * onig_f.c: enclose all flags definitions into #ifdef's.
+
+2008-07-30 Reuben Thomas <rrt@sc3d.org>
+
+ * Fixes in make files and docs. Testing on Linux.
+
+2008-07-30 Shmuel Zeigerman <shmuz@013net.net>
+
+ * Place each binding in separate directory:
+ src/posix, src/pcre, src/tre, src/oniguruma.
+
+2008-07-27 Shmuel Zeigerman <shmuz@013net.net>
+
+ * Initial binding of Oniguruma library.
+
+2008-06-22 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/luatest.lua: a fix; did not work with 'strict'.
+
+2008-06-14 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo.h: [API extension; suggested by Reuben Thomas]
+ all functions receiving string-type regex accept a compiled regex too.
+ If this is the case, cf and lo arguments are ignored (should be
+ either supplied as nils or omitted).
+ * algo.h: update version string to "Lrexlib 2.4.0".
+
+2008-05-09 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre_f.c: added new flag from PCRE-7.7.
+
+2008-03-28 Shmuel Zeigerman <shmuz@013net.net>
+ * algo.h, lpcre.h, lposix.h, ltre.h: add two new methods (find and match).
+ * algo.h: rename functions:
+ checkarg_tfind --> checkarg_find_method;
+ generic_tfind --> generic_find_method;
+ checkarg_find_f --> checkarg_find_func;
+ generic_find --> generic_find_func;
+
+2008-03-25 Shmuel Zeigerman <shmuz@013net.net>
+ * algo.h (plainfind_func): optimize for speed.
+ * algo.h (plainfind_func): treat empty patterns as valid.
+ * test/common_sets.lua (set_f_plainfind): add tests with empty patterns.
+
+2008-01-12 Shmuel Zeigerman <shmuz@013net.net>
+ * test/luatest.lua: refactoring.
+
+2007-12-27 Shmuel Zeigerman <shmuz@013net.net>
+ * test/runtest.lua: add new command-line switch -d<directory> that
+ will prepend <directory> to package.cpath.
+ * Makefile: add -d../src to testing commands, for testing the freshly built
+ libraries rather than the installed ones.
+
+2007-12-25 Shmuel Zeigerman <shmuz@013net.net>
+ * test/common_sets.lua, test/spencer_sets.lua, test/pcre_sets.lua,
+ test/pcre_sets2.lua:
+ move tests with NULs in subject from common_sets.lua into other set
+ files.
+
+2007-12-19 Shmuel Zeigerman <shmuz@013net.net>
+
+ * Makefile: [fix] remove TRE-related parts (reported by Christian Wiese).
+ * Makefile: separate PCRE and POSIX targets (suggested by Hisham Muhammad).
+ * src/common.mak: express "ld" and "-shared" via variables (suggested by
+ Hisham Muhammad).
+ * src/algo.h: update version string to "Lrexlib 2.2.2".
+
+2007-11-09 Shmuel Zeigerman <shmuz@013net.net>
+
+ * 4 source files: refactoring (ALG_GETCFLAGS redefined).
+
+2007-10-25 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo.h: version string updated to "Lrexlib 2.2.1".
+
+2007-09-25 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre_f.c: added new flags from PCRE-7.4.
+
+2007-09-20 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo.h (generic_tfind): bugfix.
+
+ * common_sets.lua (set_m_exec): one test added.
+
+2007-08-29 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre_f.c: added new flags from PCRE-7.3.
+
+2007-06-10 Shmuel Zeigerman <shmuz@013net.net>
+
+ * makefiles for Windows/MinGW:
+ * .a files are not needed anymore
+ * added test and install targets
+
+2007-06-08 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo_t.h: file removed; its contents moved to common.h.
+
+2007-05-03 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (settables): removed API function.
+
+2007-05-02 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo_t.h: new file added, for making struct definitions visible to
+ the file parts lying above the line #include algo.h.
+
+ * lpcre.c: [API extension]: cflags may be specified by a string.
+
+2007-04-30 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (REX_OPENLIB, OPTLOCALE, compile_regex): bugfix: "tables"
+ userdata could be garbage-collected before the "regex" userdata
+ that was using it.
+
+ * lpcre_f.c: added a new flag from PCRE-7.1.
+
+2007-04-21 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/luatest.lua (eq): no more relying on tostring producing unique
+ strings for different tables.
+
+2007-04-20 Shmuel Zeigerman <shmuz@013net.net>
+
+ * ltre.c (get_int_field, set_int_field): moved to common.c.
+
+2007-04-19 Reuben Thomas <rrt@sc3d.org>
+
+ * Add build system support for TRE on POSIX systems.
+
+2007-04-18 Reuben Thomas <rrt@sc3d.org>
+
+ * lpcre.c, lposix.c, ltre.c, algo.h: Fix some compiler warnings.
+
+2007-04-17 Shmuel Zeigerman <shmuz@013net.net>
+
+ * <all source files>: the metatable for regex userdata is the C-functions
+ environment (not kept in the lua_State registry anymore).
+ * lpcre.c: the metatable for 'pcre_tables' userdata is kept at index 1
+ of the C-functions environment.
+
+2007-04-14 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.h (maketables): new API function (PCRE only).
+
+2007-04-13 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo.h (gmatch_iter, split_iter): bugfix: was improper detection
+ of a "no advance" situation.
+ * algo.h (split_iter): bugfix: if the subject ends with a separator,
+ there must be an additional pass giving an empty section.
+ * test/common_sets.lua: test results adjusted for bugfix in 'split'.
+ * test/pcre_sets.lua: gmatch tests added (testing "retry" feature).
+
+2007-04-12 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo.h, lpcre.c (USE_RETRY): new macro. Changed gsub and gmatch
+ behavior under PCRE when a "no advance" situation occurs.
+ * test/pcre_sets2.lua: test results adjusted for the change in gsub
+ behavior.
+
+2007-04-11 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (settables): new API function (PCRE only).
+ * test/pcre_sets.lua: locale tests added.
+
+2007-03-19 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo.h, lpcre.c, lposix.c, ltre.c: improved userdata check
+ (detects bad userdata error prior to calling methods;
+ prevents crashes).
+
+2007-03-10 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo.h: many functions added.
+ * lpcre.c, lposix.c, ltre.c: many functions removed.
+
+2007-03-09 Shmuel Zeigerman <shmuz@013net.net>
+
+ * algo.h: new file added -- to contain the code of common algorithms.
+ * It is, in fact, a C-file.
+ * gsub, match, find: functions added
+
+ * lpcre.c, lposix.c, ltre.c (gsub, match, find): functions removed.
+
+2007-03-07 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lposix.c (REX_NSUB_BASE1): macro added, to facilitate building for
+ Tom Lord's library.
+
+2007-03-06 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lposix.c, ltre.c (gmatch, split, gsub): bugfixes:
+ incorrect processing of patterns anchored at the beginning.
+ Was cured that way: if (offset > 0) eflags |= REG_NOTBOL;
+
+ * test/common_sets.lua: test cases added.
+
+2007-03-05 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (gsub): bugfix:
+ Test: { {"abcd", "\\b", "%1"}, {"abcd", 2, 2} }.
+
+ * test/pcre_sets2.lua: a test case added.
+
+2007-03-03 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c, ltre.c (gsub): [API change]:
+ gsub returns 3 values; the 3-rd is number of replacements made.
+
+ * test/*.lua: corrected tests for gsub (after API change).
+
+2007-03-02 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/common_sets.lua: added new tests for gsub (after API change).
+
+2007-03-01 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c, ltre.c (gsub): [API change]:
+ a) 2-nd return of rep() is ignored --> API-compatible with string.gsub
+ b) argument `n' can be a function --> API extension wrt string.gsub
+
+ * common.h (REX_VERSION): updated to "2.2.0 beta".
+
+2007-02-23 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lpcre_f.c:
+ * added #ifdef's to do named subpatterns only if PCRE_MAJOR >= 4,
+ otherwise it wouldn't compile for PCRE 3.x [bugreport by Zhao Zhiguo].
+ * same #ifdef for Lpcre_config function.
+
+2007-02-20 Shmuel Zeigerman <shmuz@013net.net>
+
+ * ltre.c (aexec, atfind, have_backrefs, have_approx): new methods.
+ aexec --> exec + approximate matching;
+ atfind --> tfind + approximate matching;
+ have_backrefs --> binding of tre_have_backrefs;
+ have_approx --> binding of tre_have_approx;
+
+2007-02-18 Shmuel Zeigerman <shmuz@013net.net>
+
+ * ltre.c: all uses of regexec replaced by regnexec.
+ * test/common_sets.lua: added tests with nuls in the subject.
+
+2007-02-17 Shmuel Zeigerman <shmuz@013net.net>
+
+ * ltre.c: new file added (started the binding of the TRE regex library).
+ * test/posix_sets.lua: added tests with nuls in the subject or/and
+ the pattern.
+
+2007-02-12 Shmuel Zeigerman <shmuz@013net.net>
+
+ * all sources (match, find, tfind, exec, dfa_exec): [API change]
+ in case of ordinary non-match, only a nil is returned;
+ other non-match cases generate an error.
+
+ * test suite and the manual: updated to reflect the above API change.
+
+ * all sources (gmatch, split, gsub): [bugfix]
+ if during repeated matching pcre_exec/regexec returns a value that
+ means neither match nor no-match, then an error is generated.
+
+ * common.h (REX_VERSION): updated to "2.1.0".
+
+2007-01-29 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lposix.c (checkarg_find_f): [bugfix] incorrect default for eflags.
+ * lposix.c (generic_find): [bugfix] dereferencing uninitialized pointer.
+ * common.h (REX_VERSION): updated to "2.0.2".
+
+2007-01-27 Reuben Thomas <rrt@sc3d.org>
+
+ * lpcre.c, lposix.c (gsub): [bugfix]
+ - it was incorrectly assumed that the value on Lua stack was a string;
+ - luaL_error was used where lua_error was more appropriate;
+
+2007-01-18 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (gsub): [API change undone].
+ * all source files: refactoring.
+
+2007-01-14 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (gsub): [API change]:
+ a) 2-nd return of rep() is ignored --> API-compatible with string.gsub
+ b) argument `n' can be a function --> API extension wrt string.gsub
+
+2007-01-13 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: refactoring.
+ * common.c, common.h: refactoring.
+ * common.h (REX_VERSION): a new #define.
+ * lpcre.c, lposix.c (REX_OPENLIB): using REX_VERSION.
+
+2007-01-12 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.h, common.c: a nasty bug fixed.
+ * lpcre.c, lposix.c: version updated to 2.0.1.
+
+2007-01-10 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: refactoring.
+
+2007-01-08 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: refactoring.
+
+2007-01-04 Reuben Thomas <rrt@sc3d.org>
+
+ * Add a top-level Makefile with all, clean and test targets.
+ * Split src/*.mak common parts into src/common.mak.
+
+2007-01-04 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (Lpcre_gsub): unnecessary (though harmless) assignment removed.
+ * test/runtest.lua: extended the command-line interface.
+ * most files: the copyright notice changed to reference LICENSE file.
+
+2007-01-02 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.c (CheckFunction, OptFunction): functions removed.
+ * lpcre.c (put_integer): function removed.
+
+2006-12-31 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.c (udata_tostring): function removed.
+ * lpcre.c (Lpcre_tostring): added handling of deleted userdatum.
+ * lposix.c (Posix_tostring): added handling of deleted userdatum.
+ * lpcre.c: [API change] method `exec' now supports "named subpatterns".
+ * test/all_test.lua: renamed to runtest.lua.
+
+2006-12-30 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c: [API change] `versionPCRE' renamed to `version'.
+
+2006-12-29 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c: [API change] removed support of PCRE callout.
+ * test/pcre_sets.lua: removed testing of PCRE callout.
+
+2006-12-27 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre_f.c (config): [API change] the function accepts one optional
+ argument (a table), like the `flags' function.
+
+2006-12-26 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c (gsub): [API change] method become function.
+ * test/*.lua: modifying tests to reflect methods become functions.
+ * lua/rex.lua: file deleted.
+ * lpcre.c (luaopen_rex_pcre): changed the condition for validating
+ run-time PCRE version.
+ * lpcre_f.c: added new flags for support of PCRE 7.0.
+ * lpcre.c, lposix.c (checkarg_gsub): if the 3-rd argument is of type
+ "number" then it is converted to string (as in string.gsub).
+
+2006-12-25 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c (match, find, gmatch, split): [API change]
+ methods become functions.
+
+2006-12-23 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/*.lua: refactoring.
+
+2006-12-22 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c (tfind and exec): [API change]
+ the return value of the underlying pcre_exec/regexec call
+ is not added in the case of successfull match.
+ * lpcre.c, lposix.c (gtfind): [API change] method removed.
+ * lpcre.c, lposix.c: Lrexlib 2.0 beta -> Lrexlib 2.0.
+ * test/luatest.lua (eq): bugfix.
+ * lua/*.lua: deleted all lua files except for rex.lua.
+ * lua/rex.lua: fully rewritten; now contains wrappers for all methods.
+
+2006-12-21 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/*.lua: added tests for `split' method.
+ * test/luatest.lua (print_results): function added.
+ * test/common_sets.lua: file added.
+
+2006-12-19 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.lua: `split' method added.
+ * lposix.lua: `split' method added.
+ * test/framework.lua: renamed to luatest.lua.
+
+2006-12-15 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/*.lua: refactoring.
+
+2006-12-11 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/*.lua: refactoring; deleting files; adding new files.
+
+2006-12-10 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: gmatch bug fixed. Test case added.
+ * lpcre.c, lposix.c: gtfind bug fixed. Test case added.
+
+2006-12-09 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lua/gsub_test.lua, gsub_tstpsx.lua: 2 files deleted.
+ * lua/posix_sets.lua, pcre_sets.lua, framework.lua, all_test.lua:
+ 4 files added.
+ * lpcre.c, lposix.c, common.c, common.h:
+ an API alteration in gsub and gtfind methods: if a non-positive number
+ is supplied as the 'n' parameter, then no iterations are done.
+ Test cases added to *.lua test files.
+
+2006-12-07 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c (gsub): if parameter rep is a function,
+ and its 2-nd return value (if present) is a string "break",
+ then gsub immediately returns.
+ * test/*.lua: refactoring.
+
+2006-12-06 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: refactoring.
+
+2006-12-05 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lposix.c: cosmetics.
+
+2006-12-04 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: introduced new macros: CAP_BEG, CAP_END and CAP_LEN.
+ * lpcre.c, lpcre_f.c, lposix.c: refactoring.
+
+2006-12-03 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (Lpcre_gsub_func): an improvement.
+ * lposix.c (posix_gsub_func): an improvement.
+ * lpcre.c, lposix.c (gmatch, match, find): functions removed.
+ * lpcre.c, lposix.c: method tgfind renamed to gtfind.
+ * lpcre.c, lposix.c: gsub function become method.
+ * test/posix_test.lua, pcre_test.lua: removed tests for removed functions.
+
+2006-12-02 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.c, common.h (TBuffer): moved here from lpcre.c.
+ * common.c, common.h (TFreeList): helper class created.
+ * lpcre.c (Lpcre_gsub_func): many changes.
+ * lposix.c (posix_gsub_func): added function gsub.
+ * test/gsub_test.lua: added testing for the new written-in-C gsub.
+ * test/gsub_tstpsx.lua: file added.
+ * test/rex_.lua: file deleted.
+
+2006-12-01 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (TBuffer): helper class created.
+ * lpcre.c (Lpcre_gsub_func): many changes.
+
+2006-11-30 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (TExecData): struct renamed to TCallout.
+ * lpcre.c (LpcreSetExecData): function renamed to SetupCallout.
+ * lpcre.c (Lpcre_gsub_func): added function gsub.
+
+2006-11-29 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/*.lua: refactoring.
+ * lpcre.c, lposix.c: refactoring.
+ * lpcre.c, lposix.c (oldmatch): renamed to tfind.
+ * lpcre.c, lposix.c (oldgmatch): renamed to tgfind.
+ * */*.lua: renamed: oldmatch -> tfind; oldgmatch -> tgfind.
+
+2006-11-28 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (Lpcre_dfa_exec): one Lmalloc call instead of two.
+
+2006-11-27 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.c (plainfind_func): rewritten to not use memicmp
+ * test/*.lua: every test returns number of failures
+
+2006-11-26 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: all Check_arg_* functions renamed to Checkarg_*
+ * lpcre.c (Lpcre_dfa_exec): added 2 arguments to dfa_exec
+ * common.h (DIM): macro removed
+ * test/pcre_test.lua: tests for dfa_exec method added
+
+2006-11-25 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: alpha -> beta.
+ * lpcre_f.c: file added (was: part of lpcre.c).
+ * rex_pcre.mak: updated due to the new file lpcre_f.c
+ * *.mak: version updated to 2.0
+ * test/all_test.lua: file added.
+ * test/posix_test.lua, test/pcre_test.lua: made modules.
+ * test/posix_test.lua: tests added.
+ * test/*.lua: refactoring.
+ * lua/generic_gsub.lua: refactoring.
+
+2006-11-23 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/*.lua: refactoring.
+ * lua/rex.lua, lua/rex_.lua (gsub): 6th and 7th arguments swapped.
+
+2006-11-22 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (Check_arg_findmatch_func): 5th and 6th arguments swapped.
+ * lpcre.c (Check_arg_gmatch_func): 4th and 5th arguments swapped.
+ * test/posix_test.lua: file added.
+ * lposix.c: 2 bugs fixed.
+
+2006-11-21 Shmuel Zeigerman <shmuz@013net.net>
+
+ * test/pcre_test.lua: "named subpatterns" tests added.
+
+2006-11-20 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.c, common.h (plainfind_func): function added.
+ * lpcre.c, lposix.c (rex.plainfind): new function (from Lua side).
+ * test/framework.lua: file added.
+ * test/pcre_test.lua: file added.
+
+2006-11-19 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (Lpcre_config): new function (pcre.config from Lua side).
+ * lpcre.c: callout handling improved.
+
+2006-11-18 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: old 'gmatch' method put back; renamed into 'oldgmatch'.
+
+2006-11-17 Shmuel Zeigerman <shmuz@013net.net>
+
+ * windows/bcc32/make_bcc.mak: deleted -DCOMPAT51, added -D$(CMDLINE)
+
+2006-11-16 Shmuel Zeigerman <shmuz@013net.net>
+
+ * gsub_test.lua (PatternLua2Pcre): function renamed into 'pat2pcre'.
+ * lua/pat2pcre.lua: file added (was part of gsub_test.lua).
+
+2006-11-15 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c, lposix.c: Lua API has changed:
+ * 'match' method renamed to 'oldmatch'
+ * added (as much as possible) Lua string library API compatible:
+ 'find', 'match' and 'gmatch' - each one being a function/method pair.
+ * lpcre.c (newPCRE, flagsPCRE): functions removed.
+ * lposix.c (newPOSIX, flagsPOSIX): functions removed.
+ * lpcre.c, lposix.c: added literal rex._VERSION.
+ * rex.lua: deleted everything except gsub.
+ * rex.lua (gsub): rex.oldmatch is used instead of rex.match.
+ * generic_gsub.lua: rex.oldmatch is used instead of rex.match.
+ * test/test1.lua: file added
+
+2006-11-12 Shmuel Zeigerman <shmuz@013net.net>
+
+ * rex.lua (r:gmatch): metamethod added.
+ * lpcre.c (Lpcre_maketables): function API simplified.
+ * lpcre.c (Lpcre_getargs): function removed.
+ * lpcre.c (LpcreGetExecParams): renamed from LpcreProcessExecParams.
+
+2006-11-09 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lua/bit.lua: file removed.
+
+2006-11-05 Shmuel Zeigerman <shmuz@013net.net>
+
+ * rex.lua (gsub): a few structural optimizations.
+ * rex.lua (gmatch): a bugfix.
+ * rex.lua: tests deleted from the file.
+ * gsub.lua: renamed into 'generic_gsub.lua'; made a module.
+ * new_gsub.lua: file deleted.
+ * lua/bit.lua: file added.
+
+2006-11-04 Reuben Thomas <rrt@sc3d.org>
+
+ * rex.lua (gmatch): function rewritten to be compatible with
+ string.gmatch.
+ * find.lua: file deleted.
+ * lpcre.c (Lpcre_gmatch): function deleted.
+ * lposix.c (posix_gmatch): function deleted.
+
+2006-11-04 Shmuel Zeigerman <shmuz@013net.net>
+
+ * gsub.lua, new_gsub.lua, gsub_test.lua, rex.lua: bugfixes.
+
+2006-10-18 Shmuel Zeigerman <shmuz@013net.net>
+
+ * [Windows] DLL builds need lua5.1.dll rather than lua51.dll.
+
+2006-10-02 Shmuel Zeigerman <shmuz@013net.net>
+
+ * Support of Lua 5.0 was dropped.
+
+2006-09-03 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.h (REX_LIB_API): renamed into REX_API.
+ * common.h (flags_pair): renamed into flag_pair.
+ * common.h, lpcre.h, lposix.h (REX_REGISTER): renamed into rex_register.
+ * lpcre.h (luaopen_rex_pcre): error message text changed.
+ * lposix.c (posix_handle, posix_typename):
+ string literals are prefixed by $(REX_LIBNAME).
+ [ This makes possible using multiple rex_posix libraries
+ at a time by one lua_State. ]
+ * lpcre.c (pcre_handle, pcre_typename):
+ string literals are prefixed by $(REX_LIBNAME).
+ [ This makes possible using multiple rex_pcre libraries
+ at a time by one lua_State. ]
+ * added directory test/Spencer (containing test.lua).
+ * test/Spencer/test.lua: file returns a function.
+
+2006-08-27 Shmuel Zeigerman <shmuz@013net.net>
+
+ * (local) merge with the version put into CVS by R.Thomas.
+ * common.h: added conditional #define's for lua_pushinteger and
+ lua_tointeger (needed to compile with Lua 5.0).
+
+2006-08-18 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.c, lpcre.c, lposix.c: lua_pushnumber replaced with
+ lua_pushinteger where appropriate (in many places).
+ * lpcre.c (put_number): function renamed into put_integer.
+
+2006-06-17 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lpcre.c (TPcreExecParam): `use_callout' struct member was eliminated.
+ Instead, a special value of function reference (LUA_NOREF) is used.
+
+2006-04-01 Reuben Thomas <rrt@sc3d.org>
+
+ * lpcre.c, common.c: Remove trailing whitespace.
+ * lpcre.c (Lpcre_gmatch): Remove unnecessary limit variable.
+
+2006-02-17 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.c, common.h (L_lua_error): function deleted.
+ * common.c, lpcre.c, lposix.c: luaL_error used in place of L_lua_error.
+ * lposix.c (posix2): struct renamed into TPosix.
+ * lposix.c (posix_comp): lua_newuserdata() used instead of Lmalloc().
+
+2005-12-26 Shmuel Zeigerman <shmuz@013net.net>
+
+ * Separate makefiles for POSIX and PCRE. No config file.
+
+2005-11-28 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.h (REXLIB_API): macro renamed into REX_LIB_API.
+ * lposix.c (LREXLIB_POSIX_EXT): macro renamed into REX_POSIX_EXT.
+
+2005-11-26 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.h (LUAL_REGISTER): macro renamed into REX_REGISTER.
+ * lpcre.c (LUAOPEN_LIB): macro renamed into REX_OPENLIB.
+ * lpcre.c (LIBNAME): macro renamed into REX_LIBNAME.
+
+2005-11-15 Shmuel Zeigerman <shmuz@013net.net>
+
+ * common.c, common.h, lposix.c, lpcre.c: new files (lrexlib.c was
+ splitted); POSIX and PCRE parts now live in their own
+ separate files.
+ * common.h (REXLIB_API): new macro.
+ * lposix.c (LREXLIB_POSIX): macro removed.
+ * lposix.c (LUAOPEN_LIB, LIBNAME): new macros.
+ * lposix.c (rexlib): Lua-side functions flagsPOSIX and newPOSIX
+ now have aliases (flags and new, correspondently).
+ * lpcre.c (LREXLIB_PCRE): macro removed.
+ * lpcre.c (LUAOPEN_LIB, LIBNAME): new macros.
+ * lpcre.c (rexlib): Lua-side functions flagsPCRE and newPCRE now
+ have aliases (flags and new, correspondently).
+ * lpcre.c (Lpcre_vers): function renamed into Lpcre_version.
+
+2005-11-12 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c (LUAL_REGISTER): new macro.
+
+2005-11-10 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c (posix_match_generic): return (on Lua-side) an
+ additional value (the return code of regexec).
+ * lrexlib.c (Lpcre_match_generic): return (on Lua-side) an
+ additional value (the return code of pcre_exec).
+ * lrexlib.c (Lpcre_dfa_exec): return (on Lua-side) an additional
+ value (the return code of pcre_dfa_exec).
+
+2005-10-29 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c (get_flags): the function now accepts one parameter
+ from the Lua stack (a table). Was: no parameters. (This
+ affects the Lua-side functions: flagsPOSIX and
+ flagsPCRE).
+ * lrexlib.c (LREXLIB_POSIX_EXT): it's now possible to force-define
+ this macro at compile time, bypassing the automatic
+ detection.
+ * lrexlib.c: added new POSIX flags (error values).
+ * lrexlib.c (LpcreProcessParams): renamed into
+ LpcreProcessExecParams.
+ * lrexlib.c: added all missing PCRE flags starting from PCRE
+ version 4.
+
+2005-10-25 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c (DIM): new macro.
+ * lrexlib.c (pcre2): renamed into TPcre.
+ * lrexlib.c (TPcreExecParam): new struct.
+ * lrexlib.c (LpcreProcessParams): new function.
+ * lrexlib.c (Lpcre_dfa_exec): new function. Lua-side: dfa_exec.
+ * lrexlib.c (Lpcre_dfa_restart): new function. Lua-side: dfa_restart.
+
+2005-10-23 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c (TPcreCalloutData): new struct.
+ * lrexlib.c (Lpcre_callout): new function.
+ * lrexlib.c (Lpcre_match_generic): PCRE callout support added.
+ * lrexlib.c: added new PCRE flags (from PCRE versions 5 and 6).
+ * lrexlib.c (put_number): new helper function.
+
+2005-05-27 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c: updated to work with Compat-5.1.
+
+2004-12-18 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c (regex_tostring): error handling added.
+ * lrexlib.c (regex_tostring): renamed into udata_tostring.
+ * lrexlib.c (regex_get_flags): renamed into get_flags.
+ * lrexlib.c (Lpcre_comp): pattern offset included in error message.
+ * lrexlib.c (Lpcre_comp): error check added after pcre_study call.
+ * lrexlib.c (Lpcre_push_substrings): eliminated inserting nil
+ values into the matches table (not a bug, redundancy).
+ * lrexlib.c (Lpcre_push_substrings): lua_rawset call instead of
+ lua_settable.
+ * lrexlib.c: all stack buffers used for message formatting changed
+ in size from 128 to 256 bytes.
+
+2004-11-17 Nick Gammon <nick@gammon.com.au>
+
+ * lrexlib.c (pcre2): new member pcre2.extra.
+ * lrexlib.c (Lpcre_comp): pcre_study call added.
+ * lrexlib.c (Lpcre_push_matches, Lpcre_push_substrings,
+ Lpcre_push_offsets): function signatures changed.
+ * lrexlib.c (Lpcre_push_substrings): added support for "named
+ subpatterns".
+
+2004-09-15 Shmuel Zeigerman <shmuz@013net.net>
+
+ * gsub.lua (is_odd): Function removed; math.mod used instead.
+
+2004-08-24 Shmuel Zeigerman <shmuz@013net.net>
+
+ * ChangeLog: File added.
+ * NEWS: File added.
+
+2004-08-12 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c (posix_exec, Lpcre_exec): New C functions, that
+ correspond to the new lua function 'r:exec'.
+ * lrexlib.c (posix_tostring, Lpcre_tostring): New C functions,
+ that correspond to the new lua function 'r:__tostring'.
+ * lrexlib.c: A table returned by r:match() as its 3rd result has
+ no "n" index set anymore.
+ * lrexlib.c (LREXLIB_POSIX_EXT): New macro.
+ * lrexlib.c (PCRE_LOCALE_SUPPORT): Macro removed.
+ * lrexlib.c (posix_push_matches, Lpcre_push_matches): Functions
+ became typedef's.
+ * lrexlib.c (posix_match_generic, Lpcre_match_generic)
+ (posix_push_substrings, Lpcre_push_substrings)
+ (posix_push_offsets, Lpcre_push_offsets): New functions.
+ * gsub.lua: File added.
+
+2004-08-11 Reuben Thomas <rrt@sc3d.org>
+
+ * config: Many changes.
+ * Makefile: Many changes.
+
+2004-08-11 Shmuel Zeigerman <shmuz@013net.net>
+
+ * config: File added + many changes.
+ * Makefile: Many changes.
+
+2004-07-15 Shmuel Zeigerman <shmuz@013net.net>
+
+ * lrexlib.c (posix_get_flags, Lpcre_get_flags, Lpcre_vers): New C
+ functions, that correspond to new lua functions
+ 'flagsPOSIX', 'flagsPCRE', 'versionPCRE'.
+ * lrexlib.c: Lua functions 'newPCRE' and 'newPOSIX' accept an
+ optional 2nd argument ("compilation flags").
+ * lrexlib.c: Lua function 'newPCRE' accepts an optional 3rd
+ argument ("locale") - but only if the macro
+ PCRE_LOCALE_SUPPORT was defined at the compilation time.
+ * lrexlib.c: Lua function 'r:match' accepts optional 2nd and 3rd
+ arguments ("startoffset" and "execution flags").
+ * lrexlib.c: Lua function 'r:gmatch' accepts an optional 2nd
+ argument ("execution flags").
+ * lrexlib.c (posix_gmatch, Lpcre_gmatch): If a user-defined lua
+ function passed as the 2nd parameter returns true value,
+ then lua function 'r:gmatch' returns.
+ * lrexlib.c (posix_push_matches, Lpcre_push_matches): The table of
+ substring matches contains false in the positions
+ correspondent to non-matched subpatterns.
+ * lrexlib.c: Static functions that began with 'pcre' were renamed
+ to begin with 'Lpcre'.
+ * lrexlib.c (posix_getargs, Lpcre_getargs):
+ Fixed - allocated memory was not freed.
+ Fixed - removed redundant calls of lua_checkstack.
+ * lrexlib.c: Allocation/freeing memory moved from matching
+ operations to pattern-compiling and garbage-collecting
+ ones.
+ * lrexlib.c (posix_match, posix_gmatch, Lpcre_match, Lpcre_gmatch):
+ luaL_checkudata is used in checking of userdata-type
+ parameter.
+ * lrexlib.c: Removed conditional compilation controlled by the
+ macro REG_BASIC.
+ * lrexlib.c (posix_comp): The following invalid ANSI C89 code:
+ size_t sz = <expression>; char errbuf[sz];
+ made valid with the use of malloc/free.
+ * lrexlib.c (Lpcre_gmatch): Keeping 'subject' and 'length'
+ unchanged while updating 'startoffset'.
+ * lbitlib.c: File removed.
+ * Makefile: Removed parts related to lbitlib.c.
+ * make_bcc.mak: File added.
diff --git a/Makefile b/Makefile
index 5978db0..2180809 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@
include src/defaults.mak
REGNAMES = gnu pcre posix oniguruma tre
-DISTFILE = lrexlib-$(V).zip
+DISTFILE = lrexlib-$(V).$(MINORV).zip
all:
@for i in $(REGNAMES); do \
@@ -26,6 +26,5 @@ clean:
dist: all
git2cl > ChangeLog
- cp -a doc/index.txt README
rm -f $(DISTFILE)
- zip $(DISTFILE) -r . -x ".git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*"
+ zip $(DISTFILE) -r . -x ".git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*SciTE.properties" "*scite.properties"
diff --git a/NEWS b/NEWS
index 6f9f76f..b9fe2f6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,9 @@
-2010-09-15 Release 2.5.0
+2010-10-04 Release 2.5.1
+
+ * Minor improvements and fixes, no changes to library code.
+
+
+2010-10-03 Release 2.5.0
* Added bindings of the TRE and GNU regex APIs.
diff --git a/README b/README
index c585a3c..a261b19 100644
--- a/README
+++ b/README
@@ -5,10 +5,11 @@ Lrexlib 2.5
| and Shmuel Zeigerman (shmuz@013net.net) [maintainer]
**Lrexlib** provides bindings of five regular expression library APIs
-(POSIX_, PCRE_, GNU_, TRE_ and Oniguruma_) to Lua_ 5.1.
+(POSIX_, PCRE_, GNU_, TRE_ and Oniguruma_) to Lua_ 5.1. The bindings
+for TRE and Oniguruma are not currently complete.
**Lrexlib** is copyright Reuben Thomas 2000-2010 and copyright Shmuel
-Zeigerman 2004-2010, and is released under under the license as Lua,
+Zeigerman 2004-2010, and is released under the same license as Lua,
the MIT_ license (otherwise known as the revised BSD license). There
is no warranty.
diff --git a/doc/.gitignore b/doc/.gitignore
index ada902c..cf8dde6 100755
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -1,2 +1,3 @@
+index.txt
index.html
manual.html
diff --git a/doc/manual.txt b/doc/manual.txt
index 7022864..39f0b7b 100644
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -46,8 +46,7 @@ Notes
* REG_EXTENDED for POSIX and TRE
* 0 for PCRE
* ONIG_OPTION_NONE for Oniguruma
- * GNU does not use this argument; it is ignored (but must be
- present if further arguments are used)
+ * SYNTAX_POSIX_EXTENDED for GNU
**PCRE**, **Oniguruma**: *cf* may also be supplied as a string, whose
characters stand for compilation flags. Combinations of the following
diff --git a/src/algo.h b/src/algo.h
index b914312..2a4288d 100644
--- a/src/algo.h
+++ b/src/algo.h
@@ -3,7 +3,7 @@
#include "common.h"
-#define REX_VERSION "Lrexlib 2.5.0"
+#define REX_VERSION "Lrexlib 2.5.1"
/* Forward declarations */
static void gmatch_pushsubject (lua_State *L, TArgExec *argE);
diff --git a/src/defaults.mak b/src/defaults.mak
index 676f11b..36fb5f6 100644
--- a/src/defaults.mak
+++ b/src/defaults.mak
@@ -1,6 +1,7 @@
# default settings for lrexlib
V = 2.5
+MINORV = 1
INC_LUA =
LIB_LUA =
diff --git a/src/gnu/regex.h b/src/gnu/regex.h
deleted file mode 100644
index 8fab9f6..0000000
--- a/src/gnu/regex.h
+++ /dev/null
@@ -1,680 +0,0 @@
-/* Definitions for data structures and routines for the regular
- expression library.
- Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993, 1995, 1996, 1997, 1998,
- 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010 Free Software Foundation,
- Inc.
- This file is part of the GNU C Library.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#ifndef _REGEX_H
-#define _REGEX_H 1
-
-#include <sys/types.h>
-
-/* Allow the use in C++ code. */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Define __USE_GNU_REGEX to declare GNU extensions that violate the
- POSIX name space rules. */
-#undef __USE_GNU_REGEX
-#if (defined _GNU_SOURCE \
- || (!defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE \
- && !defined _XOPEN_SOURCE))
-# define __USE_GNU_REGEX 1
-#endif
-
-#ifdef _REGEX_LARGE_OFFSETS
-
-/* Use types and values that are wide enough to represent signed and
- unsigned byte offsets in memory. This currently works only when
- the regex code is used outside of the GNU C library; it is not yet
- supported within glibc itself, and glibc users should not define
- _REGEX_LARGE_OFFSETS. */
-
-/* The type of the offset of a byte within a string.
- For historical reasons POSIX 1003.1-2004 requires that regoff_t be
- at least as wide as off_t. However, many common POSIX platforms set
- regoff_t to the more-sensible ssize_t and the Open Group has
- signalled its intention to change the requirement to be that
- regoff_t be at least as wide as ptrdiff_t and ssize_t; see XBD ERN
- 60 (2005-08-25). We don't know of any hosts where ssize_t or
- ptrdiff_t is wider than ssize_t, so ssize_t is safe. */
-typedef ssize_t regoff_t;
-
-/* The type of nonnegative object indexes. Traditionally, GNU regex
- uses 'int' for these. Code that uses __re_idx_t should work
- regardless of whether the type is signed. */
-typedef size_t __re_idx_t;
-
-/* The type of object sizes. */
-typedef size_t __re_size_t;
-
-/* The type of object sizes, in places where the traditional code
- uses unsigned long int. */
-typedef size_t __re_long_size_t;
-
-#else
-
-/* Use types that are binary-compatible with the traditional GNU regex
- implementation, which mishandles strings longer than INT_MAX. */
-
-typedef int regoff_t;
-typedef int __re_idx_t;
-typedef unsigned int __re_size_t;
-typedef unsigned long int __re_long_size_t;
-
-#endif
-
-/* The following two types have to be signed and unsigned integer type
- wide enough to hold a value of a pointer. For most ANSI compilers
- ptrdiff_t and size_t should be likely OK. Still size of these two
- types is 2 for Microsoft C. Ugh... */
-typedef long int s_reg_t;
-typedef unsigned long int active_reg_t;
-
-/* The following bits are used to determine the regexp syntax we
- recognize. The set/not-set meanings are chosen so that Emacs syntax
- remains the value 0. The bits are given in alphabetical order, and
- the definitions shifted by one from the previous bit; thus, when we
- add or remove a bit, only one other definition need change. */
-typedef unsigned long int reg_syntax_t;
-
-#ifdef __USE_GNU_REGEX
-
-/* If this bit is not set, then \ inside a bracket expression is literal.
- If set, then such a \ quotes the following character. */
-# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
-
-/* If this bit is not set, then + and ? are operators, and \+ and \? are
- literals.
- If set, then \+ and \? are operators and + and ? are literals. */
-# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
-
-/* If this bit is set, then character classes are supported. They are:
- [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
- [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
- If not set, then character classes are not supported. */
-# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
-
-/* If this bit is set, then ^ and $ are always anchors (outside bracket
- expressions, of course).
- If this bit is not set, then it depends:
- ^ is an anchor if it is at the beginning of a regular
- expression or after an open-group or an alternation operator;
- $ is an anchor if it is at the end of a regular expression, or
- before a close-group or an alternation operator.
-
- This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
- POSIX draft 11.2 says that * etc. in leading positions is undefined.
- We already implemented a previous draft which made those constructs
- invalid, though, so we haven't changed the code back. */
-# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
-
-/* If this bit is set, then special characters are always special
- regardless of where they are in the pattern.
- If this bit is not set, then special characters are special only in
- some contexts; otherwise they are ordinary. Specifically,
- * + ? and intervals are only special when not after the beginning,
- open-group, or alternation operator. */
-# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
-
-/* If this bit is set, then *, +, ?, and { cannot be first in an re or
- immediately after an alternation or begin-group operator. */
-# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
-
-/* If this bit is set, then . matches newline.
- If not set, then it doesn't. */
-# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
-
-/* If this bit is set, then . doesn't match NUL.
- If not set, then it does. */
-# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
-
-/* If this bit is set, nonmatching lists [^...] do not match newline.
- If not set, they do. */
-# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
-
-/* If this bit is set, either \{...\} or {...} defines an
- interval, depending on RE_NO_BK_BRACES.
- If not set, \{, \}, {, and } are literals. */
-# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
-
-/* If this bit is set, +, ? and | aren't recognized as operators.
- If not set, they are. */
-# define RE_LIMITED_OPS (RE_INTERVALS << 1)
-
-/* If this bit is set, newline is an alternation operator.
- If not set, newline is literal. */
-# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
-
-/* If this bit is set, then `{...}' defines an interval, and \{ and \}
- are literals.
- If not set, then `\{...\}' defines an interval. */
-# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
-
-/* If this bit is set, (...) defines a group, and \( and \) are literals.
- If not set, \(...\) defines a group, and ( and ) are literals. */
-# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
-
-/* If this bit is set, then \<digit> matches <digit>.
- If not set, then \<digit> is a back-reference. */
-# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
-
-/* If this bit is set, then | is an alternation operator, and \| is literal.
- If not set, then \| is an alternation operator, and | is literal. */
-# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
-
-/* If this bit is set, then an ending range point collating higher
- than the starting range point, as in [z-a], is invalid.
- If not set, then when ending range point collates higher than the
- starting range point, the range is ignored. */
-# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
-
-/* If this bit is set, then an unmatched ) is ordinary.
- If not set, then an unmatched ) is invalid. */
-# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
-
-/* If this bit is set, succeed as soon as we match the whole pattern,
- without further backtracking. */
-# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
-
-/* If this bit is set, do not process the GNU regex operators.
- If not set, then the GNU regex operators are recognized. */
-# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
-
-/* If this bit is set, turn on internal regex debugging.
- If not set, and debugging was on, turn it off.
- This only works if regex.c is compiled -DDEBUG.
- We define this bit always, so that all that's needed to turn on
- debugging is to recompile regex.c; the calling code can always have
- this bit set, and it won't affect anything in the normal case. */
-# define RE_DEBUG (RE_NO_GNU_OPS << 1)
-
-/* If this bit is set, a syntactically invalid interval is treated as
- a string of ordinary characters. For example, the ERE 'a{1' is
- treated as 'a\{1'. */
-# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
-
-/* If this bit is set, then ignore case when matching.
- If not set, then case is significant. */
-# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
-
-/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
- for ^, because it is difficult to scan the regex backwards to find
- whether ^ should be special. */
-# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
-
-/* If this bit is set, then \{ cannot be first in a regex or
- immediately after an alternation, open-group or \} operator. */
-# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
-
-/* If this bit is set, then no_sub will be set to 1 during
- re_compile_pattern. */
-# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
-
-/* If this bit is set, then all special characters are ignored
- by re_compile_pattern. */
-# define RE_PLAIN (RE_NO_SUB << 1)
-
-#endif /* defined __USE_GNU_REGEX */
-
-/* This global variable defines the particular regexp syntax to use (for
- some interfaces). When a regexp is compiled, the syntax used is
- stored in the pattern buffer, so changing this does not affect
- already-compiled regexps. */
-extern reg_syntax_t re_syntax_options;
-
-#ifdef __USE_GNU_REGEX
-/* Define combinations of the above bits for the standard possibilities.
- (The [[[ comments delimit what gets put into the Texinfo file, so
- don't delete them!) */
-/* [[[begin syntaxes]]] */
-# define RE_SYNTAX_EMACS 0
-
-# define RE_SYNTAX_AWK \
- (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
- | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
- | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
-
-# define RE_SYNTAX_GNU_AWK \
- ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
- & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \
- | RE_CONTEXT_INVALID_OPS ))
-
-# define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
- | RE_INTERVALS | RE_NO_GNU_OPS)
-
-# define RE_SYNTAX_GREP \
- (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
- | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
- | RE_NEWLINE_ALT)
-
-# define RE_SYNTAX_EGREP \
- (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
- | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
- | RE_NO_BK_VBAR)
-
-# define RE_SYNTAX_POSIX_EGREP \
- (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
- | RE_INVALID_INTERVAL_ORD)
-
-/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
-# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
-
-# define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
-
-/* Syntax bits common to both basic and extended POSIX regex syntax. */
-# define _RE_SYNTAX_POSIX_COMMON \
- (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
- | RE_INTERVALS | RE_NO_EMPTY_RANGES)
-
-# define RE_SYNTAX_POSIX_BASIC \
- (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
-
-/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
- RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
- isn't minimal, since other operators, such as \`, aren't disabled. */
-# define RE_SYNTAX_POSIX_MINIMAL_BASIC \
- (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
-
-# define RE_SYNTAX_POSIX_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
-
-/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
- removed and RE_NO_BK_REFS is added. */
-# define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
-/* [[[end syntaxes]]] */
-
-#endif /* defined __USE_GNU_REGEX */
-
-#ifdef __USE_GNU_REGEX
-
-/* Maximum number of duplicates an interval can allow. POSIX-conforming
- systems might define this in <limits.h>, but we want our
- value, so remove any previous define. */
-# ifdef RE_DUP_MAX
-# undef RE_DUP_MAX
-# endif
-
-/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored
- the counter as a 2-byte signed integer. This is no longer true, so
- RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to
- ((SIZE_MAX - 2) / 10 - 1) if _REGEX_LARGE_OFFSETS is defined.
- However, there would be a huge performance problem if someone
- actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains
- its historical value. */
-# define RE_DUP_MAX (0x7fff)
-
-#endif /* defined __USE_GNU_REGEX */
-
-
-/* POSIX `cflags' bits (i.e., information for `regcomp'). */
-
-/* If this bit is set, then use extended regular expression syntax.
- If not set, then use basic regular expression syntax. */
-#define REG_EXTENDED 1
-
-/* If this bit is set, then ignore case when matching.
- If not set, then case is significant. */
-#define REG_ICASE (1 << 1)
-
-/* If this bit is set, then anchors do not match at newline
- characters in the string.
- If not set, then anchors do match at newlines. */
-#define REG_NEWLINE (1 << 2)
-
-/* If this bit is set, then report only success or fail in regexec.
- If not set, then returns differ between not matching and errors. */
-#define REG_NOSUB (1 << 3)
-
-
-/* POSIX `eflags' bits (i.e., information for regexec). */
-
-/* If this bit is set, then the beginning-of-line operator doesn't match
- the beginning of the string (presumably because it's not the
- beginning of a line).
- If not set, then the beginning-of-line operator does match the
- beginning of the string. */
-#define REG_NOTBOL 1
-
-/* Like REG_NOTBOL, except for the end-of-line. */
-#define REG_NOTEOL (1 << 1)
-
-/* Use PMATCH[0] to delimit the start and end of the search in the
- buffer. */
-#define REG_STARTEND (1 << 2)
-
-
-/* If any error codes are removed, changed, or added, update the
- `__re_error_msgid' table in regcomp.c. */
-
-typedef enum
-{
- _REG_ENOSYS = -1, /* This will never happen for this implementation. */
- _REG_NOERROR = 0, /* Success. */
- _REG_NOMATCH, /* Didn't find a match (for regexec). */
-
- /* POSIX regcomp return error codes. (In the order listed in the
- standard.) */
- _REG_BADPAT, /* Invalid pattern. */
- _REG_ECOLLATE, /* Invalid collating element. */
- _REG_ECTYPE, /* Invalid character class name. */
- _REG_EESCAPE, /* Trailing backslash. */
- _REG_ESUBREG, /* Invalid back reference. */
- _REG_EBRACK, /* Unmatched left bracket. */
- _REG_EPAREN, /* Parenthesis imbalance. */
- _REG_EBRACE, /* Unmatched \{. */
- _REG_BADBR, /* Invalid contents of \{\}. */
- _REG_ERANGE, /* Invalid range end. */
- _REG_ESPACE, /* Ran out of memory. */
- _REG_BADRPT, /* No preceding re for repetition op. */
-
- /* Error codes we've added. */
- _REG_EEND, /* Premature end. */
- _REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
- _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
-} reg_errcode_t;
-
-#ifdef _XOPEN_SOURCE
-# define REG_ENOSYS _REG_ENOSYS
-#endif
-#define REG_NOERROR _REG_NOERROR
-#define REG_NOMATCH _REG_NOMATCH
-#define REG_BADPAT _REG_BADPAT
-#define REG_ECOLLATE _REG_ECOLLATE
-#define REG_ECTYPE _REG_ECTYPE
-#define REG_EESCAPE _REG_EESCAPE
-#define REG_ESUBREG _REG_ESUBREG
-#define REG_EBRACK _REG_EBRACK
-#define REG_EPAREN _REG_EPAREN
-#define REG_EBRACE _REG_EBRACE
-#define REG_BADBR _REG_BADBR
-#define REG_ERANGE _REG_ERANGE
-#define REG_ESPACE _REG_ESPACE
-#define REG_BADRPT _REG_BADRPT
-#define REG_EEND _REG_EEND
-#define REG_ESIZE _REG_ESIZE
-#define REG_ERPAREN _REG_ERPAREN
-
-/* struct re_pattern_buffer normally uses member names like `buffer'
- that POSIX does not allow. In POSIX mode these members have names
- with leading `re_' (e.g., `re_buffer'). */
-#ifdef __USE_GNU_REGEX
-# define _REG_RE_NAME(id) id
-# define _REG_RM_NAME(id) id
-#else
-# define _REG_RE_NAME(id) re_##id
-# define _REG_RM_NAME(id) rm_##id
-#endif
-
-/* The user can specify the type of the re_translate member by
- defining the macro RE_TRANSLATE_TYPE, which defaults to unsigned
- char *. This pollutes the POSIX name space, so in POSIX mode just
- use unsigned char *. */
-#ifdef __USE_GNU_REGEX
-# ifndef RE_TRANSLATE_TYPE
-# define RE_TRANSLATE_TYPE unsigned char *
-# endif
-# define REG_TRANSLATE_TYPE RE_TRANSLATE_TYPE
-#else
-# define REG_TRANSLATE_TYPE unsigned char *
-#endif
-
-/* This data structure represents a compiled pattern. Before calling
- the pattern compiler, the fields `buffer', `allocated', `fastmap',
- `translate', and `no_sub' can be set. After the pattern has been
- compiled, the `re_nsub' field is available. All other fields are
- private to the regex routines. */
-
-struct re_pattern_buffer
-{
- /* Space that holds the compiled pattern. It is declared as
- `unsigned char *' because its elements are sometimes used as
- array indexes. */
- unsigned char *_REG_RE_NAME (buffer);
-
- /* Number of bytes to which `buffer' points. */
- __re_long_size_t _REG_RE_NAME (allocated);
-
- /* Number of bytes actually used in `buffer'. */
- __re_long_size_t _REG_RE_NAME (used);
-
- /* Syntax setting with which the pattern was compiled. */
- reg_syntax_t _REG_RE_NAME (syntax);
-
- /* Pointer to a fastmap, if any, otherwise zero. re_search uses the
- fastmap, if there is one, to skip over impossible starting points
- for matches. */
- char *_REG_RE_NAME (fastmap);
-
- /* Either a translate table to apply to all characters before
- comparing them, or zero for no translation. The translation is
- applied to a pattern when it is compiled and to a string when it
- is matched. */
- REG_TRANSLATE_TYPE _REG_RE_NAME (translate);
-
- /* Number of subexpressions found by the compiler. */
- size_t re_nsub;
-
- /* Zero if this pattern cannot match the empty string, one else.
- Well, in truth it's used only in `re_search_2', to see whether or
- not we should use the fastmap, so we don't set this absolutely
- perfectly; see `re_compile_fastmap' (the `duplicate' case). */
- unsigned int _REG_RE_NAME (can_be_null) : 1;
-
- /* If REGS_UNALLOCATED, allocate space in the `regs' structure
- for `max (RE_NREGS, re_nsub + 1)' groups.
- If REGS_REALLOCATE, reallocate space if necessary.
- If REGS_FIXED, use what's there. */
-#ifdef __USE_GNU_REGEX
-# define REGS_UNALLOCATED 0
-# define REGS_REALLOCATE 1
-# define REGS_FIXED 2
-#endif
- unsigned int _REG_RE_NAME (regs_allocated) : 2;
-
- /* Set to zero when `re_compile_pattern' compiles a pattern; set to
- one by `re_compile_fastmap' if it updates the fastmap. */
- unsigned int _REG_RE_NAME (fastmap_accurate) : 1;
-
- /* If set, `re_match_2' does not return information about
- subexpressions. */
- unsigned int _REG_RE_NAME (no_sub) : 1;
-
- /* If set, a beginning-of-line anchor doesn't match at the beginning
- of the string. */
- unsigned int _REG_RE_NAME (not_bol) : 1;
-
- /* Similarly for an end-of-line anchor. */
- unsigned int _REG_RE_NAME (not_eol) : 1;
-
- /* If true, an anchor at a newline matches. */
- unsigned int _REG_RE_NAME (newline_anchor) : 1;
-
-/* [[[end pattern_buffer]]] */
-};
-
-typedef struct re_pattern_buffer regex_t;
-
-/* This is the structure we store register match data in. See
- regex.texinfo for a full description of what registers match. */
-struct re_registers
-{
- __re_size_t _REG_RM_NAME (num_regs);
- regoff_t *_REG_RM_NAME (start);
- regoff_t *_REG_RM_NAME (end);
-};
-
-
-/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
- `re_match_2' returns information about at least this many registers
- the first time a `regs' structure is passed. */
-#if !defined RE_NREGS && defined __USE_GNU_REGEX
-# define RE_NREGS 30
-#endif
-
-
-/* POSIX specification for registers. Aside from the different names than
- `re_registers', POSIX uses an array of structures, instead of a
- structure of arrays. */
-typedef struct
-{
- regoff_t rm_so; /* Byte offset from string's start to substring's start. */
- regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
-} regmatch_t;
-
-/* Declarations for routines. */
-
-/* Sets the current default syntax to SYNTAX, and return the old syntax.
- You can also simply assign to the `re_syntax_options' variable. */
-extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
-
-/* Compile the regular expression PATTERN, with length LENGTH
- and syntax given by the global `re_syntax_options', into the buffer
- BUFFER. Return NULL if successful, and an error string if not. */
-extern const char *re_compile_pattern (const char *__pattern, size_t __length,
- struct re_pattern_buffer *__buffer);
-
-
-/* Compile a fastmap for the compiled pattern in BUFFER; used to
- accelerate searches. Return 0 if successful and -2 if was an
- internal error. */
-extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
-
-
-/* Search in the string STRING (with length LENGTH) for the pattern
- compiled into BUFFER. Start searching at position START, for RANGE
- characters. Return the starting position of the match, -1 for no
- match, or -2 for an internal error. Also return register
- information in REGS (if REGS and BUFFER->no_sub are nonzero). */
-extern regoff_t re_search (struct re_pattern_buffer *__buffer,
- const char *__string, __re_idx_t __length,
- __re_idx_t __start, regoff_t __range,
- struct re_registers *__regs);
-
-
-/* Like `re_search', but search in the concatenation of STRING1 and
- STRING2. Also, stop searching at index START + STOP. */
-extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
- const char *__string1, __re_idx_t __length1,
- const char *__string2, __re_idx_t __length2,
- __re_idx_t __start, regoff_t __range,
- struct re_registers *__regs,
- __re_idx_t __stop);
-
-
-/* Like `re_search', but return how many characters in STRING the regexp
- in BUFFER matched, starting at position START. */
-extern regoff_t re_match (struct re_pattern_buffer *__buffer,
- const char *__string, __re_idx_t __length,
- __re_idx_t __start, struct re_registers *__regs);
-
-
-/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
-extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
- const char *__string1, __re_idx_t __length1,
- const char *__string2, __re_idx_t __length2,
- __re_idx_t __start, struct re_registers *__regs,
- __re_idx_t __stop);
-
-
-/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
- ENDS. Subsequent matches using BUFFER and REGS will use this memory
- for recording register information. STARTS and ENDS must be
- allocated with malloc, and must each be at least `NUM_REGS * sizeof
- (regoff_t)' bytes long.
-
- If NUM_REGS == 0, then subsequent matches should allocate their own
- register data.
-
- Unless this function is called, the first search or match using
- BUFFER will allocate its own register data, without freeing the old
- data. */
-extern void re_set_registers (struct re_pattern_buffer *__buffer,
- struct re_registers *__regs,
- __re_size_t __num_regs,
- regoff_t *__starts, regoff_t *__ends);
-
-#if defined _REGEX_RE_COMP || defined _LIBC
-# ifndef _CRAY
-/* 4.2 bsd compatibility. */
-extern char *re_comp (const char *);
-extern int re_exec (const char *);
-# endif
-#endif
-
-/* GCC 2.95 and later have "__restrict"; C99 compilers have
- "restrict", and "configure" may have defined "restrict".
- Other compilers use __restrict, __restrict__, and _Restrict, and
- 'configure' might #define 'restrict' to those words, so pick a
- different name. */
-#ifndef _Restrict_
-# if 199901L <= __STDC_VERSION__
-# define _Restrict_ restrict
-# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
-# define _Restrict_ __restrict
-# else
-# define _Restrict_
-# endif
-#endif
-/* gcc 3.1 and up support the [restrict] syntax. Don't trust
- sys/cdefs.h's definition of __restrict_arr, though, as it
- mishandles gcc -ansi -pedantic. */
-#ifndef _Restrict_arr_
-# if ((199901L <= __STDC_VERSION__ \
- || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \
- && !__STRICT_ANSI__)) \
- && !defined __GNUG__)
-# define _Restrict_arr_ _Restrict_
-# else
-# define _Restrict_arr_
-# endif
-#endif
-
-/* POSIX compatibility. */
-extern int regcomp (regex_t *_Restrict_ __preg,
- const char *_Restrict_ __pattern,
- int __cflags);
-
-extern int regexec (const regex_t *_Restrict_ __preg,
- const char *_Restrict_ __string, size_t __nmatch,
- regmatch_t __pmatch[_Restrict_arr_],
- int __eflags);
-
-extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
- char *_Restrict_ __errbuf, size_t __errbuf_size);
-
-extern void regfree (regex_t *__preg);
-
-
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
-#endif /* regex.h */
diff --git a/src/gnu/regex_internal.h b/src/gnu/regex_internal.h
deleted file mode 100644
index dc94e2c..0000000
--- a/src/gnu/regex_internal.h
+++ /dev/null
@@ -1,873 +0,0 @@
-/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
- Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#ifndef _REGEX_INTERNAL_H
-#define _REGEX_INTERNAL_H 1
-
-#include <assert.h>
-#include <ctype.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <langinfo.h>
-#ifndef _LIBC
-# include "localcharset.h"
-#endif
-#if defined HAVE_LOCALE_H || defined _LIBC
-# include <locale.h>
-#endif
-
-#include <wchar.h>
-#include <wctype.h>
-#include <stdint.h>
-#if defined _LIBC
-# include <bits/libc-lock.h>
-#else
-# define __libc_lock_init(NAME) do { } while (0)
-# define __libc_lock_lock(NAME) do { } while (0)
-# define __libc_lock_unlock(NAME) do { } while (0)
-#endif
-
-/* In case that the system doesn't have isblank(). */
-#if !defined _LIBC && ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK))
-# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
-#endif
-
-#ifdef _LIBC
-# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
-# define _RE_DEFINE_LOCALE_FUNCTIONS 1
-# include <locale/localeinfo.h>
-# include <locale/elem-hash.h>
-# include <locale/coll-lookup.h>
-# endif
-#endif
-
-/* This is for other GNU distributions with internationalized messages. */
-#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
-# include <libintl.h>
-# ifdef _LIBC
-# undef gettext
-# define gettext(msgid) \
- INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
-# endif
-#else
-# define gettext(msgid) (msgid)
-#endif
-
-#ifndef gettext_noop
-/* This define is so xgettext can find the internationalizable
- strings. */
-# define gettext_noop(String) String
-#endif
-
-/* For loser systems without the definition. */
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
-#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
-# define RE_ENABLE_I18N
-#endif
-
-#if __GNUC__ >= 3
-# define BE(expr, val) __builtin_expect (expr, val)
-#else
-# define BE(expr, val) (expr)
-# ifdef _LIBC
-# define inline
-# endif
-#endif
-
-/* Number of ASCII characters. */
-#define ASCII_CHARS 0x80
-
-/* Number of single byte characters. */
-#define SBC_MAX (UCHAR_MAX + 1)
-
-#define COLL_ELEM_LEN_MAX 8
-
-/* The character which represents newline. */
-#define NEWLINE_CHAR '\n'
-#define WIDE_NEWLINE_CHAR L'\n'
-
-/* Rename to standard API for using out of glibc. */
-#ifndef _LIBC
-# define __wctype wctype
-# define __iswctype iswctype
-# define __btowc btowc
-# define __wcrtomb wcrtomb
-# define __mbrtowc mbrtowc
-# define __regfree regfree
-# define attribute_hidden
-#endif /* not _LIBC */
-
-#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-# define __attribute(arg) __attribute__ (arg)
-#else
-# define __attribute(arg)
-#endif
-
-typedef __re_idx_t Idx;
-
-/* Special return value for failure to match. */
-#define REG_MISSING ((Idx) -1)
-
-/* Special return value for internal error. */
-#define REG_ERROR ((Idx) -2)
-
-/* Test whether N is a valid index, and is not one of the above. */
-#ifdef _REGEX_LARGE_OFFSETS
-# define REG_VALID_INDEX(n) ((Idx) (n) < REG_ERROR)
-#else
-# define REG_VALID_INDEX(n) (0 <= (n))
-#endif
-
-/* Test whether N is a valid nonzero index. */
-#ifdef _REGEX_LARGE_OFFSETS
-# define REG_VALID_NONZERO_INDEX(n) ((Idx) ((n) - 1) < (Idx) (REG_ERROR - 1))
-#else
-# define REG_VALID_NONZERO_INDEX(n) (0 < (n))
-#endif
-
-/* A hash value, suitable for computing hash tables. */
-typedef __re_size_t re_hashval_t;
-
-/* An integer used to represent a set of bits. It must be unsigned,
- and must be at least as wide as unsigned int. */
-typedef unsigned long int bitset_word_t;
-/* All bits set in a bitset_word_t. */
-#define BITSET_WORD_MAX ULONG_MAX
-
-/* Number of bits in a bitset_word_t. For portability to hosts with
- padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)';
- instead, deduce it directly from BITSET_WORD_MAX. Avoid
- greater-than-32-bit integers and unconditional shifts by more than
- 31 bits, as they're not portable. */
-#if BITSET_WORD_MAX == 0xffffffffUL
-# define BITSET_WORD_BITS 32
-#elif BITSET_WORD_MAX >> 31 >> 4 == 1
-# define BITSET_WORD_BITS 36
-#elif BITSET_WORD_MAX >> 31 >> 16 == 1
-# define BITSET_WORD_BITS 48
-#elif BITSET_WORD_MAX >> 31 >> 28 == 1
-# define BITSET_WORD_BITS 60
-#elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1
-# define BITSET_WORD_BITS 64
-#elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1
-# define BITSET_WORD_BITS 72
-#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1
-# define BITSET_WORD_BITS 128
-#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1
-# define BITSET_WORD_BITS 256
-#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1
-# define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */
-# if BITSET_WORD_BITS <= SBC_MAX
-# error "Invalid SBC_MAX"
-# endif
-#else
-# error "Add case for new bitset_word_t size"
-#endif
-
-/* Number of bitset_word_t values in a bitset_t. */
-#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
-
-typedef bitset_word_t bitset_t[BITSET_WORDS];
-typedef bitset_word_t *re_bitset_ptr_t;
-typedef const bitset_word_t *re_const_bitset_ptr_t;
-
-#define PREV_WORD_CONSTRAINT 0x0001
-#define PREV_NOTWORD_CONSTRAINT 0x0002
-#define NEXT_WORD_CONSTRAINT 0x0004
-#define NEXT_NOTWORD_CONSTRAINT 0x0008
-#define PREV_NEWLINE_CONSTRAINT 0x0010
-#define NEXT_NEWLINE_CONSTRAINT 0x0020
-#define PREV_BEGBUF_CONSTRAINT 0x0040
-#define NEXT_ENDBUF_CONSTRAINT 0x0080
-#define WORD_DELIM_CONSTRAINT 0x0100
-#define NOT_WORD_DELIM_CONSTRAINT 0x0200
-
-typedef enum
-{
- INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
- WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
- WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
- INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
- LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
- LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
- BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
- BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
- WORD_DELIM = WORD_DELIM_CONSTRAINT,
- NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT
-} re_context_type;
-
-typedef struct
-{
- Idx alloc;
- Idx nelem;
- Idx *elems;
-} re_node_set;
-
-typedef enum
-{
- NON_TYPE = 0,
-
- /* Node type, These are used by token, node, tree. */
- CHARACTER = 1,
- END_OF_RE = 2,
- SIMPLE_BRACKET = 3,
- OP_BACK_REF = 4,
- OP_PERIOD = 5,
-#ifdef RE_ENABLE_I18N
- COMPLEX_BRACKET = 6,
- OP_UTF8_PERIOD = 7,
-#endif /* RE_ENABLE_I18N */
-
- /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
- when the debugger shows values of this enum type. */
-#define EPSILON_BIT 8
- OP_OPEN_SUBEXP = EPSILON_BIT | 0,
- OP_CLOSE_SUBEXP = EPSILON_BIT | 1,
- OP_ALT = EPSILON_BIT | 2,
- OP_DUP_ASTERISK = EPSILON_BIT | 3,
- ANCHOR = EPSILON_BIT | 4,
-
- /* Tree type, these are used only by tree. */
- CONCAT = 16,
- SUBEXP = 17,
-
- /* Token type, these are used only by token. */
- OP_DUP_PLUS = 18,
- OP_DUP_QUESTION,
- OP_OPEN_BRACKET,
- OP_CLOSE_BRACKET,
- OP_CHARSET_RANGE,
- OP_OPEN_DUP_NUM,
- OP_CLOSE_DUP_NUM,
- OP_NON_MATCH_LIST,
- OP_OPEN_COLL_ELEM,
- OP_CLOSE_COLL_ELEM,
- OP_OPEN_EQUIV_CLASS,
- OP_CLOSE_EQUIV_CLASS,
- OP_OPEN_CHAR_CLASS,
- OP_CLOSE_CHAR_CLASS,
- OP_WORD,
- OP_NOTWORD,
- OP_SPACE,
- OP_NOTSPACE,
- BACK_SLASH
-
-} re_token_type_t;
-
-#ifdef RE_ENABLE_I18N
-typedef struct
-{
- /* Multibyte characters. */
- wchar_t *mbchars;
-
- /* Collating symbols. */
-# ifdef _LIBC
- int32_t *coll_syms;
-# endif
-
- /* Equivalence classes. */
-# ifdef _LIBC
- int32_t *equiv_classes;
-# endif
-
- /* Range expressions. */
-# ifdef _LIBC
- uint32_t *range_starts;
- uint32_t *range_ends;
-# else /* not _LIBC */
- wchar_t *range_starts;
- wchar_t *range_ends;
-# endif /* not _LIBC */
-
- /* Character classes. */
- wctype_t *char_classes;
-
- /* If this character set is the non-matching list. */
- unsigned int non_match : 1;
-
- /* # of multibyte characters. */
- Idx nmbchars;
-
- /* # of collating symbols. */
- Idx ncoll_syms;
-
- /* # of equivalence classes. */
- Idx nequiv_classes;
-
- /* # of range expressions. */
- Idx nranges;
-
- /* # of character classes. */
- Idx nchar_classes;
-} re_charset_t;
-#endif /* RE_ENABLE_I18N */
-
-typedef struct
-{
- union
- {
- unsigned char c; /* for CHARACTER */
- re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
-#ifdef RE_ENABLE_I18N
- re_charset_t *mbcset; /* for COMPLEX_BRACKET */
-#endif /* RE_ENABLE_I18N */
- Idx idx; /* for BACK_REF */
- re_context_type ctx_type; /* for ANCHOR */
- } opr;
-#if __GNUC__ >= 2 && !__STRICT_ANSI__
- re_token_type_t type : 8;
-#else
- re_token_type_t type;
-#endif
- unsigned int constraint : 10; /* context constraint */
- unsigned int duplicated : 1;
- unsigned int opt_subexp : 1;
-#ifdef RE_ENABLE_I18N
- unsigned int accept_mb : 1;
- /* These 2 bits can be moved into the union if needed (e.g. if running out
- of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
- unsigned int mb_partial : 1;
-#endif
- unsigned int word_char : 1;
-} re_token_t;
-
-#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT)
-
-struct re_string_t
-{
- /* Indicate the raw buffer which is the original string passed as an
- argument of regexec(), re_search(), etc.. */
- const unsigned char *raw_mbs;
- /* Store the multibyte string. In case of "case insensitive mode" like
- REG_ICASE, upper cases of the string are stored, otherwise MBS points
- the same address that RAW_MBS points. */
- unsigned char *mbs;
-#ifdef RE_ENABLE_I18N
- /* Store the wide character string which is corresponding to MBS. */
- wint_t *wcs;
- Idx *offsets;
- mbstate_t cur_state;
-#endif
- /* Index in RAW_MBS. Each character mbs[i] corresponds to
- raw_mbs[raw_mbs_idx + i]. */
- Idx raw_mbs_idx;
- /* The length of the valid characters in the buffers. */
- Idx valid_len;
- /* The corresponding number of bytes in raw_mbs array. */
- Idx valid_raw_len;
- /* The length of the buffers MBS and WCS. */
- Idx bufs_len;
- /* The index in MBS, which is updated by re_string_fetch_byte. */
- Idx cur_idx;
- /* length of RAW_MBS array. */
- Idx raw_len;
- /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */
- Idx len;
- /* End of the buffer may be shorter than its length in the cases such
- as re_match_2, re_search_2. Then, we use STOP for end of the buffer
- instead of LEN. */
- Idx raw_stop;
- /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */
- Idx stop;
-
- /* The context of mbs[0]. We store the context independently, since
- the context of mbs[0] may be different from raw_mbs[0], which is
- the beginning of the input string. */
- unsigned int tip_context;
- /* The translation passed as a part of an argument of re_compile_pattern. */
- RE_TRANSLATE_TYPE trans;
- /* Copy of re_dfa_t's word_char. */
- re_const_bitset_ptr_t word_char;
- /* true if REG_ICASE. */
- unsigned char icase;
- unsigned char is_utf8;
- unsigned char map_notascii;
- unsigned char mbs_allocated;
- unsigned char offsets_needed;
- unsigned char newline_anchor;
- unsigned char word_ops_used;
- int mb_cur_max;
-};
-typedef struct re_string_t re_string_t;
-
-
-struct re_dfa_t;
-typedef struct re_dfa_t re_dfa_t;
-
-#ifndef _LIBC
-# if defined __i386__ && !defined __EMX__
-# define internal_function __attribute ((regparm (3), stdcall))
-# else
-# define internal_function
-# endif
-#endif
-
-static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
- Idx new_buf_len)
- internal_function;
-#ifdef RE_ENABLE_I18N
-static void build_wcs_buffer (re_string_t *pstr) internal_function;
-static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr)
- internal_function;
-#endif /* RE_ENABLE_I18N */
-static void build_upper_buffer (re_string_t *pstr) internal_function;
-static void re_string_translate_buffer (re_string_t *pstr) internal_function;
-static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
- int eflags)
- internal_function __attribute ((pure));
-#define re_string_peek_byte(pstr, offset) \
- ((pstr)->mbs[(pstr)->cur_idx + offset])
-#define re_string_fetch_byte(pstr) \
- ((pstr)->mbs[(pstr)->cur_idx++])
-#define re_string_first_byte(pstr, idx) \
- ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF)
-#define re_string_is_single_byte_char(pstr, idx) \
- ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \
- || (pstr)->wcs[(idx) + 1] != WEOF))
-#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx)
-#define re_string_cur_idx(pstr) ((pstr)->cur_idx)
-#define re_string_get_buffer(pstr) ((pstr)->mbs)
-#define re_string_length(pstr) ((pstr)->len)
-#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx])
-#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
-#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
-
-#include <alloca.h>
-
-#ifndef _LIBC
-# if HAVE_ALLOCA
-/* The OS usually guarantees only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- allocate anything larger than 4096 bytes. Also care for the possibility
- of a few compiler-allocated temporary stack slots. */
-# define __libc_use_alloca(n) ((n) < 4032)
-# else
-/* alloca is implemented with malloc, so just use malloc. */
-# define __libc_use_alloca(n) 0
-# undef alloca
-# define alloca(n) malloc (n)
-# endif
-#endif
-
-#ifndef MAX
-# define MAX(a,b) ((a) < (b) ? (b) : (a))
-#endif
-
-#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
-#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
-#define re_free(p) free (p)
-
-struct bin_tree_t
-{
- struct bin_tree_t *parent;
- struct bin_tree_t *left;
- struct bin_tree_t *right;
- struct bin_tree_t *first;
- struct bin_tree_t *next;
-
- re_token_t token;
-
- /* `node_idx' is the index in dfa->nodes, if `type' == 0.
- Otherwise `type' indicate the type of this node. */
- Idx node_idx;
-};
-typedef struct bin_tree_t bin_tree_t;
-
-#define BIN_TREE_STORAGE_SIZE \
- ((1024 - sizeof (void *)) / sizeof (bin_tree_t))
-
-struct bin_tree_storage_t
-{
- struct bin_tree_storage_t *next;
- bin_tree_t data[BIN_TREE_STORAGE_SIZE];
-};
-typedef struct bin_tree_storage_t bin_tree_storage_t;
-
-#define CONTEXT_WORD 1
-#define CONTEXT_NEWLINE (CONTEXT_WORD << 1)
-#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1)
-#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1)
-
-#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD)
-#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE)
-#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF)
-#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF)
-#define IS_ORDINARY_CONTEXT(c) ((c) == 0)
-
-#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
-#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
-#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_')
-#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
-
-#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
- ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
- || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
- || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\
- || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context)))
-
-#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \
- ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
- || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
- || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \
- || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context)))
-
-struct re_dfastate_t
-{
- re_hashval_t hash;
- re_node_set nodes;
- re_node_set non_eps_nodes;
- re_node_set inveclosure;
- re_node_set *entrance_nodes;
- struct re_dfastate_t **trtable, **word_trtable;
- unsigned int context : 4;
- unsigned int halt : 1;
- /* If this state can accept `multi byte'.
- Note that we refer to multibyte characters, and multi character
- collating elements as `multi byte'. */
- unsigned int accept_mb : 1;
- /* If this state has backreference node(s). */
- unsigned int has_backref : 1;
- unsigned int has_constraint : 1;
-};
-typedef struct re_dfastate_t re_dfastate_t;
-
-struct re_state_table_entry
-{
- Idx num;
- Idx alloc;
- re_dfastate_t **array;
-};
-
-/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */
-
-typedef struct
-{
- Idx next_idx;
- Idx alloc;
- re_dfastate_t **array;
-} state_array_t;
-
-/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */
-
-typedef struct
-{
- Idx node;
- Idx str_idx; /* The position NODE match at. */
- state_array_t path;
-} re_sub_match_last_t;
-
-/* Store information about the node NODE whose type is OP_OPEN_SUBEXP.
- And information about the node, whose type is OP_CLOSE_SUBEXP,
- corresponding to NODE is stored in LASTS. */
-
-typedef struct
-{
- Idx str_idx;
- Idx node;
- state_array_t *path;
- Idx alasts; /* Allocation size of LASTS. */
- Idx nlasts; /* The number of LASTS. */
- re_sub_match_last_t **lasts;
-} re_sub_match_top_t;
-
-struct re_backref_cache_entry
-{
- Idx node;
- Idx str_idx;
- Idx subexp_from;
- Idx subexp_to;
- char more;
- char unused;
- unsigned short int eps_reachable_subexps_map;
-};
-
-typedef struct
-{
- /* The string object corresponding to the input string. */
- re_string_t input;
-#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
- const re_dfa_t *const dfa;
-#else
- const re_dfa_t *dfa;
-#endif
- /* EFLAGS of the argument of regexec. */
- int eflags;
- /* Where the matching ends. */
- Idx match_last;
- Idx last_node;
- /* The state log used by the matcher. */
- re_dfastate_t **state_log;
- Idx state_log_top;
- /* Back reference cache. */
- Idx nbkref_ents;
- Idx abkref_ents;
- struct re_backref_cache_entry *bkref_ents;
- int max_mb_elem_len;
- Idx nsub_tops;
- Idx asub_tops;
- re_sub_match_top_t **sub_tops;
-} re_match_context_t;
-
-typedef struct
-{
- re_dfastate_t **sifted_states;
- re_dfastate_t **limited_states;
- Idx last_node;
- Idx last_str_idx;
- re_node_set limits;
-} re_sift_context_t;
-
-struct re_fail_stack_ent_t
-{
- Idx idx;
- Idx node;
- regmatch_t *regs;
- re_node_set eps_via_nodes;
-};
-
-struct re_fail_stack_t
-{
- Idx num;
- Idx alloc;
- struct re_fail_stack_ent_t *stack;
-};
-
-struct re_dfa_t
-{
- re_token_t *nodes;
- size_t nodes_alloc;
- size_t nodes_len;
- Idx *nexts;
- Idx *org_indices;
- re_node_set *edests;
- re_node_set *eclosures;
- re_node_set *inveclosures;
- struct re_state_table_entry *state_table;
- re_dfastate_t *init_state;
- re_dfastate_t *init_state_word;
- re_dfastate_t *init_state_nl;
- re_dfastate_t *init_state_begbuf;
- bin_tree_t *str_tree;
- bin_tree_storage_t *str_tree_storage;
- re_bitset_ptr_t sb_char;
- int str_tree_storage_idx;
-
- /* number of subexpressions `re_nsub' is in regex_t. */
- re_hashval_t state_hash_mask;
- Idx init_node;
- Idx nbackref; /* The number of backreference in this dfa. */
-
- /* Bitmap expressing which backreference is used. */
- bitset_word_t used_bkref_map;
- bitset_word_t completed_bkref_map;
-
- unsigned int has_plural_match : 1;
- /* If this dfa has "multibyte node", which is a backreference or
- a node which can accept multibyte character or multi character
- collating element. */
- unsigned int has_mb_node : 1;
- unsigned int is_utf8 : 1;
- unsigned int map_notascii : 1;
- unsigned int word_ops_used : 1;
- int mb_cur_max;
- bitset_t word_char;
- reg_syntax_t syntax;
- Idx *subexp_map;
-#ifdef DEBUG
- char* re_str;
-#endif
-#ifdef _LIBC
- __libc_lock_define (, lock)
-#endif
-};
-
-#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
-#define re_node_set_remove(set,id) \
- (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1))
-#define re_node_set_empty(p) ((p)->nelem = 0)
-#define re_node_set_free(set) re_free ((set)->elems)
-
-
-typedef enum
-{
- SB_CHAR,
- MB_CHAR,
- EQUIV_CLASS,
- COLL_SYM,
- CHAR_CLASS
-} bracket_elem_type;
-
-typedef struct
-{
- bracket_elem_type type;
- union
- {
- unsigned char ch;
- unsigned char *name;
- wchar_t wch;
- } opr;
-} bracket_elem_t;
-
-
-/* Inline functions for bitset_t operation. */
-
-static inline void
-bitset_set (bitset_t set, Idx i)
-{
- set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS;
-}
-
-static inline void
-bitset_clear (bitset_t set, Idx i)
-{
- set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS);
-}
-
-static inline bool
-bitset_contain (const bitset_t set, Idx i)
-{
- return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1;
-}
-
-static inline void
-bitset_empty (bitset_t set)
-{
- memset (set, '\0', sizeof (bitset_t));
-}
-
-static inline void
-bitset_set_all (bitset_t set)
-{
- memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS));
- if (SBC_MAX % BITSET_WORD_BITS != 0)
- set[BITSET_WORDS - 1] =
- ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1;
-}
-
-static inline void
-bitset_copy (bitset_t dest, const bitset_t src)
-{
- memcpy (dest, src, sizeof (bitset_t));
-}
-
-static inline void
-bitset_not (bitset_t set)
-{
- int bitset_i;
- for (bitset_i = 0; bitset_i < SBC_MAX / BITSET_WORD_BITS; ++bitset_i)
- set[bitset_i] = ~set[bitset_i];
- if (SBC_MAX % BITSET_WORD_BITS != 0)
- set[BITSET_WORDS - 1] =
- ((((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1)
- & ~set[BITSET_WORDS - 1]);
-}
-
-static inline void
-bitset_merge (bitset_t dest, const bitset_t src)
-{
- int bitset_i;
- for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
- dest[bitset_i] |= src[bitset_i];
-}
-
-static inline void
-bitset_mask (bitset_t dest, const bitset_t src)
-{
- int bitset_i;
- for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
- dest[bitset_i] &= src[bitset_i];
-}
-
-#ifdef RE_ENABLE_I18N
-/* Inline functions for re_string. */
-static inline int
-internal_function __attribute ((pure))
-re_string_char_size_at (const re_string_t *pstr, Idx idx)
-{
- int byte_idx;
- if (pstr->mb_cur_max == 1)
- return 1;
- for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx)
- if (pstr->wcs[idx + byte_idx] != WEOF)
- break;
- return byte_idx;
-}
-
-static inline wint_t
-internal_function __attribute ((pure))
-re_string_wchar_at (const re_string_t *pstr, Idx idx)
-{
- if (pstr->mb_cur_max == 1)
- return (wint_t) pstr->mbs[idx];
- return (wint_t) pstr->wcs[idx];
-}
-
-static int
-internal_function __attribute ((pure))
-re_string_elem_size_at (const re_string_t *pstr, Idx idx)
-{
-# ifdef _LIBC
- const unsigned char *p, *extra;
- const int32_t *table, *indirect;
- int32_t tmp;
-# include <locale/weight.h>
- uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
-
- if (nrules != 0)
- {
- table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
- extra = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
- indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
- _NL_COLLATE_INDIRECTMB);
- p = pstr->mbs + idx;
- tmp = findidx (&p);
- return p - pstr->mbs - idx;
- }
- else
-# endif /* _LIBC */
- return 1;
-}
-#endif /* RE_ENABLE_I18N */
-
-#ifndef __GNUC_PREREQ
-# if defined __GNUC__ && defined __GNUC_MINOR__
-# define __GNUC_PREREQ(maj, min) \
- ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-# else
-# define __GNUC_PREREQ(maj, min) 0
-# endif
-#endif
-
-#if __GNUC_PREREQ (3,4)
-# undef __attribute_warn_unused_result__
-# define __attribute_warn_unused_result__ \
- __attribute__ ((__warn_unused_result__))
-#else
-# define __attribute_warn_unused_result__ /* empty */
-#endif
-
-#endif /* _REGEX_INTERNAL_H */
diff --git a/test/emacs_sets.lua b/test/emacs_sets.lua
index fb2b024..7046752 100644
--- a/test/emacs_sets.lua
+++ b/test/emacs_sets.lua
@@ -1,8 +1,5 @@
-- See Copyright Notice in the file LICENSE
--- This file should contain only test sets that behave identically
--- when being run with pcre or posix regex libraries.
-
local luatest = require "luatest"
local N = luatest.NT
diff --git a/test/gnu_sets.lua b/test/gnu_sets.lua
index 519705a..29dd817 100644
--- a/test/gnu_sets.lua
+++ b/test/gnu_sets.lua
@@ -1,8 +1,5 @@
-- See Copyright Notice in the file LICENSE
--- This file should contain only test sets that behave identically
--- when being run with pcre or posix regex libraries.
-
local luatest = require "luatest"
local N = luatest.NT
@@ -39,7 +36,8 @@ return {
{ {"abcd", ".+", 5}, { N } }, -- failing st
{ {"abc", "^abc"}, {"abc" } }, -- anchor
{ {"abc", "^abc", N,N,flg.not_bol}, { N } }, -- anchor + ef
- { {"cabcaab", "ca+b", N,N,flg.reverse}, {"caab" } }, -- reverse search
+ { {"abc", "abc$", N,N,flg.not_eol}, { N } }, -- anchor + ef
+ { {"cabcaab", "ca+b", N,N,flg.backward}, {"caab" } }, -- reverse search
}
end
diff --git a/windows/mingw/Makefile b/windows/mingw/Makefile
index 5b78e95..e7e859e 100644
--- a/windows/mingw/Makefile
+++ b/windows/mingw/Makefile
@@ -6,21 +6,29 @@ build:
make -f rex_pcre.mak
make -f rex_spencer.mak
make -f rex_onig.mak
+ make -f rex_gnu.mak
+ make -f rex_tre.mak
test:
make -f rex_pcre.mak test
make -f rex_spencer.mak test
make -f rex_onig.mak test
+ make -f rex_gnu.mak test
+ make -f rex_tre.mak test
install:
make -f rex_pcre.mak install
make -f rex_spencer.mak install
make -f rex_onig.mak install
+ make -f rex_gnu.mak install
+ make -f rex_tre.mak install
clean:
make -f rex_pcre.mak clean
make -f rex_spencer.mak clean
make -f rex_onig.mak clean
+ make -f rex_gnu.mak clean
+ make -f rex_tre.mak clean
.PHONY: all build test install clean
diff --git a/windows/mingw/_mingw.mak b/windows/mingw/_mingw.mak
index 389988c..8e2d532 100644
--- a/windows/mingw/_mingw.mak
+++ b/windows/mingw/_mingw.mak
@@ -22,7 +22,7 @@ clean:
install: $(BININSTALL)
test:
- cd $(TESTPATH) && lua runtest.lua $(TESTNAME)
+ cd $(TESTPATH) && lua runtest.lua $(TESTNAME) -d$(CURDIR)
$(BIN): $(OBJ) $(DEFFILE)
$(CC) $(DEFFILE) $(OBJ) $(LIBS) -o $@ -shared