luajit require("file") and table.concat issue

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

luajit require("file") and table.concat issue

This post has NOT been accepted by the mailing list yet.
Sorry for my poorly english, I just try to report my problem when using the latest luajit. This is first time I post here, hope your guys can understand it.

Demo code as loading lua51.dll by dllcall.

    handle := DllCall("LoadLibrary", "Str", "lua51.dll")
    L := DllCall("lua51\luaL_newstate", "Cdecl")
    DllCall("lua51\luaL_openlibs", "Ptr", L, "Cdecl")
    DllCall("lua51\luaL_loadfile", "Ptr", L, "AStr", "main.lua", "Cdecl Int")
    DllCall("lua51\lua_pcall", "Ptr", L, "Int", 0, "Int", 0, "Ptr", 0, "Cdecl")

    /* we want to close it now*/
    DllCall("lua51\lua_close", "Ptr", L, "Cdecl")
    DllCall("FreeLibrary", "Ptr", handle )
    /* The lua51.dll is still in use in latest luajit(in win7 sp1 and xp sp3)*/

The content of Main.lua is:

    require "sth"    -- require sth.lua, this cause the problem. No matter what the content of sth.lua, even is empty.
    require "ffi"  -- no problem when we load internal lib.

About table.concat, It just broken recently, I still use the 10.14 version with no problem.

    local concat = table.concat
    function tableToJson (s, ic)
        if not ic and type(s) ~= "table" then return s end
        local l = {}
        for k, v in pairs(s) do
            if type(v) == "table" then
                l[#l+1] = k .. ":".. tableToJson (v, true)
                l[#l+1] = k .. ':"' .. tostring(v) .. '"'
        if #l >0 then
            return "{" .. concat(l, ",") .. "}"
            return "{}"

This function may generate truncated result in some situation, and stop me from using the latest git-head version.