Exemplo n.º 1
0
        static int loadline(Lua.LuaState L)
        {
            int status;

            Lua.lua_settop(L, 0);
            if (pushline(L, 1) == 0)
            {
                return(-1);  /* no input */
            }
            for (; ;)
            {  /* repeat until gets a complete line */
                status = Lua.luaL_loadbuffer(L, Lua.lua_tostring(L, 1), Lua.lua_strlen(L, 1), "=stdin");
                if (incomplete(L, status) == 0)
                {
                    break;                /* cannot try to add lines? */
                }
                if (pushline(L, 0) == 0)  /* no more input? */
                {
                    return(-1);
                }
                Lua.lua_pushliteral(L, "\n"); /* add a new line... */
                Lua.lua_insert(L, -2);        /* ...between the two lines */
                Lua.lua_concat(L, 3);         /* join them */
            }
            Lua.lua_saveline(L, 1);
            Lua.lua_remove(L, 1);  /* remove line */
            return(status);
        }
Exemplo n.º 2
0
        static int dostring(Lua.LuaState L, Lua.CharPtr s, Lua.CharPtr name)
        {
            int status = (Lua.luaL_loadbuffer(L, s, (uint)Lua.strlen(s), name) != 0) || (docall(L, 0, 1) != 0) ? 1 : 0;

            return(report(L, status));
        }