Ejemplo n.º 1
0
        static int pmain(LuaState L)
        {
            Smain s    = (Smain)Lua.LuaToUserData(L, 1);
            int   argc = s.argc;

            string[]  argv = s.argv;
            Lua.Proto f;
            int       i;

            if (Lua.LuaCheckStack(L, argc) == 0)
            {
                fatal("too many input files");
            }
            for (i = 0; i < argc; i++)
            {
                CharPtr filename = (Lua.strcmp(argv[i], "-") == 0) ? null : argv[i];
                if (Lua.LuaLLoadFile(L, filename) != 0)
                {
                    fatal(Lua.LuaToString(L, -1));
                }
            }
            f = combine(L, argc);
            if (listing != 0)
            {
                Lua.luaU_print(f, (listing > 1)?1:0);
            }
            if (dumping != 0)
            {
                Stream D = (output == null) ? Lua.stdout : Lua.fopen(output, "wb");
                if (D == null)
                {
                    cannot("open");
                }
                Lua.LuaLock(L);
                Lua.LuaUDump(L, f, writer, D, stripping);
                Lua.LuaUnlock(L);
                if (Lua.ferror(D) != 0)
                {
                    cannot("write");
                }
                if (Lua.fclose(D) != 0)
                {
                    cannot("close");
                }
            }
            return(0);
        }