|
20 | 20 | #include "lauxlib.h" |
21 | 21 | #include "lualib.h" |
22 | 22 |
|
23 | | - |
24 | | -static int luaB_print (lua_State *L) { |
25 | | - int n = lua_gettop(L); /* number of arguments */ |
26 | | - int i; |
27 | | - lua_getglobal(L, "tostring"); |
28 | | - for (i=1; i<=n; i++) { |
29 | | - const char *s; |
30 | | - size_t l; |
31 | | - lua_pushvalue(L, -1); /* function to be called */ |
32 | | - lua_pushvalue(L, i); /* value to print */ |
33 | | - lua_call(L, 1, 1); |
34 | | - s = lua_tolstring(L, -1, &l); /* get result */ |
35 | | - if (s == NULL) |
36 | | - return luaL_error(L, "'tostring' must return a string to 'print'"); |
37 | | - if (i>1) lua_writestring("\t", 1); |
38 | | - lua_writestring(s, l); |
39 | | - lua_pop(L, 1); /* pop result */ |
40 | | - } |
41 | | - lua_writeline(); |
42 | | - return 0; |
43 | | -} |
44 | | - |
45 | | - |
46 | 23 | #define SPACECHARS " \f\n\r\t\v" |
47 | 24 |
|
48 | 25 | static const char *b_str2int (const char *s, int base, lua_Integer *pn) { |
@@ -283,16 +260,6 @@ static int load_aux (lua_State *L, int status, int envidx) { |
283 | 260 | } |
284 | 261 | } |
285 | 262 |
|
286 | | - |
287 | | -static int luaB_loadfile (lua_State *L) { |
288 | | - const char *fname = luaL_optstring(L, 1, NULL); |
289 | | - const char *mode = luaL_optstring(L, 2, NULL); |
290 | | - int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */ |
291 | | - int status = luaL_loadfilex(L, fname, mode); |
292 | | - return load_aux(L, status, env); |
293 | | -} |
294 | | - |
295 | | - |
296 | 263 | /* |
297 | 264 | ** {====================================================== |
298 | 265 | ** Generic Read function |
@@ -353,22 +320,6 @@ static int luaB_load (lua_State *L) { |
353 | 320 | /* }====================================================== */ |
354 | 321 |
|
355 | 322 |
|
356 | | -static int dofilecont (lua_State *L, int d1, lua_KContext d2) { |
357 | | - (void)d1; (void)d2; /* only to match 'lua_Kfunction' prototype */ |
358 | | - return lua_gettop(L) - 1; |
359 | | -} |
360 | | - |
361 | | - |
362 | | -static int luaB_dofile (lua_State *L) { |
363 | | - const char *fname = luaL_optstring(L, 1, NULL); |
364 | | - lua_settop(L, 1); |
365 | | - if (luaL_loadfile(L, fname) != LUA_OK) |
366 | | - return lua_error(L); |
367 | | - lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); |
368 | | - return dofilecont(L, 0, 0); |
369 | | -} |
370 | | - |
371 | | - |
372 | 323 | static int luaB_assert (lua_State *L) { |
373 | 324 | if (lua_toboolean(L, 1)) /* condition is true? */ |
374 | 325 | return lua_gettop(L); /* return all arguments */ |
@@ -453,19 +404,16 @@ static int luaB_tostring (lua_State *L) { |
453 | 404 | static const luaL_Reg base_funcs[] = { |
454 | 405 | {"assert", luaB_assert}, |
455 | 406 | {"collectgarbage", luaB_collectgarbage}, |
456 | | - {"dofile", luaB_dofile}, |
457 | 407 | {"error", luaB_error}, |
458 | 408 | {"getmetatable", luaB_getmetatable}, |
459 | 409 | {"ipairs", luaB_ipairs}, |
460 | | - {"loadfile", luaB_loadfile}, |
461 | 410 | {"load", luaB_load}, |
462 | 411 | #if defined(LUA_COMPAT_LOADSTRING) |
463 | 412 | {"loadstring", luaB_load}, |
464 | 413 | #endif |
465 | 414 | {"next", luaB_next}, |
466 | 415 | {"pairs", luaB_pairs}, |
467 | 416 | {"pcall", luaB_pcall}, |
468 | | - {"print", luaB_print}, |
469 | 417 | {"rawequal", luaB_rawequal}, |
470 | 418 | {"rawlen", luaB_rawlen}, |
471 | 419 | {"rawget", luaB_rawget}, |
|
0 commit comments