Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (33 commits)
  Makefile: fix things so rockspecs aren't distributed (a hard problem) but do have the right MD5 sums
  NEWS: add for 2.7.1
  Makefile: make it harder to make mistakes
  Makefile: exclude luarocks directory from distribution zip
  Makefile: bump version to 2.7.1
  Allow to signal no replacement in gsub with a nil or false replacement.
  rockspecs.lua: fix some inconsistent whitespace
  rockspecs.lua: mention that we're Lua 5.2 compatible
  algo.h: fix to make it work on Lua 5.1; oops
  .gitignore: add luarocks directory
  Add luarocks-config.lua, needed for testing rockspecs
  Makefile: fix testing of rockspecs, and remove now-redundant warning to upload to github
  Makefile: make release depend on dist and check
  Makefile: fix a typo
  Makefile: test rockspecs after uploading the distribution before announcing it.
  common.c: remove last use of non-Lua state malloc
  Makefile: add a convenience install target for testing
  common.c: use Lua state allocator for TBuffers
  Makefile: simplify running tests, and error if LUA is not set
  rockspecs.lua: fix some typos in the GNU rockspec
  ...
  • Loading branch information
drahosp committed Oct 29, 2012
2 parents a2aad49 + b1db4e5 commit 13949ab
Show file tree
Hide file tree
Showing 33 changed files with 386 additions and 540 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -5,3 +5,5 @@
ChangeLog
*.zip
release-notes
/*.rockspec
/luarocks
4 changes: 2 additions & 2 deletions 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
Expand Down
44 changes: 24 additions & 20 deletions Makefile
@@ -1,41 +1,45 @@
# 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.7.1
PROJECT_VERSIONED = $(PROJECT)-$(VERSION)
DISTFILE = $(PROJECT_VERSIONED).zip

all:
@for i in $(REGNAMES); do \
make -C src/$$i; \
install: dist
@for i in *.rockspec; do \
luarocks make $$i; \
done
@make -C doc

check: all
check:
@if test -z "$(LUA)"; then echo "Set LUA to run tests"; exit 1; fi
@for i in $(REGNAMES); do \
make -C src/$$i check; \
LUA_PATH="test/?.lua;$(LUA_PATH)" $(LUA) test/runtest.lua -dsrc/$$i $$i; \
done

clean:
@for i in $(REGNAMES); do \
make -C src/$$i clean; \
done
@make -C doc clean
docs:
@make -C doc

dist: all
rockspecs: dist
rm -f *.rockspec
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)
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:
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'` && \
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
@echo "Don't forget to upload release to github!"
woger github $(WOGER_ARGS) && \
for i in *.rockspec; do \
LUAROCKS_CONFIG=luarocks-config.lua luarocks --tree=luarocks build $$i; \
done && \
woger lua $(WOGER_ARGS)
rm -f release-notes
19 changes: 19 additions & 0 deletions NEWS
@@ -1,3 +1,22 @@
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
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.
* Always use Lua state memory allocator.

2012-04-13 Release 2.6.0

* Added support for Lua 5.2.
Expand Down
4 changes: 2 additions & 2 deletions README.rst
@@ -1,5 +1,5 @@
Lrexlib 2.6
===========
Lrexlib
=======

| by Reuben Thomas (rrt@sc3d.org)
| and Shmuel Zeigerman (shmuz@013net.net) [maintainer]
Expand Down
2 changes: 1 addition & 1 deletion doc/license.html
Expand Up @@ -5,7 +5,7 @@
</head>
<body>

<h2>Lrexlib 2.6</h2>
<h2>Lrexlib</h2>
<p>Copyright &copy; Reuben Thomas 2000-2012<br>
Copyright &copy; Shmuel Zeigerman 2004-2012

Expand Down
34 changes: 25 additions & 9 deletions doc/manual.txt
@@ -1,7 +1,7 @@
.. role:: funcdef(literal)

Lrexlib 2.6 Reference Manual
============================
Lrexlib Reference Manual
========================

.. contents:: Table of Contents

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.

------------------------------------------------------------
Expand Down Expand Up @@ -220,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 | | |
Expand All @@ -238,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*:

Expand Down Expand Up @@ -279,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_.

Expand Down
3 changes: 3 additions & 0 deletions luarocks-config.lua
@@ -0,0 +1,3 @@
rocks_trees = {
"./luarocks"
}
49 changes: 49 additions & 0 deletions 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
134 changes: 134 additions & 0 deletions rockspecs.lua
@@ -0,0 +1,134 @@
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 and 5.2, 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 = {
defines = {"VERSION=\""..version.."\""},
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 = {
defines = {"VERSION=\""..version.."\""},
sources = {"src/common.c", "src/posix/lposix.c"}
}
}
}
},

oniguruma = {
external_dependencies = {
ONIG = {
header = "oniguruma.h",
library = "onig"
}
},
build = {
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)"},
libdirs = {"$(ONIG_LIBDIR)"}
}
}
}
},

TRE = {
external_dependencies = {
TRE = {
header = "tre/tre.h",
library = "tre"
}
},
build = {
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)"},
libdirs = {"$(TRE_LIBDIR)"}
}
}
}
},
GNU = {
external_dependencies = {
GNU = {
header = "regex.h",
}
},
build = {
type = "builtin",
modules = {
rex_gnu = {
defines = {"VERSION=\""..version.."\""},
sources = {"src/common.c", "src/gnu/lgnu.c"}
}
}
}
},
} -- close wrapper table

0 comments on commit 13949ab

Please sign in to comment.