From daa6cb6994a70c5d223eb4ffc0bd2e4fc14a2f82 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Sat, 29 Sep 2012 16:22:24 +0100 Subject: [PATCH 01/33] lposix.c: detect REG_STARTEND separately from other REX_POSIX_EXT features REG_STARTEND is implemented in some widely used libc's, e.g. GNU libc, which don't implement the other extensions. --- src/posix/lposix.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/posix/lposix.c b/src/posix/lposix.c index cfaaaf3..61582ab 100644 --- a/src/posix/lposix.c +++ b/src/posix/lposix.c @@ -38,7 +38,7 @@ #endif #define ALG_CFLAGS_DFLT REG_EXTENDED -#ifdef REX_POSIX_EXT +#ifdef REG_STARTEND # define ALG_EFLAGS_DFLT REG_STARTEND #else # define ALG_EFLAGS_DFLT 0 @@ -116,7 +116,7 @@ static int compile_regex (lua_State *L, const TArgComp *argC, TPosix **pud) { return 1; } -#ifdef REX_POSIX_EXT +#ifdef REG_STARTEND static void CheckStartEnd (TArgExec *argE, TPosix *ud) { if (argE->eflags & REG_STARTEND) { ud->match[0].rm_so = argE->startoffset; @@ -132,7 +132,7 @@ static int gmatch_exec (TUserdata *ud, TArgExec *argE) { if (argE->startoffset > 0) argE->eflags |= REG_NOTBOL; -#ifdef REX_POSIX_EXT +#ifdef REG_STARTEND if (argE->eflags & REG_STARTEND) { ALG_SUBBEG(ud,0) = 0; ALG_SUBEND(ud,0) = argE->textlen - argE->startoffset; @@ -144,7 +144,7 @@ static int gmatch_exec (TUserdata *ud, TArgExec *argE) { } static void gmatch_pushsubject (lua_State *L, TArgExec *argE) { -#ifdef REX_POSIX_EXT +#ifdef REG_STARTEND if (argE->eflags & REG_STARTEND) lua_pushlstring (L, argE->text, argE->textlen); else @@ -155,7 +155,7 @@ static void gmatch_pushsubject (lua_State *L, TArgExec *argE) { } static int findmatch_exec (TPosix *ud, TArgExec *argE) { -#ifdef REX_POSIX_EXT +#ifdef REG_STARTEND CheckStartEnd (argE, ud); #else argE->text += argE->startoffset; @@ -164,7 +164,7 @@ static int findmatch_exec (TPosix *ud, TArgExec *argE) { } static int gsub_exec (TPosix *ud, TArgExec *argE, int st) { -#ifdef REX_POSIX_EXT +#ifdef REG_STARTEND if(argE->eflags & REG_STARTEND) { ALG_SUBBEG(ud,0) = 0; ALG_SUBEND(ud,0) = argE->textlen - st; @@ -176,7 +176,7 @@ static int gsub_exec (TPosix *ud, TArgExec *argE, int st) { } static int split_exec (TPosix *ud, TArgExec *argE, int offset) { -#ifdef REX_POSIX_EXT +#ifdef REG_STARTEND if (argE->eflags & REG_STARTEND) { ALG_SUBBEG(ud,0) = 0; ALG_SUBEND(ud,0) = argE->textlen - offset; @@ -213,6 +213,8 @@ static flag_pair posix_flags[] = { "BASIC", REG_BASIC }, { "NOSPEC", REG_NOSPEC }, { "PEND", REG_PEND }, +#endif +#ifdef REG_STARTEND { "STARTEND", REG_STARTEND }, #endif { "EXTENDED", REG_EXTENDED }, From 3d6f22f6c72b9514aa327e2f45d8c232afdd0d76 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Sat, 29 Sep 2012 16:30:28 +0100 Subject: [PATCH 02/33] lposix.c: simplify gmatch_pushsubject slightly --- src/posix/lposix.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/posix/lposix.c b/src/posix/lposix.c index 61582ab..e8ed93e 100644 --- a/src/posix/lposix.c +++ b/src/posix/lposix.c @@ -148,10 +148,8 @@ static void gmatch_pushsubject (lua_State *L, TArgExec *argE) { if (argE->eflags & REG_STARTEND) lua_pushlstring (L, argE->text, argE->textlen); else - lua_pushlstring (L, argE->text, strlen (argE->text)); -#else - lua_pushlstring (L, argE->text, strlen (argE->text)); #endif + lua_pushstring (L, argE->text); } static int findmatch_exec (TPosix *ud, TArgExec *argE) { From bcafc078ff3de4b6fe57a480dacbe33ae41ce84d Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Sat, 29 Sep 2012 16:31:23 +0100 Subject: [PATCH 03/33] lposix.c: improve a comment --- src/posix/lposix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/posix/lposix.c b/src/posix/lposix.c index e8ed93e..513ea31 100644 --- a/src/posix/lposix.c +++ b/src/posix/lposix.c @@ -26,10 +26,11 @@ #define REX_TYPENAME REX_LIBNAME"_regex" -/* Test if regex.h corresponds to the extended POSIX library, i.e. H.Spencer's. +/* Test if regex.h corresponds to the extended POSIX library, i.e. H. Spencer's. This test may not work as intended if regex.h introduced REG_BASIC, etc. via enum rather than #define. If that's the case, add -DREX_POSIX_EXT in the makefile/command line. + The same applies to REG_STARTEND. */ #ifndef REX_POSIX_EXT # if defined(REG_BASIC) && defined(REG_STARTEND) From 414a1d037989d12af148396eadb175b2d6491114 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Sat, 29 Sep 2012 16:34:08 +0100 Subject: [PATCH 04/33] lposix.c: fold CheckStartEnd into its only caller --- src/posix/lposix.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/posix/lposix.c b/src/posix/lposix.c index 513ea31..77fa761 100644 --- a/src/posix/lposix.c +++ b/src/posix/lposix.c @@ -117,18 +117,6 @@ static int compile_regex (lua_State *L, const TArgComp *argC, TPosix **pud) { return 1; } -#ifdef REG_STARTEND -static void CheckStartEnd (TArgExec *argE, TPosix *ud) { - if (argE->eflags & REG_STARTEND) { - ud->match[0].rm_so = argE->startoffset; - ud->match[0].rm_eo = argE->textlen; - argE->startoffset = 0; - } - else - argE->text += argE->startoffset; -} -#endif - static int gmatch_exec (TUserdata *ud, TArgExec *argE) { if (argE->startoffset > 0) argE->eflags |= REG_NOTBOL; @@ -155,10 +143,14 @@ static void gmatch_pushsubject (lua_State *L, TArgExec *argE) { static int findmatch_exec (TPosix *ud, TArgExec *argE) { #ifdef REG_STARTEND - CheckStartEnd (argE, ud); -#else - argE->text += argE->startoffset; + if (argE->eflags & REG_STARTEND) { + ud->match[0].rm_so = argE->startoffset; + ud->match[0].rm_eo = argE->textlen; + argE->startoffset = 0; + } + else #endif + argE->text += argE->startoffset; return regexec (&ud->r, argE->text, ALG_NSUB(ud) + 1, ud->match, argE->eflags); } From b551acf755e894c9db15d17d24754793a5773612 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Sat, 29 Sep 2012 17:43:09 +0100 Subject: [PATCH 05/33] common.mak: don't touch LUA_INIT, and augment, don't replace LUA_PATH --- src/common.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.mak b/src/common.mak index 4c2cf8d..0652758 100644 --- a/src/common.mak +++ b/src/common.mak @@ -23,4 +23,4 @@ clean: rm -f $(OBJ) $(TRG_AR) $(TRG_SO)* check: all - LUA_INIT= LUA_PATH=../../test/?.lua $(LUA) ../../test/runtest.lua -d. $(REGNAME) + LUA_PATH="../../test/?.lua;$(LUA_PATH)" $(LUA) ../../test/runtest.lua -d. $(REGNAME) From 2cdbe1c4460249a5d2d865d4406fc06a64dcd560 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Sat, 29 Sep 2012 17:43:50 +0100 Subject: [PATCH 06/33] Add the ability to use raw memory blocks as subjects. The implementation is in algo.h, in the new check_subject function. Usage is documented in manual.txt. Optional tests have been added, using alien buffers. --- doc/manual.txt | 16 +++++++++++++--- src/algo.h | 38 ++++++++++++++++++++++++++++++++++---- test/luatest.lua | 17 +++++++++++++++++ test/onig_sets.lua | 8 ++++---- test/pcre_sets.lua | 8 ++++---- test/runtest.lua | 15 +++++++++++++++ 6 files changed, 87 insertions(+), 15 deletions(-) diff --git a/doc/manual.txt b/doc/manual.txt index 6af4d5f..72790ba 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -38,9 +38,19 @@ Notes too. In this case, the cf_ and larg_ arguments are ignored (should be either supplied as nils or omitted). +6. All functions that take a string-type subject accept a table (in Lua >= 5.2) + or userdata that has a ``topointer`` method and ``__len`` metamethod, and + take the subject to be a block of memory starting at the address returned by + ``subject:topointer()`` and of length ``#subject``. This works with buffers + objects from the alien library (https://github.com/mascarenhas/alien). Note + that special attention is needed with POSIX regex libraries that do not + support ``REG_STARTEND``, and hence need NUL-terminated subjects: the NUL is + not included in the string length, so alien buffers must be wrapped to + report a length that excludes the NUL. + .. _cf: -6. The default value for *compilation flags* (*cf*) that Lrexlib uses when +7. The default value for *compilation flags* (*cf*) that Lrexlib uses when the parameter is not supplied or ``nil`` is: * REG_EXTENDED for POSIX and TRE @@ -65,7 +75,7 @@ Notes .. _ef: -7. The default value for *execution flags* (*ef*) that Lrexlib uses when +8. The default value for *execution flags* (*ef*) that Lrexlib uses when the parameter is not supplied or ``nil``, is: * 0 for standard POSIX regex library @@ -75,7 +85,7 @@ Notes .. _larg: -8. The notation *larg...* is used to indicate optional library-specific +9. The notation *larg...* is used to indicate optional library-specific arguments, which are documented in the ``new`` method of each library. ------------------------------------------------------------ diff --git a/src/algo.h b/src/algo.h index a1ea61c..e268a02 100644 --- a/src/algo.h +++ b/src/algo.h @@ -115,6 +115,36 @@ static TUserdata* check_ud (lua_State *L) } +static void check_subject (lua_State *L, int pos, TArgExec *argE) +{ + int stype; + argE->text = lua_tolstring (L, pos, &argE->textlen); + stype = lua_type (L, pos); + if (stype != LUA_TSTRING && stype != LUA_TTABLE && stype != LUA_TUSERDATA) { + luaL_typerror (L, pos, "string, table or userdata"); + } else if (argE->text == NULL) { + int type; + lua_getfield (L, pos, "topointer"); + if (lua_type (L, -1) != LUA_TFUNCTION) + luaL_error (L, "subject has no topointer method"); + lua_pushvalue (L, pos); + lua_call (L, 1, 1); + type = lua_type (L, -1); + if (type != LUA_TLIGHTUSERDATA) + luaL_error (L, "subject's topointer method returned %s (expected lightuserdata)", + lua_typename (L, type)); + argE->text = lua_touserdata (L, -1); + lua_pop (L, 1); + lua_len (L, pos); + type = lua_type (L, -1); + if (type != LUA_TNUMBER) + luaL_error (L, "subject's length is %s (expected number)", + lua_typename (L, type)); + argE->textlen = lua_tointeger (L, -1); + lua_pop (L, 1); + } +} + static void check_pattern (lua_State *L, int pos, TArgComp *argC) { if (lua_isstring (L, pos)) { @@ -134,7 +164,7 @@ static void checkarg_new (lua_State *L, TArgComp *argC) { /* function gsub (s, patt, f, [n], [cf], [ef], [larg...]) */ static void checkarg_gsub (lua_State *L, TArgComp *argC, TArgExec *argE) { - argE->text = luaL_checklstring (L, 1, &argE->textlen); + check_subject (L, 1, argE); check_pattern (L, 2, argC); lua_tostring (L, 3); /* converts number (if any) to string */ argE->reptype = lua_type (L, 3); @@ -154,7 +184,7 @@ static void checkarg_gsub (lua_State *L, TArgComp *argC, TArgExec *argE) { /* function find (s, patt, [st], [cf], [ef], [larg...]) */ /* function match (s, patt, [st], [cf], [ef], [larg...]) */ static void checkarg_find_func (lua_State *L, TArgComp *argC, TArgExec *argE) { - argE->text = luaL_checklstring (L, 1, &argE->textlen); + check_subject (L, 1, argE); check_pattern (L, 2, argC); argE->startoffset = get_startoffset (L, 3, argE->textlen); argC->cflags = ALG_GETCFLAGS (L, 4); @@ -166,7 +196,7 @@ static void checkarg_find_func (lua_State *L, TArgComp *argC, TArgExec *argE) { /* function gmatch (s, patt, [cf], [ef], [larg...]) */ /* function split (s, patt, [cf], [ef], [larg...]) */ static void checkarg_gmatch_split (lua_State *L, TArgComp *argC, TArgExec *argE) { - argE->text = luaL_checklstring (L, 1, &argE->textlen); + check_subject (L, 1, argE); check_pattern (L, 2, argC); argC->cflags = ALG_GETCFLAGS (L, 3); argE->eflags = luaL_optint (L, 4, ALG_EFLAGS_DFLT); @@ -180,7 +210,7 @@ static void checkarg_gmatch_split (lua_State *L, TArgComp *argC, TArgExec *argE) /* method r:match (s, [st], [ef]) */ static void checkarg_find_method (lua_State *L, TArgExec *argE, TUserdata **ud) { *ud = check_ud (L); - argE->text = luaL_checklstring (L, 2, &argE->textlen); + check_subject (L, 2, argE); argE->startoffset = get_startoffset (L, 3, argE->textlen); argE->eflags = luaL_optint (L, 4, ALG_EFLAGS_DFLT); } diff --git a/test/luatest.lua b/test/luatest.lua index 5ea7ba8..3949d90 100644 --- a/test/luatest.lua +++ b/test/luatest.lua @@ -73,6 +73,22 @@ local function test_function (test, func) if t[1] then table.remove (t, 1) res = t + if alien then + local subject = test[1][1] + local buf = alien.buffer (#subject) + if #subject > 0 then + alien.memmove (buf:topointer (), subject, #subject) + end + test[1][1] = buf + local t = packNT (pcall (func, unpackNT (test[1]))) + if t[1] then + table.remove (t, 1) + res = t + else + print "alien test failed" + res = t[2] --> error_message + end + end else res = t[2] --> error_message end @@ -87,6 +103,7 @@ end -- 3) test results table or error_message local function test_method (test, constructor, name) local res1, res2 + local subject = test[2][1] local ok, r = pcall (constructor, unpackNT (test[1])) if ok then local t = packNT (pcall (r[name], r, unpackNT (test[2]))) diff --git a/test/onig_sets.lua b/test/onig_sets.lua index 83555a6..dd226ec 100644 --- a/test/onig_sets.lua +++ b/test/onig_sets.lua @@ -14,14 +14,14 @@ end local function set_named_subpatterns (lib, flg) return { Name = "Named Subpatterns", - Func = function (methodname, subj, patt, name1, name2) + Func = function (subj, methodname, patt, name1, name2) local r = lib.new (patt) local _,_,caps = r[methodname] (r, subj) return norm(caps[name1]), norm(caps[name2]) end, - --{} - { {"tfind", "abcd", "(?.)b.(?d)", "dog", "cat"}, {"a","d"} }, - { {"exec", "abcd", "(?.)b.(?d)", "dog", "cat"}, {"a","d"} }, + --{} N.B. subject is always first element + { {"abcd", "tfind", "(?.)b.(?d)", "dog", "cat"}, {"a","d"} }, + { {"abcd", "exec", "(?.)b.(?d)", "dog", "cat"}, {"a","d"} }, } end diff --git a/test/pcre_sets.lua b/test/pcre_sets.lua index 9c19bbe..e2db7a9 100644 --- a/test/pcre_sets.lua +++ b/test/pcre_sets.lua @@ -14,14 +14,14 @@ end local function set_named_subpatterns (lib, flg) return { Name = "Named Subpatterns", - Func = function (methodname, subj, patt, name1, name2) + Func = function (subj, methodname, patt, name1, name2) local r = lib.new (patt) local _,_,caps = r[methodname] (r, subj) return norm(caps[name1]), norm(caps[name2]) end, - --{} - { {"tfind", "abcd", "(?P.)b.(?Pd)", "dog", "cat"}, {"a","d"} }, - { {"exec", "abcd", "(?P.)b.(?Pd)", "dog", "cat"}, {"a","d"} }, + --{} N.B. subject is always first element + { {"abcd", "tfind", "(?P.)b.(?Pd)", "dog", "cat"}, {"a","d"} }, + { {"abcd", "exec", "(?P.)b.(?Pd)", "dog", "cat"}, {"a","d"} }, } end diff --git a/test/runtest.lua b/test/runtest.lua index 3c79970..d0d1435 100644 --- a/test/runtest.lua +++ b/test/runtest.lua @@ -1,5 +1,12 @@ -- See Copyright Notice in the file LICENSE +-- See if we have alien, so we can do tests with buffer subjects +local ok +ok, alien = pcall (require, "alien") +if not ok then + io.stderr:write ("Warning: alien not found, so cannot run tests with buffer subjects\n") +end + do local path = "./?.lua;" if package.path:sub(1, #path) ~= path then @@ -16,6 +23,13 @@ local function test_library (libname, setfile, verbose) local lib = require (libname) local f = require (setfile) local sets = f (libname) + + local realalien = alien + if libname == "rex_posix" and not lib.flags ().STARTEND and alien then + alien = nil + io.stderr:write ("Cannot run posix tests with alien without REG_STARTEND\n") + end + local n = 0 -- number of failures for _, set in ipairs (sets) do if verbose then @@ -33,6 +47,7 @@ local function test_library (libname, setfile, verbose) if verbose then print "" end + alien = realalien return n end From 9aa4c1baae4872950e587b3a950c5f1e03d9e1ea Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Tue, 2 Oct 2012 22:45:40 +0100 Subject: [PATCH 07/33] lonig.c: fix a mismatched type in two results of ?:; closes issue #1 --- src/oniguruma/lonig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oniguruma/lonig.c b/src/oniguruma/lonig.c index d97f922..d622445 100644 --- a/src/oniguruma/lonig.c +++ b/src/oniguruma/lonig.c @@ -46,7 +46,7 @@ static void checkarg_compile (lua_State *L, int pos, TArgComp *argC); lua_pushlstring (L, (text) + ALG_SUBBEG(ud,n), ALG_SUBLEN(ud,n)) #define ALG_PUSHSUB_OR_FALSE(L,ud,text,n) \ - (ALG_SUBVALID(ud,n) ? ALG_PUSHSUB (L,ud,text,n) : lua_pushboolean (L,0)) + (ALG_SUBVALID(ud,n) ? (void) ALG_PUSHSUB (L,ud,text,n) : lua_pushboolean (L,0)) #define ALG_PUSHSTART(L,ud,offs,n) lua_pushinteger(L, (offs) + ALG_SUBBEG(ud,n) + 1) #define ALG_PUSHEND(L,ud,offs,n) lua_pushinteger(L, (offs) + ALG_SUBEND(ud,n)) From a3dd13c7a178a58ecabac18af29a38b71ec2e165 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 14:47:55 +0100 Subject: [PATCH 08/33] defaults.mak: add -fPIC and remove -g from default gcc flags --- src/defaults.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/defaults.mak b/src/defaults.mak index f2a5323..f2b2be9 100644 --- a/src/defaults.mak +++ b/src/defaults.mak @@ -12,6 +12,6 @@ LIB_LUA = #INC_LUA = -I/usr/include/lua5.1 #LIB_LUA = -llua -MYCFLAGS = -W -Wall -g $(INC_LUA) $(INC_PCRE) +MYCFLAGS = -fPIC -W -Wall $(INC_LUA) $(INC_PCRE) AR = ar rcu CC = gcc From 41d9fad85070f354b097b8be9aa34bd588314cdb Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:02:24 +0100 Subject: [PATCH 09/33] Replace build systems with LuaRocks. A single Makefile remains to take care of tests, distribution, release and documentation. As a result, rockspecs are automatically generated for all lrexlib flavours (previously, only POSIX and PCRE were available). --- .gitignore | 1 + Makefile | 25 ++--- NEWS | 12 ++ mkrockspecs.lua | 49 ++++++++ rockspecs.lua | 125 +++++++++++++++++++++ src/common.mak | 26 ----- src/defaults.mak | 17 --- src/gnu/Makefile | 39 ------- src/oniguruma/Makefile | 38 ------- src/pcre/Makefile | 38 ------- src/posix/Makefile | 48 -------- src/tre/Makefile | 43 ------- test/{onig_sets.lua => oniguruma_sets.lua} | 0 test/runtest.lua | 12 +- windows/mingw/Makefile | 26 ----- windows/mingw/_mingw.mak | 64 ----------- windows/mingw/docs.mak | 13 --- windows/mingw/rex_gnu.mak | 18 --- windows/mingw/rex_onig.mak | 19 ---- windows/mingw/rex_pcre.mak | 19 ---- windows/mingw/rex_spencer.mak | 18 --- windows/mingw/rex_tre.mak | 26 ----- 22 files changed, 200 insertions(+), 476 deletions(-) create mode 100644 mkrockspecs.lua create mode 100644 rockspecs.lua delete mode 100644 src/common.mak delete mode 100644 src/defaults.mak delete mode 100644 src/gnu/Makefile delete mode 100644 src/oniguruma/Makefile delete mode 100644 src/pcre/Makefile delete mode 100644 src/posix/Makefile delete mode 100644 src/tre/Makefile rename test/{onig_sets.lua => oniguruma_sets.lua} (100%) delete mode 100644 windows/mingw/Makefile delete mode 100644 windows/mingw/_mingw.mak delete mode 100644 windows/mingw/docs.mak delete mode 100644 windows/mingw/rex_gnu.mak delete mode 100644 windows/mingw/rex_onig.mak delete mode 100644 windows/mingw/rex_pcre.mak delete mode 100644 windows/mingw/rex_spencer.mak delete mode 100644 windows/mingw/rex_tre.mak diff --git a/.gitignore b/.gitignore index 638f997..4dba253 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ ChangeLog *.zip release-notes +/*.rockspec diff --git a/Makefile b/Makefile index c50258a..dab648f 100644 --- a/Makefile +++ b/Makefile @@ -1,33 +1,22 @@ # Makefile for lrexlib -# See src/*/Makefile and src/defaults.mak for user-definable settings - -include src/defaults.mak +# See src/*/Makefile for user-definable settings REGNAMES = gnu pcre posix oniguruma tre PROJECT = lrexlib -VERSION = $(V).$(MINORV) +VERSION = 2.6.0 PROJECT_VERSIONED = $(PROJECT)-$(VERSION) DISTFILE = $(PROJECT_VERSIONED).zip -all: - @for i in $(REGNAMES); do \ - make -C src/$$i; \ - done - @make -C doc - -check: all +check: @for i in $(REGNAMES); do \ - make -C src/$$i check; \ + cd src/$$i && LUA_PATH="../../test/?.lua;$(LUA_PATH)" $(LUA) ../../test/runtest.lua -d. $$i && cd ../..; \ done -clean: - @for i in $(REGNAMES); do \ - make -C src/$$i clean; \ - done - @make -C doc clean +doc: + @make -C doc -dist: all +dist: doc git2cl > ChangeLog cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) diff --git a/NEWS b/NEWS index 94b5d3f..2ab071a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,15 @@ +2012-10-04 Release 2.7.0 + + * Added support for searching raw memory buffers (e.g. made with + alien). + * Fixed possible invalid code generation in C (thanks, Michael + Tautschnig). + * Generate LuaRock rockspecs for all modules. + * Greatly simplify UNIX build system, relying on LuaRocks. + * Allow POSIX REG_STARTEND to be used on any system supporting it. + * Add a test set for POSIX regex engine (thanks, Enrico Tassi). + * Simplify some code. + 2012-04-13 Release 2.6.0 * Added support for Lua 5.2. diff --git a/mkrockspecs.lua b/mkrockspecs.lua new file mode 100644 index 0000000..6a2506c --- /dev/null +++ b/mkrockspecs.lua @@ -0,0 +1,49 @@ +-- Generate the rockspecs + +require "std" + +if select ("#", ...) < 2 then + io.stderr:write "Usage: mkrockspecs VERSION MD5SUM\n" + os.exit () +end + +version = select (1, ...) +md5sum = select (2, ...) + +function format (x, indent) + indent = indent or "" + if type (x) == "table" then + local s = "{\n" + for i, v in pairs (x) do + if type (i) ~= "number" then + s = s..indent..i.." = "..format (v, indent.." ")..",\n" + end + end + for i, v in ipairs (x) do + s = s..indent..format (v, indent.." ")..",\n" + end + return s..indent:sub(1, -3).."}" + elseif type (x) == "string" then + return string.format ("%q", x) + else + return tostring (x) + end +end + +for f, spec in pairs (loadfile ("rockspecs.lua") ()) do + if f ~= "default" then + local specfile = "lrexlib-"..f:lower ().."-"..version.."-1.rockspec" + h = io.open (specfile, "w") + assert (h) + flavour = f -- a global, visible in loadfile + local specs = loadfile ("rockspecs.lua") () -- reload to get current flavour interpolated + local spec = table.merge (specs.default, specs[f]) + local s = "" + for i, v in pairs (spec) do + s = s..i.." = "..format (v, " ").."\n" + end + h:write (s) + h:close () + os.execute ("luarocks lint " .. specfile) + end +end diff --git a/rockspecs.lua b/rockspecs.lua new file mode 100644 index 0000000..8d5c06a --- /dev/null +++ b/rockspecs.lua @@ -0,0 +1,125 @@ +local flavours = {"PCRE", "POSIX", "oniguruma", "TRE", "GNU"} + +-- Rockspec data + +-- Variables to be interpolated: +-- +-- flavour: regex library +-- version +-- md5sum: checksum of distribution tarball + +-- When Lua 5.1 support is dropped, use an env argument with loadfile +-- instead of wrapping in a table +return { + +default = { + package="Lrexlib-"..flavour, + version=version.."-1", + source = { + url = "https://github.com/downloads/rrthomas/lrexlib/lrexlib-"..version..".zip", + md5 = md5sum + }, + description = { + summary = "Regular expression library binding ("..flavour.." flavour).", + detailed = [[ + Lrexlib is a regular expression library for Lua 5.1, which + provides bindings for several regular expression libraries. + This rock provides the ]]..flavour..[[ bindings. + ]], + homepage = "http://github.com/rrthomas/lrexlib", + license = "MIT/X11" + }, + dependencies = { + "lua >= 5.1" + }, +}, + +PCRE = { + external_dependencies = { + PCRE = { + header = "pcre.h", + library = "pcre" + } + }, + build = { + type = "builtin", + modules = { + rex_pcre = { + sources = {"src/common.c", "src/pcre/lpcre.c", "src/pcre/lpcre_f.c"}, + libraries = {"pcre"}, + incdirs = {"$(PCRE_INCDIR)"}, + libdirs = {"$(PCRE_LIBDIR)"} + } + } + } +}, + +POSIX = { + external_dependencies = { + POSIX = { + header = "regex.h", + } + }, + build = { + type = "builtin", + modules = { + rex_posix = {"src/common.c", "src/posix/lposix.c"} + } + } +}, + +oniguruma = { + external_dependencies = { + ONIG = { + header = "oniguruma.h", + library = "onig" + } + }, + build = { + type = "builtin", + modules = { + rex_onig = { + sources = {"src/common.c", "src/oniguruma/lonig.c", "src/oniguruma/lonig_f.c"}, + libraries = {"onig"}, + incdirs = {"$(ONIG_INCDIR)"}, + libdirs = {"$(ONIG_LIBDIR)"} + } + } + } +}, + +TRE = { + external_dependencies = { + TRE = { + header = "tre/tre.h", + library = "tre" + } + }, + build = { + type = "builtin", + modules = { + rex_tre = { + sources = {"src/common.c", "src/tre/ltre.c" --[[, "src/tre/tre_w.c"]]}, + libraries = {"tre"}, + incdirs = {"$(TRE_INCDIR)"}, + libdirs = {"$(TRE_LIBDIR)"} + } + } + } +}, + +GNU = { + external_dependencies = { + GNU = { + header = "regex.h", + } + }, + build = { + type = "builtin", + modules = { + rex_posix = {"src/common.c", "src/gnu/lgnu.c"} + } + } +}, + +} -- close wrapper table diff --git a/src/common.mak b/src/common.mak deleted file mode 100644 index 0652758..0000000 --- a/src/common.mak +++ /dev/null @@ -1,26 +0,0 @@ -# Rules for lrexlib - -TRG = rex_$(REGNAME) -DEFS = -DREX_OPENLIB=luaopen_$(TRG) -DREX_LIBNAME=\"$(TRG)\" -CFLAGS = $(MYCFLAGS) $(DEFS) $(INC) -TRG_AR = lib$(TRG).a -TRG_SO = $(TRG).so -LD = $(CC) -LDFLAGS= -shared -# For Darwin: -#LDFLAGS= -bundle -undefined dynamic_lookup - -all: $(TRG_AR) $(TRG_SO) - -$(TRG_AR): $(OBJ) - $(AR) $@ $^ - -$(TRG_SO): $(OBJ) - $(LD) -o $@.$V $(LDFLAGS) $^ $(LIB) $(LIB_LUA) - ln -fs $@.$V $@ - -clean: - rm -f $(OBJ) $(TRG_AR) $(TRG_SO)* - -check: all - LUA_PATH="../../test/?.lua;$(LUA_PATH)" $(LUA) ../../test/runtest.lua -d. $(REGNAME) diff --git a/src/defaults.mak b/src/defaults.mak deleted file mode 100644 index f2b2be9..0000000 --- a/src/defaults.mak +++ /dev/null @@ -1,17 +0,0 @@ -# default settings for lrexlib - -V = 2.6 -MINORV = 0 - -LUA = lua -INC_LUA = -LIB_LUA = - -# If the default settings don't work for your system, -# try to uncomment and edit the settings below. -#INC_LUA = -I/usr/include/lua5.1 -#LIB_LUA = -llua - -MYCFLAGS = -fPIC -W -Wall $(INC_LUA) $(INC_PCRE) -AR = ar rcu -CC = gcc diff --git a/src/gnu/Makefile b/src/gnu/Makefile deleted file mode 100644 index 8c3991d..0000000 --- a/src/gnu/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# makefile for rex_gnu library - -include ../defaults.mak - -# === USER SETTINGS === -# =========================================================================== - -# These are default values. -INC = -LIB = - -# If the default settings don't work for your system, -# try to uncomment and edit the settings below. -# The default settings below work with a libgnu.a in the current directory, -# copied from any libgnu.a built with the regex module. -#INC = -I. -DREX_GNU_INCLUDE='"regex.h"' -#LIB = -L. -lgnu - -# Regex library name -REGNAME = gnu - -# =========================================================================== -# === END OF USER SETTINGS === - -OBJ = lgnu.o ../common.o - -include ../common.mak - -# static GNU regexp library binding -ar_gnu: $(TRG_AR) - -# dynamic GNU regexp library binding -so_gnu: $(TRG_SO) - -# Dependencies -lgnu.o: lgnu.c ../common.h ../algo.h -../common.o: ../common.c ../common.h - -# (End of Makefile) diff --git a/src/oniguruma/Makefile b/src/oniguruma/Makefile deleted file mode 100644 index bb788fd..0000000 --- a/src/oniguruma/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# makefile for rex_onig library - -include ../defaults.mak - -# === USER SETTINGS === -# =========================================================================== - -# These are default values. -INC = -LIB = -lonig - -# If the default settings don't work for your system, -# try to uncomment and edit the settings below. -#INC = -#LIB = -lonig - -# Target name -REGNAME = onig - -# =========================================================================== -# === END OF USER SETTINGS === - -OBJ = lonig.o lonig_f.o ../common.o - -include ../common.mak - -# static Oniguruma regexp library binding -ar_onig: $(TRG_AR) - -# dynamic Oniguruma regexp library binding -so_onig: $(TRG_SO) - -# Dependencies -lonig.o: lonig.c ../common.h ../algo.h -lonig_f.o: lonig_f.c ../common.h -../common.o: ../common.c ../common.h - -# (End of Makefile) diff --git a/src/pcre/Makefile b/src/pcre/Makefile deleted file mode 100644 index c7897e3..0000000 --- a/src/pcre/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# makefile for rex_pcre library - -include ../defaults.mak - -# === USER SETTINGS === -# =========================================================================== - -# These are default values. -INC = -LIB = -lpcre - -# If the default settings don't work for your system, -# try to uncomment and edit the settings below. -#INC = -#LIB = -lpcre - -# Target name -REGNAME = pcre - -# =========================================================================== -# === END OF USER SETTINGS === - -OBJ = lpcre.o lpcre_f.o ../common.o - -include ../common.mak - -# static PCRE regexp library binding -ar_pcre: $(TRG_AR) - -# dynamic PCRE regexp library binding -so_pcre: $(TRG_SO) - -# Dependencies -lpcre.o: lpcre.c ../common.h ../algo.h -lpcre_f.o: lpcre_f.c ../common.h -../common.o: ../common.c ../common.h - -# (End of Makefile) diff --git a/src/posix/Makefile b/src/posix/Makefile deleted file mode 100644 index a797b87..0000000 --- a/src/posix/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# makefile for rex_posix library - -include ../defaults.mak - -# === USER SETTINGS === -# =========================================================================== - -# These are default values. -INC = -LIB = - -# If the default settings don't work for your system, -# try to uncomment and edit the settings below. -#INC = -#LIB = -lc - -# WARNING: -# If you want to use a POSIX regex library that is not the system -# default, make sure you set both the INC and LIB variables correctly, -# as if a header file and library are used which do not match, you may -# well get segmentation faults (or worse). - -# The following lines work for the rxspencer library, when installed -# under /usr (note the above warning!) -#INC = -I/usr/include/rxspencer -#LIB = -lrxspencer - -# Target name -REGNAME = posix - -# =========================================================================== -# === END OF USER SETTINGS === - -OBJ = lposix.o ../common.o - -include ../common.mak - -# static POSIX regexp library binding -ar_posix: $(TRG_AR) - -# dynamic POSIX regexp library binding -so_posix: $(TRG_SO) - -# Dependencies -lposix.o: lposix.c ../common.h ../algo.h -../common.o: ../common.c ../common.h - -# (End of Makefile) diff --git a/src/tre/Makefile b/src/tre/Makefile deleted file mode 100644 index 6618626..0000000 --- a/src/tre/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# makefile for rex_tre library - -include ../defaults.mak - -# === USER SETTINGS === -# =========================================================================== - -# These are default values. -INC = -LIB = -ltre - -# If the default settings don't work for your system, -# try to uncomment and edit the settings below. -#INC = -I/usr/include -#LIB = -lc - -# WARNING: -# Make sure you set both the INC and LIB variables correctly, as -# otherwise you risk using a header file and library that do not -# match, and you may well get segmentation faults (or worse). - -# Target name -REGNAME = tre - -# =========================================================================== -# === END OF USER SETTINGS === - -OBJ = ltre.o ../common.o # ltre_w.o - -include ../common.mak - -# static TRE regexp library binding -ar_tre: $(TRG_AR) - -# dynamic TRE regexp library binding -so_tre: $(TRG_SO) - -# Dependencies -ltre.o: ltre.c ../common.h ../algo.h -ltre_w.o: ltre_w.c ../common.h ../algo.h -../common.o: ../common.c ../common.h - -# (End of Makefile) diff --git a/test/onig_sets.lua b/test/oniguruma_sets.lua similarity index 100% rename from test/onig_sets.lua rename to test/oniguruma_sets.lua diff --git a/test/runtest.lua b/test/runtest.lua index d0d1435..fe32a3d 100644 --- a/test/runtest.lua +++ b/test/runtest.lua @@ -52,12 +52,12 @@ local function test_library (libname, setfile, verbose) end local avail_tests = { - posix = { lib = "rex_posix", "common_sets", "posix_sets" }, - gnu = { lib = "rex_gnu", "common_sets", "emacs_sets", "gnu_sets" }, - onig = { lib = "rex_onig", "common_sets", "onig_sets", }, - pcre = { lib = "rex_pcre", "common_sets", "pcre_sets", "pcre_sets2", }, - spencer = { lib = "rex_spencer", "common_sets", "posix_sets", "spencer_sets" }, - tre = { lib = "rex_tre", "common_sets", "posix_sets", "spencer_sets", --[["tre_sets"]] }, + posix = { lib = "rex_posix", "common_sets", "posix_sets" }, + gnu = { lib = "rex_gnu", "common_sets", "emacs_sets", "gnu_sets" }, + oniguruma = { lib = "rex_onig", "common_sets", "oniguruma_sets", }, + pcre = { lib = "rex_pcre", "common_sets", "pcre_sets", "pcre_sets2", }, + spencer = { lib = "rex_spencer", "common_sets", "posix_sets", "spencer_sets" }, + tre = { lib = "rex_tre", "common_sets", "posix_sets", "spencer_sets", --[["tre_sets"]] }, } do diff --git a/windows/mingw/Makefile b/windows/mingw/Makefile deleted file mode 100644 index e3efb9d..0000000 --- a/windows/mingw/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# Makefile for lrexlib - -MKFILES = \ - rex_gnu.mak \ - rex_onig.mak \ - rex_pcre.mak \ - rex_spencer.mak \ - rex_tre.mak - -LOOP = @for %%d in ($(MKFILES)) do $(MAKE) -f %%d - -all: build test - -build: - $(LOOP) - -test: - $(LOOP) test - -install: - $(LOOP) install - -clean: - del *.o *.def *.dll - -.PHONY: all build test install clean diff --git a/windows/mingw/_mingw.mak b/windows/mingw/_mingw.mak deleted file mode 100644 index 9d56927..0000000 --- a/windows/mingw/_mingw.mak +++ /dev/null @@ -1,64 +0,0 @@ -# Use with GNU Make. - -# User Settings ------------------------------------------------------------ - -# Target Lua version (51 for Lua 5.1; 52 for Lua 5.2). -LUAVERSION = 51 - -# INSTALLPATH : Path to install the built DLL. -# LUADLL : Name of Lua DLL to link to (.dll should be omitted). -# LUAEXE : Name of Lua interpreter. -# LUAINC : Path of Lua include files. - -ifeq ($(LUAVERSION),51) - INSTALLPATH = s:\exe\lib32\lua51 - LUADLL = lua5.1 - LUAEXE = lua.exe - LUAINC = s:\progr\work\system\include\lua51 - MYCFLAGS += -DREX_CREATEGLOBALVAR -else - INSTALLPATH = s:\exe\lib32\lua52 - LUADLL = lua52 - LUAEXE = lua52.exe - LUAINC = s:\progr\work\system\include\lua52 -# MYCFLAGS += -DREX_CREATEGLOBALVAR -endif - -# -------------------------------------------------------------------------- - -BIN = $(PROJECT).dll -BININSTALL = $(INSTALLPATH)\$(BIN) -CC = gcc -CFLAGS = -W -Wall -O2 $(INCS) -DREX_OPENLIB=luaopen_$(PROJECT) \ - -DREX_LIBNAME=\"$(PROJECT)\" $(MYCFLAGS) -DEFFILE = $(PROJECT).def -EXPORTED = luaopen_$(PROJECT) -INCS = -I$(LUAINC) $(MYINCS) -LIBS = -l$(LUADLL) $(MYLIBS) -s -SRCPATH = ..\..\src -TESTPATH = ..\..\test - -.PHONY: all install test clean - -vpath %.c $(SRCPATH);$(SRCPATH)\$(PROJDIR) -vpath %.h $(SRCPATH);$(SRCPATH)\$(PROJDIR) - -all: $(BIN) - -clean: - del $(OBJ) $(BIN) $(DEFFILE) - -install: $(BININSTALL) - -test: - cd $(TESTPATH) && $(LUAEXE) runtest.lua $(TESTNAME) -d$(CURDIR) - -$(BIN): $(OBJ) $(DEFFILE) - $(CC) $(DEFFILE) $(OBJ) $(LIBS) -o $@ -shared - -$(DEFFILE): - echo EXPORTS > $@ - for %%d in ($(EXPORTED)) do echo %%d>> $@ - -$(BININSTALL): $(BIN) - copy /Y $< $@ diff --git a/windows/mingw/docs.mak b/windows/mingw/docs.mak deleted file mode 100644 index 7c813aa..0000000 --- a/windows/mingw/docs.mak +++ /dev/null @@ -1,13 +0,0 @@ -# Documentation Makefile - -APP = rst2html.py -CP = "copy /y" -RM = del -IDX = ..\README.rst - -ALLVAR = APP=$(APP) CP=$(CP) RM=$(RM) IDX=$(IDX) - -.PHONY: all clean - -all clean: - cd ..\..\doc && $(MAKE) $(ALLVAR) $@ diff --git a/windows/mingw/rex_gnu.mak b/windows/mingw/rex_gnu.mak deleted file mode 100644 index fb17a5c..0000000 --- a/windows/mingw/rex_gnu.mak +++ /dev/null @@ -1,18 +0,0 @@ -# Project: rex_gnu - -# User Settings ------------------------------------------------------------ -# path of GNU include files -REGEXINC = s:\progr\work\system\include\gnuregex -# -------------------------------------------------------------------------- - -PROJECT = rex_gnu -MYINCS = -I$(REGEXINC) -MYLIBS = -lregex2 -OBJ = lgnu.o common.o -PROJDIR = gnu -TESTNAME = gnu - -include _mingw.mak - -lgnu.o : common.h algo.h -common.o : common.h diff --git a/windows/mingw/rex_onig.mak b/windows/mingw/rex_onig.mak deleted file mode 100644 index 4e9f5f7..0000000 --- a/windows/mingw/rex_onig.mak +++ /dev/null @@ -1,19 +0,0 @@ -# Project: rex_onig - -# User Settings ------------------------------------------------------------ -# path of Oniguruma include files -REGEXINC = s:\progr\work\system\include -# -------------------------------------------------------------------------- - -PROJECT = rex_onig -MYINCS = -I$(REGEXINC) -MYLIBS = -lonig -Wl,--enable-auto-import -OBJ = lonig.o lonig_f.o common.o -PROJDIR = oniguruma -TESTNAME = onig - -include _mingw.mak - -lonig.o : common.h algo.h -lonig_f.o : common.h -common.o : common.h diff --git a/windows/mingw/rex_pcre.mak b/windows/mingw/rex_pcre.mak deleted file mode 100644 index b6d34ce..0000000 --- a/windows/mingw/rex_pcre.mak +++ /dev/null @@ -1,19 +0,0 @@ -# Project: rex_pcre - -# User Settings ------------------------------------------------------------ -# path of PCRE include files -REGEXINC = s:\progr\work\system\include -# -------------------------------------------------------------------------- - -PROJECT = rex_pcre -MYINCS = -I$(REGEXINC) -MYLIBS = -lpcre -OBJ = lpcre.o lpcre_f.o common.o -PROJDIR = pcre -TESTNAME = pcre - -include _mingw.mak - -lpcre.o : common.h algo.h -lpcre_f.o : common.h -common.o : common.h diff --git a/windows/mingw/rex_spencer.mak b/windows/mingw/rex_spencer.mak deleted file mode 100644 index fb82f0c..0000000 --- a/windows/mingw/rex_spencer.mak +++ /dev/null @@ -1,18 +0,0 @@ -# Project: rex_spencer - -# User Settings ------------------------------------------------------------ -# path of Spencer's include files -REGEXINC = s:\progr\work\system\include\rxspencer -# -------------------------------------------------------------------------- - -PROJECT = rex_spencer -MYINCS = -I$(REGEXINC) -MYLIBS = -lrxspencer -OBJ = lposix.o common.o -PROJDIR = posix -TESTNAME = spencer - -include _mingw.mak - -lposix.o : common.h algo.h -common.o : common.h diff --git a/windows/mingw/rex_tre.mak b/windows/mingw/rex_tre.mak deleted file mode 100644 index de7c5a3..0000000 --- a/windows/mingw/rex_tre.mak +++ /dev/null @@ -1,26 +0,0 @@ -# Project: rex_tre - -# User Settings ------------------------------------------------------------ -# path of TRE include files -REGEXINC = s:\progr\work\system\include -# -------------------------------------------------------------------------- - -PROJECT = rex_tre -MYINCS = -I$(REGEXINC) -MYLIBS = -ltre -OBJ = ltre.o common.o -PROJDIR = tre -TESTNAME = tre - -# Uncomment the following line to add wide-character functions (in alpha state). -# ADDWIDECHARFUNCS = 1 -ifdef ADDWIDECHARFUNCS - OBJ += ltre_w.o - MYCFLAGS += -DREX_ADDWIDECHARFUNCS -endif - -include _mingw.mak - -ltre.o : common.h algo.h -ltre_w.o : common.h algo.h -common.o : common.h From 145fc81aa9b2dd6ea6d53eb18e0f948991773ecb Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:08:46 +0100 Subject: [PATCH 10/33] Makefile: rename doc target to docs, to avoid clash with doc directory --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dab648f..0458835 100644 --- a/Makefile +++ b/Makefile @@ -13,10 +13,10 @@ check: cd src/$$i && LUA_PATH="../../test/?.lua;$(LUA_PATH)" $(LUA) ../../test/runtest.lua -d. $$i && cd ../..; \ done -doc: +docs: @make -C doc -dist: doc +dist: docs git2cl > ChangeLog cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) From 4d23cfb500678ffc285860bfb6dd5e2863dda6c2 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:19:41 +0100 Subject: [PATCH 11/33] Makefile: add a target to make the rockspecs --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 0458835..8dedb8b 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,9 @@ check: docs: @make -C doc +rockspecs: + lua mkrockspecs.lua $(VERSION) `md5sum $(DISTFILE)` + dist: docs git2cl > ChangeLog cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) From 49b14d86ff46b25b5399987e970dc851ac821119 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:20:07 +0100 Subject: [PATCH 12/33] Remove unnecessary version numbers and have only one source of the version. --- LICENSE | 4 ++-- README.rst | 4 ++-- doc/license.html | 2 +- doc/manual.txt | 4 ++-- rockspecs.lua | 13 +++++++++++-- src/algo.h | 3 +-- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/LICENSE b/LICENSE index 5844250..6cbc664 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ -License of Lrexlib release 2.6 ------------------------------- +License of Lrexlib release +-------------------------- Copyright (C) Reuben Thomas 2000-2012 Copyright (C) Shmuel Zeigerman 2004-2012 diff --git a/README.rst b/README.rst index 41a3f8c..e0d7ad9 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -Lrexlib 2.6 -=========== +Lrexlib +======= | by Reuben Thomas (rrt@sc3d.org) | and Shmuel Zeigerman (shmuz@013net.net) [maintainer] diff --git a/doc/license.html b/doc/license.html index 15335ed..91c476a 100644 --- a/doc/license.html +++ b/doc/license.html @@ -5,7 +5,7 @@ -

Lrexlib 2.6

+

Lrexlib

Copyright © Reuben Thomas 2000-2012
Copyright © Shmuel Zeigerman 2004-2012 diff --git a/doc/manual.txt b/doc/manual.txt index 72790ba..f0c379a 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -1,7 +1,7 @@ .. role:: funcdef(literal) -Lrexlib 2.6 Reference Manual -============================ +Lrexlib Reference Manual +======================== .. contents:: Table of Contents diff --git a/rockspecs.lua b/rockspecs.lua index 8d5c06a..9ad55c8 100644 --- a/rockspecs.lua +++ b/rockspecs.lua @@ -45,6 +45,7 @@ PCRE = { type = "builtin", modules = { rex_pcre = { + defines = {"VERSION=\""..version.."\""}, sources = {"src/common.c", "src/pcre/lpcre.c", "src/pcre/lpcre_f.c"}, libraries = {"pcre"}, incdirs = {"$(PCRE_INCDIR)"}, @@ -63,7 +64,10 @@ POSIX = { build = { type = "builtin", modules = { - rex_posix = {"src/common.c", "src/posix/lposix.c"} + rex_posix = { + defines = {"VERSION=\""..version.."\""}, + sources = {"src/common.c", "src/posix/lposix.c"} + } } } }, @@ -79,6 +83,7 @@ oniguruma = { type = "builtin", modules = { rex_onig = { + defines = {"VERSION=\""..version.."\""}, sources = {"src/common.c", "src/oniguruma/lonig.c", "src/oniguruma/lonig_f.c"}, libraries = {"onig"}, incdirs = {"$(ONIG_INCDIR)"}, @@ -99,6 +104,7 @@ TRE = { type = "builtin", modules = { rex_tre = { + defines = {"VERSION=\""..version.."\""}, sources = {"src/common.c", "src/tre/ltre.c" --[[, "src/tre/tre_w.c"]]}, libraries = {"tre"}, incdirs = {"$(TRE_INCDIR)"}, @@ -117,7 +123,10 @@ GNU = { build = { type = "builtin", modules = { - rex_posix = {"src/common.c", "src/gnu/lgnu.c"} + rex_posix = { + defines = {"VERSION=\""..version.."\""}, + source = {"src/common.c", "src/gnu/lgnu.c"} + } } } }, diff --git a/src/algo.h b/src/algo.h index e268a02..4a0afb3 100644 --- a/src/algo.h +++ b/src/algo.h @@ -3,8 +3,7 @@ #include "common.h" -/* FIXME: Get version from defaults.mak */ -#define REX_VERSION "Lrexlib 2.6.0" +#define REX_VERSION "Lrexlib " VERSION /* Forward declarations */ static void gmatch_pushsubject (lua_State *L, TArgExec *argE); From 91f4d3560bef3e245e9b44dae6ed1f1a4e474152 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:22:01 +0100 Subject: [PATCH 13/33] Makefile: bump version to 2.7.0 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8dedb8b..8872a87 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ REGNAMES = gnu pcre posix oniguruma tre PROJECT = lrexlib -VERSION = 2.6.0 +VERSION = 2.7.0 PROJECT_VERSIONED = $(PROJECT)-$(VERSION) DISTFILE = $(PROJECT_VERSIONED).zip From 275b34b093d908323e1ba24107ddacc5256bd4be Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:49:13 +0100 Subject: [PATCH 14/33] rockspecs.lua: fix some typos in the GNU rockspec --- rockspecs.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rockspecs.lua b/rockspecs.lua index 9ad55c8..2d3d89e 100644 --- a/rockspecs.lua +++ b/rockspecs.lua @@ -123,9 +123,9 @@ GNU = { build = { type = "builtin", modules = { - rex_posix = { + rex_gnu = { defines = {"VERSION=\""..version.."\""}, - source = {"src/common.c", "src/gnu/lgnu.c"} + sources = {"src/common.c", "src/gnu/lgnu.c"} } } } From ed4a8521bd63704dc81284109791f5b33015b85d Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:53:33 +0100 Subject: [PATCH 15/33] Makefile: simplify running tests, and error if LUA is not set --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8872a87..f350546 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,9 @@ PROJECT_VERSIONED = $(PROJECT)-$(VERSION) DISTFILE = $(PROJECT_VERSIONED).zip check: + @if test -z "$(LUA)"; then echo "Set LUA to run tests"; exit 1; fi @for i in $(REGNAMES); do \ - cd src/$$i && LUA_PATH="../../test/?.lua;$(LUA_PATH)" $(LUA) ../../test/runtest.lua -d. $$i && cd ../..; \ + LUA_PATH="test/?.lua;$(LUA_PATH)" $(LUA) test/runtest.lua -dsrc/$$i $$i; \ done docs: From 44176181c728575b9e07f75709b735551ae17457 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:54:01 +0100 Subject: [PATCH 16/33] common.c: use Lua state allocator for TBuffers --- src/common.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common.c b/src/common.c index e1adf2e..3ae87f0 100644 --- a/src/common.c +++ b/src/common.c @@ -97,7 +97,6 @@ void freelist_free (TFreeList *fl) { * ************* * Auto-extensible array of characters for building long strings incrementally. * * Differs from luaL_Buffer in that: - * * it does not use Lua facilities (except luaL_error when malloc fails) * * its operations do not change Lua stack top position * * buffer_addvalue does not extract the value from Lua stack * * buffer_pushresult does not have to be the last operation @@ -116,7 +115,9 @@ void freelist_free (TFreeList *fl) { enum { ID_NUMBER, ID_STRING }; void buffer_init (TBuffer *buf, size_t sz, lua_State *L, TFreeList *fl) { - buf->arr = (char*) malloc (sz); + void *ud; + lua_Alloc lalloc = lua_getallocf(L, &ud); + buf->arr = (char*) lalloc (ud, NULL, 0, sz); if (!buf->arr) { freelist_free (fl); luaL_error (L, "malloc failed"); @@ -129,7 +130,9 @@ void buffer_init (TBuffer *buf, size_t sz, lua_State *L, TFreeList *fl) { } void buffer_free (TBuffer *buf) { - free (buf->arr); + void *ud; + lua_Alloc lalloc = lua_getallocf(buf->L, &ud); + lalloc (buf->L, buf->arr, buf->size, 0); } void buffer_clear (TBuffer *buf) { @@ -147,7 +150,9 @@ void buffer_addbuffer (TBuffer *trg, TBuffer *src) { void buffer_addlstring (TBuffer *buf, const void *src, size_t sz) { size_t newtop = buf->top + sz; if (newtop > buf->size) { - char *p = (char*) realloc (buf->arr, 2 * newtop); /* 2x expansion */ + void *ud; + lua_Alloc lalloc = lua_getallocf(buf->L, &ud); + char *p = (char*) lalloc (buf->L, buf->arr, buf->size, 2 * newtop); /* 2x expansion */ if (!p) { freelist_free (buf->freelist); luaL_error (buf->L, "realloc failed"); From bb7fefc410b84fcfea40b0abc84383fd9d081f88 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:59:09 +0100 Subject: [PATCH 17/33] Makefile: add a convenience install target for testing --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index f350546..9eac009 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,11 @@ VERSION = 2.7.0 PROJECT_VERSIONED = $(PROJECT)-$(VERSION) DISTFILE = $(PROJECT_VERSIONED).zip +install: + @for i in *.rockspec; do \ + luarocks make $$i; \ + done + check: @if test -z "$(LUA)"; then echo "Set LUA to run tests"; exit 1; fi @for i in $(REGNAMES); do \ From ba7c99ebf3758e8c9fba10f946a6b35e8d7b4fbf Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 4 Oct 2012 18:59:27 +0100 Subject: [PATCH 18/33] common.c: remove last use of non-Lua state malloc --- NEWS | 1 + src/common.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2ab071a..ecdb565 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ * Allow POSIX REG_STARTEND to be used on any system supporting it. * Add a test set for POSIX regex engine (thanks, Enrico Tassi). * Simplify some code. + * Always use Lua state memory allocator. 2012-04-13 Release 2.6.0 diff --git a/src/common.c b/src/common.c index 3ae87f0..fabbd80 100644 --- a/src/common.c +++ b/src/common.c @@ -28,7 +28,9 @@ void set_int_field (lua_State *L, const char* field, int val) } void *Lmalloc(lua_State *L, size_t size) { - void *p = malloc(size); + void *ud; + lua_Alloc lalloc = lua_getallocf(L, &ud); + void *p = lalloc(L, NULL, 0, size); if(p == NULL) luaL_error(L, "malloc failed"); return p; From 2d3a182f8c128d2e972734493c445b1a5ef5f635 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 5 Oct 2012 12:59:26 +0100 Subject: [PATCH 19/33] Makefile: test rockspecs after uploading the distribution before announcing it. --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9eac009..e0d9205 100644 --- a/Makefile +++ b/Makefile @@ -29,11 +29,17 @@ dist: docs git2cl > ChangeLog cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) +WOGER_ARGS = package=$(PROJECT) package_name=$(PROJECT) version=$(VERSION) description="Lua binding for regex libraries" notes=release-notes dist_type="zip" github_user=rrthomas + release: agrep -d 'Release' $(VERSION) NEWS | tail -n +3 | head -n -2 > release-notes && \ git diff --exit-code && \ git tag -a -m "Release tag" rel-`echo $(VERSION) | sed -e 's/\./-/g'` && \ git push && git push --tags && \ - woger lua,github package=$(PROJECT) package_name=$(PROJECT) version=$(VERSION) description="Lua binding for regex libraries" notes=release-notes dist_type="zip" github_user=rrthomas + woger github $(WOGER_ARGS) && \ + for i in $(REGNAMES); do + LUAROCKS_CONFIG=luarocks-config.lua luarocks --tree=luarocks build $$i; \ + done && \ + woger lua $(WOGER_ARGS) @echo "Don't forget to upload release to github!" rm -f release-notes From 064c1f4533a4f21e3e2ab5f591851052424af9c6 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 5 Oct 2012 13:00:45 +0100 Subject: [PATCH 20/33] Makefile: fix a typo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e0d9205..cdac100 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ release: git tag -a -m "Release tag" rel-`echo $(VERSION) | sed -e 's/\./-/g'` && \ git push && git push --tags && \ woger github $(WOGER_ARGS) && \ - for i in $(REGNAMES); do + for i in $(REGNAMES); do \ LUAROCKS_CONFIG=luarocks-config.lua luarocks --tree=luarocks build $$i; \ done && \ woger lua $(WOGER_ARGS) From c2d49c4e7c323be45512595a7114a05f5409653c Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 5 Oct 2012 13:01:23 +0100 Subject: [PATCH 21/33] Makefile: make release depend on dist and check --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cdac100..9205ada 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ dist: docs WOGER_ARGS = package=$(PROJECT) package_name=$(PROJECT) version=$(VERSION) description="Lua binding for regex libraries" notes=release-notes dist_type="zip" github_user=rrthomas -release: +release: dist check agrep -d 'Release' $(VERSION) NEWS | tail -n +3 | head -n -2 > release-notes && \ git diff --exit-code && \ git tag -a -m "Release tag" rel-`echo $(VERSION) | sed -e 's/\./-/g'` && \ From 0e2bc8c4c8a128517618c3ba762a6c9279cbc34c Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 5 Oct 2012 23:16:56 +0100 Subject: [PATCH 22/33] Makefile: fix testing of rockspecs, and remove now-redundant warning to upload to github --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9205ada..94be467 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,8 @@ release: dist check git tag -a -m "Release tag" rel-`echo $(VERSION) | sed -e 's/\./-/g'` && \ git push && git push --tags && \ woger github $(WOGER_ARGS) && \ - for i in $(REGNAMES); do \ + for i in *.rockspec; do \ LUAROCKS_CONFIG=luarocks-config.lua luarocks --tree=luarocks build $$i; \ done && \ woger lua $(WOGER_ARGS) - @echo "Don't forget to upload release to github!" rm -f release-notes From 5ed05e76523d77d1acd8061117aa59314106da3e Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Wed, 17 Oct 2012 21:02:02 +0100 Subject: [PATCH 23/33] Add luarocks-config.lua, needed for testing rockspecs --- luarocks-config.lua | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 luarocks-config.lua diff --git a/luarocks-config.lua b/luarocks-config.lua new file mode 100644 index 0000000..582623b --- /dev/null +++ b/luarocks-config.lua @@ -0,0 +1,3 @@ +rocks_trees = { + "./luarocks" +} From a23eb8906b15a517d1a5261ce1ccd829a0ce131c Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Wed, 17 Oct 2012 21:05:52 +0100 Subject: [PATCH 24/33] .gitignore: add luarocks directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4dba253..9b8eff7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ ChangeLog *.zip release-notes /*.rockspec +/luarocks From 1ed329073eb786b2958f723b859c6f99cbe85d98 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Wed, 17 Oct 2012 21:34:38 +0100 Subject: [PATCH 25/33] algo.h: fix to make it work on Lua 5.1; oops --- src/algo.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/algo.h b/src/algo.h index 4a0afb3..488cad7 100644 --- a/src/algo.h +++ b/src/algo.h @@ -134,7 +134,11 @@ static void check_subject (lua_State *L, int pos, TArgExec *argE) lua_typename (L, type)); argE->text = lua_touserdata (L, -1); lua_pop (L, 1); +#if LUA_VERSION_NUM == 501 + lua_objlen (L, pos); +#else lua_len (L, pos); +#endif type = lua_type (L, -1); if (type != LUA_TNUMBER) luaL_error (L, "subject's length is %s (expected number)", From e22585e5655141bda83b237a90078d15026fdcc2 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Wed, 17 Oct 2012 21:53:37 +0100 Subject: [PATCH 26/33] rockspecs.lua: mention that we're Lua 5.2 compatible --- rockspecs.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rockspecs.lua b/rockspecs.lua index 2d3d89e..2f25788 100644 --- a/rockspecs.lua +++ b/rockspecs.lua @@ -22,7 +22,7 @@ default = { description = { summary = "Regular expression library binding ("..flavour.." flavour).", detailed = [[ - Lrexlib is a regular expression library for Lua 5.1, which + Lrexlib is a regular expression library for Lua 5.1 and 5.2, which provides bindings for several regular expression libraries. This rock provides the ]]..flavour..[[ bindings. ]], From e3ca7bf625c105afc9165c358e859708f1d678bb Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Wed, 17 Oct 2012 21:55:17 +0100 Subject: [PATCH 27/33] rockspecs.lua: fix some inconsistent whitespace --- rockspecs.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rockspecs.lua b/rockspecs.lua index 2f25788..3fe2615 100644 --- a/rockspecs.lua +++ b/rockspecs.lua @@ -13,8 +13,8 @@ local flavours = {"PCRE", "POSIX", "oniguruma", "TRE", "GNU"} return { default = { - package="Lrexlib-"..flavour, - version=version.."-1", + package = "Lrexlib-"..flavour, + version = version.."-1", source = { url = "https://github.com/downloads/rrthomas/lrexlib/lrexlib-"..version..".zip", md5 = md5sum From db3e4e5b0e5dbfcbbf47b4140a6186749616152b Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 18 Oct 2012 13:22:15 +0100 Subject: [PATCH 28/33] Allow to signal no replacement in gsub with a nil or false replacement. --- doc/manual.txt | 14 ++++++++++---- src/algo.h | 12 +++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/doc/manual.txt b/doc/manual.txt index f0c379a..ab68394 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -230,7 +230,8 @@ below). +---------+-----------------------------------+-------------------------+-------------+ | patt |regular expression pattern |string or userdata | n/a | +---------+-----------------------------------+-------------------------+-------------+ - | repl |substitution source |string, function or table| n/a | + | repl |substitution source |string, function, table, | n/a | + | | |``false`` or ``nil`` | | +---------+-----------------------------------+-------------------------+-------------+ | [n] |maximum number of matches to search| number or function | ``nil`` | | |for, or control function, or nil | | | @@ -248,9 +249,9 @@ below). 3. Number of substitutions made. **Details:** - The parameter *repl* can be either a string, a function or a table. - On each match made, it is converted into a value *repl_out* that may be used - for the replacement. + The parameter *repl* can be either a string, a function, a table, + ``false`` or ``nil``. On each match made, it is converted into a + value *repl_out* that may be used for the replacement. *repl_out* is generated differently depending on the type of *repl*: @@ -289,6 +290,11 @@ below). same rules as for the return value of *repl* call, described in the above paragraph. + 4. If *repl* is ``false`` or ``nil``, no replacement is done. Note + that, unusually for Lua, if ``repl`` is absent, it is not taken + to be ``nil``. This is to prevent programming errors caused by + inadvertently missing out *repl*. + Note: Under some circumstances, the value of *repl_out* may be ignored; see below_. diff --git a/src/algo.h b/src/algo.h index 488cad7..2255070 100644 --- a/src/algo.h +++ b/src/algo.h @@ -172,8 +172,10 @@ static void checkarg_gsub (lua_State *L, TArgComp *argC, TArgExec *argE) { lua_tostring (L, 3); /* converts number (if any) to string */ argE->reptype = lua_type (L, 3); if (argE->reptype != LUA_TSTRING && argE->reptype != LUA_TTABLE && - argE->reptype != LUA_TFUNCTION) { - luaL_typerror (L, 3, "string, table or function"); + argE->reptype != LUA_TFUNCTION && argE->reptype != LUA_TNIL && + (argE->reptype != LUA_TBOOLEAN || + (argE->reptype == LUA_TBOOLEAN && lua_toboolean (L, 3)))) { + luaL_typerror (L, 3, "string, table, function, false or nil"); } argE->funcpos = 3; argE->funcpos2 = 4; @@ -334,7 +336,11 @@ static int algf_gsub (lua_State *L) { } } /*----------------------------------------------------------------*/ - if (argE.reptype != LUA_TSTRING) { + else if (argE.reptype == LUA_TNIL || argE.reptype == LUA_TBOOLEAN) { + buffer_addlstring (pBuf, argE.text + from, to - from); + } + /*----------------------------------------------------------------*/ + if (argE.reptype == LUA_TTABLE || argE.reptype == LUA_TFUNCTION) { if (lua_tostring (L, -1)) { buffer_addvalue (pBuf, -1); curr_subst = 1; From b02e77feeb28a4493f7be129f397e5ec5aeb1f62 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 18 Oct 2012 13:27:36 +0100 Subject: [PATCH 29/33] Makefile: bump version to 2.7.1 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 94be467..ddf658b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ REGNAMES = gnu pcre posix oniguruma tre PROJECT = lrexlib -VERSION = 2.7.0 +VERSION = 2.7.1 PROJECT_VERSIONED = $(PROJECT)-$(VERSION) DISTFILE = $(PROJECT_VERSIONED).zip From f106462d51ef930dd382901cf08f5fe933393277 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 18 Oct 2012 13:32:14 +0100 Subject: [PATCH 30/33] Makefile: exclude luarocks directory from distribution zip --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ddf658b..63141b8 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ rockspecs: dist: docs git2cl > ChangeLog - cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) + cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" "lrexlib/luarocks/*" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) WOGER_ARGS = package=$(PROJECT) package_name=$(PROJECT) version=$(VERSION) description="Lua binding for regex libraries" notes=release-notes dist_type="zip" github_user=rrthomas From 5af421a5c03960d5ca7554a4fd3e1a2bc8e531b9 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 18 Oct 2012 13:57:25 +0100 Subject: [PATCH 31/33] Makefile: make it harder to make mistakes Have install depend on dist, and dist depend on rockspecs, and make rockspecs remove any old rockspec files, so it is much less likely that the wrong rockspec is used, or out-of-date rockspecs distributed. --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 63141b8..93b2690 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ VERSION = 2.7.1 PROJECT_VERSIONED = $(PROJECT)-$(VERSION) DISTFILE = $(PROJECT_VERSIONED).zip -install: +install: dist @for i in *.rockspec; do \ luarocks make $$i; \ done @@ -23,9 +23,10 @@ docs: @make -C doc rockspecs: + rm -f *.rockspec lua mkrockspecs.lua $(VERSION) `md5sum $(DISTFILE)` -dist: docs +dist: docs rockspecs git2cl > ChangeLog cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" "lrexlib/luarocks/*" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) From d9722d0277c6bc4df3d985cf0b046a3704489de9 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 18 Oct 2012 14:04:17 +0100 Subject: [PATCH 32/33] NEWS: add for 2.7.1 --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index ecdb565..076a1b5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +2012-10-18 Release 2.7.1 + + * Fixed Lua 5.1 compatibility, broken in 2.7.0. + * Added ability to specify no replacement to gsub with a nil or + false replacement argument. + 2012-10-04 Release 2.7.0 * Added support for searching raw memory buffers (e.g. made with From b1db4e5ae44e54eb41401ebfc8609d3c30890395 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 18 Oct 2012 14:14:45 +0100 Subject: [PATCH 33/33] Makefile: fix things so rockspecs aren't distributed (a hard problem) but do have the right MD5 sums --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 93b2690..6e69c5d 100644 --- a/Makefile +++ b/Makefile @@ -22,17 +22,17 @@ check: docs: @make -C doc -rockspecs: +rockspecs: dist rm -f *.rockspec lua mkrockspecs.lua $(VERSION) `md5sum $(DISTFILE)` -dist: docs rockspecs +dist: docs git2cl > ChangeLog - cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" "lrexlib/luarocks/*" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) + cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" "*.rockspec" "lrexlib/luarocks/*" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED) WOGER_ARGS = package=$(PROJECT) package_name=$(PROJECT) version=$(VERSION) description="Lua binding for regex libraries" notes=release-notes dist_type="zip" github_user=rrthomas -release: dist check +release: rockspecs check agrep -d 'Release' $(VERSION) NEWS | tail -n +3 | head -n -2 > release-notes && \ git diff --exit-code && \ git tag -a -m "Release tag" rel-`echo $(VERSION) | sed -e 's/\./-/g'` && \