Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix use of arg in ltn12 #24

Merged
merged 1 commit into from

3 participants

@catwell

arg is not part of Lua 5.1 and hence no longer works in Lua 5.2 or LuaJIT with its default compilation options.

Note that arg is apparently used in other parts of the codebase, but I have only hit this issue in ltn12 so far. If you think this fix is correct I can git a try at hunting use of arg in other places.

@catwell catwell referenced this pull request in sam-github/luasocket
Closed

fix use of arg in ltn12 #1

@diegonehab
Owner

The alternative would be to use the select function, which may be more efficient. On the other hand, these functions are not performance critical, so I am merging the request.

@diegonehab diegonehab merged commit 114080d into diegonehab:unstable
@catwell

Awesome, thank you!

@sbernard31

Hi,
Remove all the reference to arg would be nice.

Will luasocket 2.1 will be compatible with Lua 5.1 ? Or will luasocket 2.1 be only for Lua 5.2 and luasocket 2.0 is only for Lua 5.1 ?
In the second case, it could be nice to backport those fixes on luasocket 2.0 maintenance branch.
Because, arg is deprecated in Lua 5.1 and not present in LuaJIT 2.0 (which is a Lua 5.1 VM)

@catwell

@sbernard31 This is precisely what this commit fixes.

EDIT: Oh, sorry, maybe I misread you. I think that, even if v2.0 doesn't support Lua 5.2, v2.1 will be usable on all versions (5.1, 5.2 and LuaJIT), right @diegonehab ?

@sbernard31

When I say

Remove all the reference to arg would be nice.

I mean remove all the references of arg in the whole codebase, not only in the ltn12 file.

You said :

Note that arg is apparently used in other parts of the codebase, but I have only hit this issue in ltn12 so far. If you think this fix is correct I can git a try at hunting use of arg in other places.

So I understood that this problem occur in other files, that's right ?

For the second point, if you are right, it's a good news :).

@catwell catwell referenced this pull request
Merged

fix more uses of arg #27

@catwell

OK, see above :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 17, 2012
  1. @catwell

    fix use of arg in ltn12

    catwell authored
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/ltn12.lua
View
4 src/ltn12.lua
@@ -37,7 +37,8 @@ end
-- chains a bunch of filters together
-- (thanks to Wim Couwenberg)
function filter.chain(...)
- local n = table.getn(arg)
+ local arg = {...}
+ local n = #arg
local top, index = 1, 1
local retry = ""
return function(chunk)
@@ -185,6 +186,7 @@ end
-- other, as if they were concatenated
-- (thanks to Wim Couwenberg)
function source.cat(...)
+ local arg = {...}
local src = table.remove(arg, 1)
return function()
while src do
Something went wrong with that request. Please try again.