From 1484a6c3d4929420c05477c4b6c5de355bdaee5d Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Tue, 26 Mar 2013 09:35:59 +0700 Subject: [PATCH 1/7] configury: mkrockspecs uses uninstalled stdlib again. (issue #24) * GNUmakefile (ROCKSPEC_ENV): Default to same value as LUA_ENV. (MKROCKSPECS): Now uses lua-stdlib from the build tree, not the previously installed version. --- GNUmakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index bcdc6e7..25122be 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -22,7 +22,8 @@ specl_verbose_1 = --verbose --formatter=report include Makefile -MKROCKSPECS = $(ROCKSPEC_ENV) $(LUA) $(srcdir)/mkrockspecs.lua +ROCKSPEC_ENV = $(LUA_ENV) +MKROCKSPECS = $(ROCKSPEC_ENV) $(LUA) $(srcdir)/mkrockspecs.lua ROCKSPEC_TEMPLATE = $(srcdir)/$(PACKAGE)-rockspec.lua luarocks-config.lua: From 902aa01a7421d8ac49dce721e1545814e7939b6a Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Tue, 26 Mar 2013 10:57:58 +0700 Subject: [PATCH 2/7] rockspecs: bump revision number to 2. * mkrockspecs.lua: Bump revision number to 2. --- mkrockspecs.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkrockspecs.lua b/mkrockspecs.lua index ee3e80b..b2a77ae 100644 --- a/mkrockspecs.lua +++ b/mkrockspecs.lua @@ -32,7 +32,7 @@ end for f, spec in pairs (loadfile ("rockspecs.lua") ()) do if f ~= "default" then - local specfile = package_name.."-"..(f ~= "" and f:lower ().."-" or "")..version.."-1.rockspec" + local specfile = package_name.."-"..(f ~= "" and f:lower ().."-" or "")..version.."-2.rockspec" h = io.open (specfile, "w") assert (h) flavour = f -- a global, visible in loadfile From 1788c3c2705ff00469717cfb53df107652a2f629 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Tue, 26 Mar 2013 22:26:51 +0000 Subject: [PATCH 3/7] getopt: instead of parsing undefined options, stop at first non-option This is a configurable behaviour in C getopt, and does what I actually wanted in the first place. If the other behaviour has a use case, it can be reinstated later. --- specs/getopt_spec.yaml | 10 +++++----- src/getopt.lua | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/specs/getopt_spec.yaml b/specs/getopt_spec.yaml index 006d9cd..94bfe5c 100644 --- a/specs/getopt_spec.yaml +++ b/specs/getopt_spec.yaml @@ -12,8 +12,8 @@ specify getopt: } } - function test (cmdLine, undefined_opts) - local nonOpts, opts, errors = getopt.getOpt (cmdLine, prog.options, undefined_opts) + function test (cmdLine, stop_at_nonopt) + local nonOpts, opts, errors = getopt.getOpt (cmdLine, prog.options, stop_at_nonopt) if #errors == 0 then return { options = opts, args = nonOpts } else @@ -35,9 +35,9 @@ specify getopt: args = {} }) - it diagnoses unrecognized options: expect (test {"-foo"}).should_contain "unrecognized option `-foo'" - - it allows unrecognized options if told to: - expect (test ({"-foo"}, true)).should_equal ( - { options = { foo = {1}}, args = {} }) + - it stops option parsing at the first non-option if told to: + expect (test ({"foo", "-bar"}, true)).should_equal ( + { options = {}, args = {"foo", "-bar"} }) - "describe getopt.usageInfo": - context when specifying options: diff --git a/src/getopt.lua b/src/getopt.lua index 2042f15..d0ffb26 100644 --- a/src/getopt.lua +++ b/src/getopt.lua @@ -44,11 +44,11 @@ local M = { --- Perform argument processing -- @param argIn list of command-line args -- @param options options table --- @param undefined_options if true, allow and collect undefined options +-- @param stop_at_nonopt if true, stop option processing at first non-option -- @return table of remaining non-options -- @return table of option key-value list pairs -- @return table of error messages -local function getOpt (argIn, options, undefined_options) +local function getOpt (argIn, options, stop_at_nonopt) local noProcess = nil local argOut, optOut, errors = {[0] = argIn[0]}, {}, {} -- get an argument for option opt @@ -74,7 +74,7 @@ local function getOpt (argIn, options, undefined_options) local function parseOpt (opt, arg) local o = options.name[opt] - if undefined_options or o ~= nil then + if o ~= nil then o = o or {name = {opt}} optOut[o.name[1]] = optOut[o.name[1]] or {} table.insert (optOut[o.name[1]], getArg (o, opt, arg, optOut[o.name[1]])) @@ -87,9 +87,12 @@ local function getOpt (argIn, options, undefined_options) table.remove (argIn, 1) local _, _, dash, opt = string.find (v, "^(%-%-?)([^=-][^=]*)") local _, _, arg = string.find (v, "=(.*)$") + if not dash and stop_at_nonopt then + noProcess = true + end if v == "--" then - noProcess = 1 - elseif dash == nil or noProcess then -- non-option + noProcess = true + elseif not dash or noProcess then -- non-option table.insert (argOut, v) else -- option parseOpt (opt, arg) @@ -242,12 +245,12 @@ end -- stops program if there was an error, or if --help or -- --version was used. -- @param prog table of named parameters --- @param undefined_opts if true, allow and collect undefined options -local function processArgs (prog, undefined_opts) +-- @param ... extra arguments for getOpt +local function processArgs (prog, ...) local totArgs = #arg local errors prog.options = makeOptions (prog.options) - _G.arg, M.opt, errors = getOpt (arg, prog.options, undefined_opts) + _G.arg, M.opt, errors = getOpt (arg, prog.options, ...) local opt = M.opt if (opt.version or opt.help) and prog.banner then io.writelines (prog.banner) From 24b04ce87df72b74f7329a846b25e9f3bd41c389 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Tue, 26 Mar 2013 22:31:03 +0000 Subject: [PATCH 4/7] rockspecs.lua: bump rockspec version for branch --- rockspecs.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rockspecs.lua b/rockspecs.lua index 8f203f8..f063397 100644 --- a/rockspecs.lua +++ b/rockspecs.lua @@ -9,7 +9,7 @@ local version_dashed = version:gsub ("%.", "-") local default = { package = package_name, - version = version.."-1", + version = version.."-2", source = { url = "git://github.com/rrthomas/lua-stdlib.git", }, From 55ba69942ddbfa1a4ded55f17eade64c9c2c52a7 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 29 Mar 2013 11:28:31 +0700 Subject: [PATCH 5/7] getopt: ensure we find _G.arg from Specl nested setfenv environments. (issue #27) Although only necessary for Lua 5.1, this fix is harmless for Lua 5.2, and we support both! * src/getopt.lua (processArgs): Use only fully qualified _G.arg references, for Lua 5.1 Specl compatibility. Fixes issue #27. --- src/getopt.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/getopt.lua b/src/getopt.lua index d0ffb26..d67c8a2 100644 --- a/src/getopt.lua +++ b/src/getopt.lua @@ -247,10 +247,10 @@ end -- @param prog table of named parameters -- @param ... extra arguments for getOpt local function processArgs (prog, ...) - local totArgs = #arg + local totArgs = #_G.arg local errors prog.options = makeOptions (prog.options) - _G.arg, M.opt, errors = getOpt (arg, prog.options, ...) + _G.arg, M.opt, errors = getOpt (_G.arg, prog.options, ...) local opt = M.opt if (opt.version or opt.help) and prog.banner then io.writelines (prog.banner) From c9f07e87367d1dc879b7dfaa2a1b0276ec844e76 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 29 Mar 2013 12:05:14 +0700 Subject: [PATCH 6/7] configury: bump revision to 2 in release rules. * GNUmakefile (tag-release, check-in-release, release): Bump release revision to 2. --- GNUmakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 25122be..4a84f93 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -42,7 +42,7 @@ GIT ?= git tag-release: $(GIT) diff --exit-code && \ - $(GIT) tag -f -a -m "Release tag" v$(VERSION) + $(GIT) tag -f -a -m "Release tag" v$(VERSION)-2 define unpack-distcheck-release rm -rf $(PACKAGE)-$(VERSION)/ && \ @@ -59,8 +59,8 @@ check-in-release: distcheck cd ../$(PACKAGE)-release && \ $(unpack-distcheck-release) && \ $(GIT) add . && \ - $(GIT) commit -a -m "Release v$(VERSION)" && \ - $(GIT) tag -f -a -m "Full source release tag" release-v$(VERSION) + $(GIT) commit -a -m "Release v$(VERSION)-2" && \ + $(GIT) tag -f -a -m "Full source release tag" release-v$(VERSION)-2 ## To test the release process without publishing upstream, use: @@ -76,7 +76,7 @@ release: rockspecs $(MAKE) check-in-release && \ $(GIT_PUBLISH) push && $(GIT_PUBLISH) push --tags && \ LUAROCKS_CONFIG=$(abs_srcdir)/luarocks-config.lua luarocks \ - --tree=$(abs_srcdir)/luarocks build $(PACKAGE)-$(VERSION)-1.rockspec && \ + --tree=$(abs_srcdir)/luarocks build $(PACKAGE)-$(VERSION)-2.rockspec && \ $(WOGER) lua \ package=$(PACKAGE) \ package_name=$(PACKAGE_NAME) \ From 24bedbfc5c8ad97de1b8dddfdc62df326853fb04 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Mon, 1 Apr 2013 15:02:52 +0700 Subject: [PATCH 7/7] maint: revert to `-1` rockspec revisions number. * configure.ac (AC_INIT): Bump version to 34.1. * rockspecs.lua: Revert to `-1` rockspec revision number. * mkrockspecs.lua (specfile): Likewise. * GNUmakefile (tag-release, check-in-release): Don't apply -2 suffix. (release): Use -1 revision rockspec filename. --- GNUmakefile | 8 ++++---- configure.ac | 2 +- mkrockspecs.lua | 2 +- rockspecs.lua | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 4a84f93..25122be 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -42,7 +42,7 @@ GIT ?= git tag-release: $(GIT) diff --exit-code && \ - $(GIT) tag -f -a -m "Release tag" v$(VERSION)-2 + $(GIT) tag -f -a -m "Release tag" v$(VERSION) define unpack-distcheck-release rm -rf $(PACKAGE)-$(VERSION)/ && \ @@ -59,8 +59,8 @@ check-in-release: distcheck cd ../$(PACKAGE)-release && \ $(unpack-distcheck-release) && \ $(GIT) add . && \ - $(GIT) commit -a -m "Release v$(VERSION)-2" && \ - $(GIT) tag -f -a -m "Full source release tag" release-v$(VERSION)-2 + $(GIT) commit -a -m "Release v$(VERSION)" && \ + $(GIT) tag -f -a -m "Full source release tag" release-v$(VERSION) ## To test the release process without publishing upstream, use: @@ -76,7 +76,7 @@ release: rockspecs $(MAKE) check-in-release && \ $(GIT_PUBLISH) push && $(GIT_PUBLISH) push --tags && \ LUAROCKS_CONFIG=$(abs_srcdir)/luarocks-config.lua luarocks \ - --tree=$(abs_srcdir)/luarocks build $(PACKAGE)-$(VERSION)-2.rockspec && \ + --tree=$(abs_srcdir)/luarocks build $(PACKAGE)-$(VERSION)-1.rockspec && \ $(WOGER) lua \ package=$(PACKAGE) \ package_name=$(PACKAGE_NAME) \ diff --git a/configure.ac b/configure.ac index 966b5d6..86de659 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script dnl Initialise autoconf and automake -AC_INIT(stdlib, 34, rrt@sc3d.org) +AC_INIT(stdlib, 34.1, rrt@sc3d.org) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign]) AM_SILENT_RULES([yes]) diff --git a/mkrockspecs.lua b/mkrockspecs.lua index b2a77ae..ee3e80b 100644 --- a/mkrockspecs.lua +++ b/mkrockspecs.lua @@ -32,7 +32,7 @@ end for f, spec in pairs (loadfile ("rockspecs.lua") ()) do if f ~= "default" then - local specfile = package_name.."-"..(f ~= "" and f:lower ().."-" or "")..version.."-2.rockspec" + local specfile = package_name.."-"..(f ~= "" and f:lower ().."-" or "")..version.."-1.rockspec" h = io.open (specfile, "w") assert (h) flavour = f -- a global, visible in loadfile diff --git a/rockspecs.lua b/rockspecs.lua index f063397..8f203f8 100644 --- a/rockspecs.lua +++ b/rockspecs.lua @@ -9,7 +9,7 @@ local version_dashed = version:gsub ("%.", "-") local default = { package = package_name, - version = version.."-2", + version = version.."-1", source = { url = "git://github.com/rrthomas/lua-stdlib.git", },