liolib.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /*
  2. ** $Id: liolib.c,v 2.116 2014/02/21 14:39:50 roberto Exp roberto $
  3. ** Standard I/O (and system) library
  4. ** See Copyright Notice in lua.h
  5. */
  6. /*
  7. ** This definition must come before the inclusion of 'stdio.h'; it
  8. ** should not affect non-POSIX systems
  9. */
  10. #if !defined(_FILE_OFFSET_BITS)
  11. #define _LARGEFILE_SOURCE 1
  12. #define _FILE_OFFSET_BITS 64
  13. #endif
  14. #include <errno.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #define liolib_c
  19. #define LUA_LIB
  20. #include "lua.h"
  21. #include "lauxlib.h"
  22. #include "lualib.h"
  23. #if !defined(lua_checkmode)
  24. /*
  25. ** Check whether 'mode' matches '[rwa]%+?b?'.
  26. ** Change this macro to accept other modes for 'fopen' besides
  27. ** the standard ones.
  28. */
  29. #define lua_checkmode(mode) \
  30. (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \
  31. (*mode != '+' || ++mode) && /* skip if char is '+' */ \
  32. (*mode != 'b' || ++mode) && /* skip if char is 'b' */ \
  33. (*mode == '\0'))
  34. #endif
  35. /*
  36. ** {======================================================
  37. ** lua_popen spawns a new process connected to the current
  38. ** one through the file streams.
  39. ** =======================================================
  40. */
  41. #if !defined(lua_popen) /* { */
  42. #if defined(LUA_USE_POSIX) /* { */
  43. #define lua_popen(L,c,m) (fflush(NULL), popen(c,m))
  44. #define lua_pclose(L,file) (pclose(file))
  45. #elif defined(LUA_WIN) /* }{ */
  46. #define lua_popen(L,c,m) (_popen(c,m))
  47. #define lua_pclose(L,file) (_pclose(file))
  48. #else /* }{ */
  49. /* ANSI definitions */
  50. #define lua_popen(L,c,m) \
  51. ((void)((void)c, m), \
  52. luaL_error(L, LUA_QL("popen") " not supported"), \
  53. (FILE*)0)
  54. #define lua_pclose(L,file) ((void)((void)L, file), -1)
  55. #endif /* } */
  56. #endif /* } */
  57. /* }====================================================== */
  58. /*
  59. ** {======================================================
  60. ** lua_fseek: configuration for longer offsets
  61. ** =======================================================
  62. */
  63. #if !defined(lua_fseek) /* { */
  64. #if defined(LUA_USE_POSIX) /* { */
  65. #define l_fseek(f,o,w) fseeko(f,o,w)
  66. #define l_ftell(f) ftello(f)
  67. #define l_seeknum off_t
  68. #elif defined(LUA_WIN) && !defined(_CRTIMP_TYPEINFO) \
  69. && defined(_MSC_VER) && (_MSC_VER >= 1400) /* }{ */
  70. /* Windows (but not DDK) and Visual C++ 2005 or higher */
  71. #define l_fseek(f,o,w) _fseeki64(f,o,w)
  72. #define l_ftell(f) _ftelli64(f)
  73. #define l_seeknum __int64
  74. #else /* }{ */
  75. /* ANSI definitions */
  76. #define l_fseek(f,o,w) fseek(f,o,w)
  77. #define l_ftell(f) ftell(f)
  78. #define l_seeknum long
  79. #endif /* } */
  80. #endif /* } */
  81. /* }====================================================== */
  82. #define IO_PREFIX "_IO_"
  83. #define IO_INPUT (IO_PREFIX "input")
  84. #define IO_OUTPUT (IO_PREFIX "output")
  85. typedef luaL_Stream LStream;
  86. #define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
  87. #define isclosed(p) ((p)->closef == NULL)
  88. static int io_type (lua_State *L) {
  89. LStream *p;
  90. luaL_checkany(L, 1);
  91. p = (LStream *)luaL_testudata(L, 1, LUA_FILEHANDLE);
  92. if (p == NULL)
  93. lua_pushnil(L); /* not a file */
  94. else if (isclosed(p))
  95. lua_pushliteral(L, "closed file");
  96. else
  97. lua_pushliteral(L, "file");
  98. return 1;
  99. }
  100. static int f_tostring (lua_State *L) {
  101. LStream *p = tolstream(L);
  102. if (isclosed(p))
  103. lua_pushliteral(L, "file (closed)");
  104. else
  105. lua_pushfstring(L, "file (%p)", p->f);
  106. return 1;
  107. }
  108. static FILE *tofile (lua_State *L) {
  109. LStream *p = tolstream(L);
  110. if (isclosed(p))
  111. luaL_error(L, "attempt to use a closed file");
  112. lua_assert(p->f);
  113. return p->f;
  114. }
  115. /*
  116. ** When creating file handles, always creates a `closed' file handle
  117. ** before opening the actual file; so, if there is a memory error, the
  118. ** file is not left opened.
  119. */
  120. static LStream *newprefile (lua_State *L) {
  121. LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream));
  122. p->closef = NULL; /* mark file handle as 'closed' */
  123. luaL_setmetatable(L, LUA_FILEHANDLE);
  124. return p;
  125. }
  126. static int aux_close (lua_State *L) {
  127. LStream *p = tolstream(L);
  128. lua_CFunction cf = p->closef;
  129. p->closef = NULL; /* mark stream as closed */
  130. return (*cf)(L); /* close it */
  131. }
  132. static int io_close (lua_State *L) {
  133. if (lua_isnone(L, 1)) /* no argument? */
  134. lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */
  135. tofile(L); /* make sure argument is an open stream */
  136. return aux_close(L);
  137. }
  138. static int f_gc (lua_State *L) {
  139. LStream *p = tolstream(L);
  140. if (!isclosed(p) && p->f != NULL)
  141. aux_close(L); /* ignore closed and incompletely open files */
  142. return 0;
  143. }
  144. /*
  145. ** function to close regular files
  146. */
  147. static int io_fclose (lua_State *L) {
  148. LStream *p = tolstream(L);
  149. int res = fclose(p->f);
  150. return luaL_fileresult(L, (res == 0), NULL);
  151. }
  152. static LStream *newfile (lua_State *L) {
  153. LStream *p = newprefile(L);
  154. p->f = NULL;
  155. p->closef = &io_fclose;
  156. return p;
  157. }
  158. static void opencheck (lua_State *L, const char *fname, const char *mode) {
  159. LStream *p = newfile(L);
  160. p->f = fopen(fname, mode);
  161. if (p->f == NULL)
  162. luaL_error(L, "cannot open file " LUA_QS " (%s)", fname, strerror(errno));
  163. }
  164. static int io_open (lua_State *L) {
  165. const char *filename = luaL_checkstring(L, 1);
  166. const char *mode = luaL_optstring(L, 2, "r");
  167. LStream *p = newfile(L);
  168. const char *md = mode; /* to traverse/check mode */
  169. luaL_argcheck(L, lua_checkmode(md), 2, "invalid mode");
  170. p->f = fopen(filename, mode);
  171. return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
  172. }
  173. /*
  174. ** function to close 'popen' files
  175. */
  176. static int io_pclose (lua_State *L) {
  177. LStream *p = tolstream(L);
  178. return luaL_execresult(L, lua_pclose(L, p->f));
  179. }
  180. static int io_popen (lua_State *L) {
  181. const char *filename = luaL_checkstring(L, 1);
  182. const char *mode = luaL_optstring(L, 2, "r");
  183. LStream *p = newprefile(L);
  184. p->f = lua_popen(L, filename, mode);
  185. p->closef = &io_pclose;
  186. return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
  187. }
  188. static int io_tmpfile (lua_State *L) {
  189. LStream *p = newfile(L);
  190. p->f = tmpfile();
  191. return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1;
  192. }
  193. static FILE *getiofile (lua_State *L, const char *findex) {
  194. LStream *p;
  195. lua_getfield(L, LUA_REGISTRYINDEX, findex);
  196. p = (LStream *)lua_touserdata(L, -1);
  197. if (isclosed(p))
  198. luaL_error(L, "standard %s file is closed", findex + strlen(IO_PREFIX));
  199. return p->f;
  200. }
  201. static int g_iofile (lua_State *L, const char *f, const char *mode) {
  202. if (!lua_isnoneornil(L, 1)) {
  203. const char *filename = lua_tostring(L, 1);
  204. if (filename)
  205. opencheck(L, filename, mode);
  206. else {
  207. tofile(L); /* check that it's a valid file handle */
  208. lua_pushvalue(L, 1);
  209. }
  210. lua_setfield(L, LUA_REGISTRYINDEX, f);
  211. }
  212. /* return current value */
  213. lua_getfield(L, LUA_REGISTRYINDEX, f);
  214. return 1;
  215. }
  216. static int io_input (lua_State *L) {
  217. return g_iofile(L, IO_INPUT, "r");
  218. }
  219. static int io_output (lua_State *L) {
  220. return g_iofile(L, IO_OUTPUT, "w");
  221. }
  222. static int io_readline (lua_State *L);
  223. static void aux_lines (lua_State *L, int toclose) {
  224. int i;
  225. int n = lua_gettop(L) - 1; /* number of arguments to read */
  226. /* ensure that arguments will fit here and into 'io_readline' stack */
  227. luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options");
  228. lua_pushvalue(L, 1); /* file handle */
  229. lua_pushinteger(L, n); /* number of arguments to read */
  230. lua_pushboolean(L, toclose); /* close/not close file when finished */
  231. for (i = 1; i <= n; i++) lua_pushvalue(L, i + 1); /* copy arguments */
  232. lua_pushcclosure(L, io_readline, 3 + n);
  233. }
  234. static int f_lines (lua_State *L) {
  235. tofile(L); /* check that it's a valid file handle */
  236. aux_lines(L, 0);
  237. return 1;
  238. }
  239. static int io_lines (lua_State *L) {
  240. int toclose;
  241. if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */
  242. if (lua_isnil(L, 1)) { /* no file name? */
  243. lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT); /* get default input */
  244. lua_replace(L, 1); /* put it at index 1 */
  245. tofile(L); /* check that it's a valid file handle */
  246. toclose = 0; /* do not close it after iteration */
  247. }
  248. else { /* open a new file */
  249. const char *filename = luaL_checkstring(L, 1);
  250. opencheck(L, filename, "r");
  251. lua_replace(L, 1); /* put file at index 1 */
  252. toclose = 1; /* close it after iteration */
  253. }
  254. aux_lines(L, toclose);
  255. return 1;
  256. }
  257. /*
  258. ** {======================================================
  259. ** READ
  260. ** =======================================================
  261. */
  262. static int read_integer (lua_State *L, FILE *f) {
  263. lua_Integer d;
  264. if (fscanf(f, LUA_INTEGER_SCAN, &d) == 1) {
  265. lua_pushinteger(L, d);
  266. return 1;
  267. }
  268. else {
  269. lua_pushnil(L); /* "result" to be removed */
  270. return 0; /* read fails */
  271. }
  272. }
  273. static int read_number (lua_State *L, FILE *f) {
  274. lua_Number d;
  275. if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
  276. lua_pushnumber(L, d);
  277. return 1;
  278. }
  279. else {
  280. lua_pushnil(L); /* "result" to be removed */
  281. return 0; /* read fails */
  282. }
  283. }
  284. static int test_eof (lua_State *L, FILE *f) {
  285. int c = getc(f);
  286. ungetc(c, f); /* no-op when c == EOF */
  287. lua_pushlstring(L, NULL, 0);
  288. return (c != EOF);
  289. }
  290. static int read_line (lua_State *L, FILE *f, int chop) {
  291. luaL_Buffer b;
  292. luaL_buffinit(L, &b);
  293. for (;;) {
  294. size_t l;
  295. char *p = luaL_prepbuffer(&b);
  296. if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */
  297. luaL_pushresult(&b); /* close buffer */
  298. return (lua_rawlen(L, -1) > 0); /* check whether read something */
  299. }
  300. l = strlen(p);
  301. if (l == 0 || p[l-1] != '\n')
  302. luaL_addsize(&b, l);
  303. else {
  304. luaL_addsize(&b, l - chop); /* chop 'eol' if needed */
  305. luaL_pushresult(&b); /* close buffer */
  306. return 1; /* read at least an `eol' */
  307. }
  308. }
  309. }
  310. static void read_all (lua_State *L, FILE *f) {
  311. size_t nr;
  312. luaL_Buffer b;
  313. luaL_buffinit(L, &b);
  314. do { /* read file in chunks of LUAL_BUFFERSIZE bytes */
  315. char *p = luaL_prepbuffsize(&b, LUAL_BUFFERSIZE);
  316. nr = fread(p, sizeof(char), LUAL_BUFFERSIZE, f);
  317. luaL_addsize(&b, nr);
  318. } while (nr == LUAL_BUFFERSIZE);
  319. luaL_pushresult(&b); /* close buffer */
  320. }
  321. static int read_chars (lua_State *L, FILE *f, size_t n) {
  322. size_t nr; /* number of chars actually read */
  323. char *p;
  324. luaL_Buffer b;
  325. luaL_buffinit(L, &b);
  326. p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */
  327. nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */
  328. luaL_addsize(&b, nr);
  329. luaL_pushresult(&b); /* close buffer */
  330. return (nr > 0); /* true iff read something */
  331. }
  332. static int g_read (lua_State *L, FILE *f, int first) {
  333. int nargs = lua_gettop(L) - 1;
  334. int success;
  335. int n;
  336. clearerr(f);
  337. if (nargs == 0) { /* no arguments? */
  338. success = read_line(L, f, 1);
  339. n = first+1; /* to return 1 result */
  340. }
  341. else { /* ensure stack space for all results and for auxlib's buffer */
  342. luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
  343. success = 1;
  344. for (n = first; nargs-- && success; n++) {
  345. if (lua_type(L, n) == LUA_TNUMBER) {
  346. size_t l = (size_t)lua_tointeger(L, n);
  347. success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
  348. }
  349. else {
  350. const char *p = lua_tostring(L, n);
  351. luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
  352. switch (p[1]) {
  353. case 'i': /* integer */
  354. success = read_integer(L, f);
  355. break;
  356. case 'n': /* number */
  357. success = read_number(L, f);
  358. break;
  359. case 'l': /* line */
  360. success = read_line(L, f, 1);
  361. break;
  362. case 'L': /* line with end-of-line */
  363. success = read_line(L, f, 0);
  364. break;
  365. case 'a': /* file */
  366. read_all(L, f); /* read entire file */
  367. success = 1; /* always success */
  368. break;
  369. default:
  370. return luaL_argerror(L, n, "invalid format");
  371. }
  372. }
  373. }
  374. }
  375. if (ferror(f))
  376. return luaL_fileresult(L, 0, NULL);
  377. if (!success) {
  378. lua_pop(L, 1); /* remove last result */
  379. lua_pushnil(L); /* push nil instead */
  380. }
  381. return n - first;
  382. }
  383. static int io_read (lua_State *L) {
  384. return g_read(L, getiofile(L, IO_INPUT), 1);
  385. }
  386. static int f_read (lua_State *L) {
  387. return g_read(L, tofile(L), 2);
  388. }
  389. static int io_readline (lua_State *L) {
  390. LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1));
  391. int i;
  392. int n = (int)lua_tointeger(L, lua_upvalueindex(2));
  393. if (isclosed(p)) /* file is already closed? */
  394. return luaL_error(L, "file is already closed");
  395. lua_settop(L , 1);
  396. for (i = 1; i <= n; i++) /* push arguments to 'g_read' */
  397. lua_pushvalue(L, lua_upvalueindex(3 + i));
  398. n = g_read(L, p->f, 2); /* 'n' is number of results */
  399. lua_assert(n > 0); /* should return at least a nil */
  400. if (!lua_isnil(L, -n)) /* read at least one value? */
  401. return n; /* return them */
  402. else { /* first result is nil: EOF or error */
  403. if (n > 1) { /* is there error information? */
  404. /* 2nd result is error message */
  405. return luaL_error(L, "%s", lua_tostring(L, -n + 1));
  406. }
  407. if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */
  408. lua_settop(L, 0);
  409. lua_pushvalue(L, lua_upvalueindex(1));
  410. aux_close(L); /* close it */
  411. }
  412. return 0;
  413. }
  414. }
  415. /* }====================================================== */
  416. static int g_write (lua_State *L, FILE *f, int arg) {
  417. int nargs = lua_gettop(L) - arg;
  418. int status = 1;
  419. for (; nargs--; arg++) {
  420. if (lua_type(L, arg) == LUA_TNUMBER) {
  421. /* optimization: could be done exactly as for strings */
  422. int len = lua_isinteger(L, arg)
  423. ? fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg))
  424. : fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg));
  425. status = status && (len > 0);
  426. }
  427. else {
  428. size_t l;
  429. const char *s = luaL_checklstring(L, arg, &l);
  430. status = status && (fwrite(s, sizeof(char), l, f) == l);
  431. }
  432. }
  433. if (status) return 1; /* file handle already on stack top */
  434. else return luaL_fileresult(L, status, NULL);
  435. }
  436. static int io_write (lua_State *L) {
  437. return g_write(L, getiofile(L, IO_OUTPUT), 1);
  438. }
  439. static int f_write (lua_State *L) {
  440. FILE *f = tofile(L);
  441. lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */
  442. return g_write(L, f, 2);
  443. }
  444. static int f_seek (lua_State *L) {
  445. static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
  446. static const char *const modenames[] = {"set", "cur", "end", NULL};
  447. FILE *f = tofile(L);
  448. int op = luaL_checkoption(L, 2, "cur", modenames);
  449. lua_Number p3 = luaL_optnumber(L, 3, 0);
  450. l_seeknum offset = (l_seeknum)p3;
  451. luaL_argcheck(L, (lua_Number)offset == p3, 3,
  452. "not an integer in proper range");
  453. op = l_fseek(f, offset, mode[op]);
  454. if (op)
  455. return luaL_fileresult(L, 0, NULL); /* error */
  456. else {
  457. lua_pushnumber(L, (lua_Number)l_ftell(f));
  458. return 1;
  459. }
  460. }
  461. static int f_setvbuf (lua_State *L) {
  462. static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
  463. static const char *const modenames[] = {"no", "full", "line", NULL};
  464. FILE *f = tofile(L);
  465. int op = luaL_checkoption(L, 2, NULL, modenames);
  466. lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
  467. int res = setvbuf(f, NULL, mode[op], sz);
  468. return luaL_fileresult(L, res == 0, NULL);
  469. }
  470. static int io_flush (lua_State *L) {
  471. return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL);
  472. }
  473. static int f_flush (lua_State *L) {
  474. return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL);
  475. }
  476. /*
  477. ** functions for 'io' library
  478. */
  479. static const luaL_Reg iolib[] = {
  480. {"close", io_close},
  481. {"flush", io_flush},
  482. {"input", io_input},
  483. {"lines", io_lines},
  484. {"open", io_open},
  485. {"output", io_output},
  486. {"popen", io_popen},
  487. {"read", io_read},
  488. {"tmpfile", io_tmpfile},
  489. {"type", io_type},
  490. {"write", io_write},
  491. {NULL, NULL}
  492. };
  493. /*
  494. ** methods for file handles
  495. */
  496. static const luaL_Reg flib[] = {
  497. {"close", io_close},
  498. {"flush", f_flush},
  499. {"lines", f_lines},
  500. {"read", f_read},
  501. {"seek", f_seek},
  502. {"setvbuf", f_setvbuf},
  503. {"write", f_write},
  504. {"__gc", f_gc},
  505. {"__tostring", f_tostring},
  506. {NULL, NULL}
  507. };
  508. static void createmeta (lua_State *L) {
  509. luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
  510. lua_pushvalue(L, -1); /* push metatable */
  511. lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
  512. luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */
  513. lua_pop(L, 1); /* pop new metatable */
  514. }
  515. /*
  516. ** function to (not) close the standard files stdin, stdout, and stderr
  517. */
  518. static int io_noclose (lua_State *L) {
  519. LStream *p = tolstream(L);
  520. p->closef = &io_noclose; /* keep file opened */
  521. lua_pushnil(L);
  522. lua_pushliteral(L, "cannot close standard file");
  523. return 2;
  524. }
  525. static void createstdfile (lua_State *L, FILE *f, const char *k,
  526. const char *fname) {
  527. LStream *p = newprefile(L);
  528. p->f = f;
  529. p->closef = &io_noclose;
  530. if (k != NULL) {
  531. lua_pushvalue(L, -1);
  532. lua_setfield(L, LUA_REGISTRYINDEX, k); /* add file to registry */
  533. }
  534. lua_setfield(L, -2, fname); /* add file to module */
  535. }
  536. LUAMOD_API int luaopen_io (lua_State *L) {
  537. luaL_newlib(L, iolib); /* new module */
  538. createmeta(L);
  539. /* create (and set) default files */
  540. createstdfile(L, stdin, IO_INPUT, "stdin");
  541. createstdfile(L, stdout, IO_OUTPUT, "stdout");
  542. createstdfile(L, stderr, NULL, "stderr");
  543. return 1;
  544. }