diff options
Diffstat (limited to 'src/lanes.lua')
-rw-r--r-- | src/lanes.lua | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/src/lanes.lua b/src/lanes.lua index 90f9cd2..6a4f149 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -222,23 +222,25 @@ end | |||
222 | 222 | ||
223 | local valid_libs = | 223 | local valid_libs = |
224 | { | 224 | { |
225 | ["package"] = true, | 225 | ["base"] = true, |
226 | ["table"] = true, | 226 | ["bit"] = true, |
227 | ["bit32"] = true, | ||
228 | ["coroutine"] = true, | ||
229 | ["debug"] = true, | ||
230 | ["ffi"] = true, | ||
227 | ["io"] = true, | 231 | ["io"] = true, |
232 | ["jit"] = true, | ||
233 | ["math"] = true, | ||
228 | ["os"] = true, | 234 | ["os"] = true, |
235 | ["package"] = true, | ||
229 | ["string"] = true, | 236 | ["string"] = true, |
230 | ["math"] = true, | 237 | ["table"] = true, |
231 | ["debug"] = true, | 238 | ["utf8"] = true, |
232 | ["bit32"] = true, -- Lua 5.2 only, ignored silently under 5.1 | ||
233 | ["utf8"] = true, -- Lua 5.3 only, ignored silently under 5.1 and 5.2 | ||
234 | ["bit"] = true, -- LuaJIT only, ignored silently under PUC-Lua | ||
235 | ["jit"] = true, -- LuaJIT only, ignored silently under PUC-Lua | ||
236 | ["ffi"] = true, -- LuaJIT only, ignored silently under PUC-Lua | ||
237 | -- | 239 | -- |
238 | ["base"] = true, | ||
239 | ["coroutine"] = true, -- part of "base" in Lua 5.1 | ||
240 | ["lanes.core"] = true | 240 | ["lanes.core"] = true |
241 | } | 241 | } |
242 | -- same structure, but contains only the libraries that the current Lua flavor actually supports | ||
243 | local supported_libs | ||
242 | 244 | ||
243 | -- ################################################################################################# | 245 | -- ################################################################################################# |
244 | 246 | ||
@@ -375,14 +377,17 @@ local gen = function(...) | |||
375 | error "Libs specification '*' must be used alone" | 377 | error "Libs specification '*' must be used alone" |
376 | end | 378 | end |
377 | local found = {} | 379 | local found = {} |
378 | for s in string_gmatch(libs, "[%a%d.]+") do | 380 | -- accept lib identifiers followed by an optional question mark |
381 | for s, question in string_gmatch(libs, "([%a%d.]+)(%??)") do | ||
379 | if not valid_libs[s] then | 382 | if not valid_libs[s] then |
380 | error("Bad library name: " .. s, 2) | 383 | error("Bad library name: " .. string_format("%q", tostring(s)), 2) |
381 | else | 384 | end |
382 | found[s] = (found[s] or 0) + 1 | 385 | if question == '' and not supported_libs[s] then |
383 | if found[s] > 1 then | 386 | error("Unsupported library: " .. string_format("%q", tostring(s)), 2) |
384 | error("Libs specification contains '" .. s .. "' more than once", 2) | 387 | end |
385 | end | 388 | found[s] = (found[s] or 0) + 1 |
389 | if found[s] > 1 then | ||
390 | error("Libs specification contains " .. string_format("%q", tostring(s)) .. " more than once", 2) | ||
386 | end | 391 | end |
387 | end | 392 | end |
388 | end | 393 | end |
@@ -810,6 +815,11 @@ local configure = function(settings_) | |||
810 | lanes.configure = function() return lanes end -- no need to configure anything again | 815 | lanes.configure = function() return lanes end -- no need to configure anything again |
811 | 816 | ||
812 | -- now we can configure Lanes core | 817 | -- now we can configure Lanes core |
818 | |||
819 | |||
820 | |||
821 | |||
822 | |||
813 | local settings = core.configure and core.configure(params_checker(settings_)) or core.settings | 823 | local settings = core.configure and core.configure(params_checker(settings_)) or core.settings |
814 | 824 | ||
815 | -- | 825 | -- |
@@ -825,6 +835,7 @@ local configure = function(settings_) | |||
825 | -- avoid pulling the whole core module as upvalue when cancel_error is enough | 835 | -- avoid pulling the whole core module as upvalue when cancel_error is enough |
826 | -- these are locals declared above, that we need to set prior to calling configure_timers() | 836 | -- these are locals declared above, that we need to set prior to calling configure_timers() |
827 | cancel_error = assert(core.cancel_error) | 837 | cancel_error = assert(core.cancel_error) |
838 | supported_libs = assert(core.supported_libs()) | ||
828 | timerLinda = assert(core.timerLinda) | 839 | timerLinda = assert(core.timerLinda) |
829 | 840 | ||
830 | if settings.with_timers then | 841 | if settings.with_timers then |