PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/IronHellsOgre/src/lua/lib/lbaselib.c

#
C | 675 lines | 542 code | 106 blank | 27 comment | 95 complexity | 10ed77590135fe195a71b23030d385b4 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, Apache-2.0
  1. /*
  2. ** $Id: lbaselib.c 224 2005-09-28 04:24:57Z cipher $
  3. ** Basic library
  4. ** See Copyright Notice in lua.h
  5. */
  6. #include <ctype.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #define lbaselib_c
  11. #include "lua.h"
  12. #include "lauxlib.h"
  13. #include "lualib.h"
  14. /*
  15. ** If your system does not support `stdout', you can just remove this function.
  16. ** If you need, you can define your own `print' function, following this
  17. ** model but changing `fputs' to put the strings at a proper place
  18. ** (a console window or a log file, for instance).
  19. */
  20. static int luaB_print (lua_State *L) {
  21. int n = lua_gettop(L); /* number of arguments */
  22. int i;
  23. lua_getglobal(L, "tostring");
  24. for (i=1; i<=n; i++) {
  25. const char *s;
  26. lua_pushvalue(L, -1); /* function to be called */
  27. lua_pushvalue(L, i); /* value to print */
  28. lua_call(L, 1, 1);
  29. s = lua_tostring(L, -1); /* get result */
  30. if (s == NULL)
  31. return luaL_error(L, "`tostring' must return a string to `print'");
  32. if (i>1) fputs("\t", stdout);
  33. fputs(s, stdout);
  34. lua_pop(L, 1); /* pop result */
  35. }
  36. fputs("\n", stdout);
  37. return 0;
  38. }
  39. static int luaB_tonumber (lua_State *L) {
  40. int base = luaL_optint(L, 2, 10);
  41. if (base == 10) { /* standard conversion */
  42. luaL_checkany(L, 1);
  43. if (lua_isnumber(L, 1)) {
  44. lua_pushnumber(L, lua_tonumber(L, 1));
  45. return 1;
  46. }
  47. }
  48. else {
  49. const char *s1 = luaL_checkstring(L, 1);
  50. char *s2;
  51. unsigned long n;
  52. luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
  53. n = strtoul(s1, &s2, base);
  54. if (s1 != s2) { /* at least one valid digit? */
  55. while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
  56. if (*s2 == '\0') { /* no invalid trailing characters? */
  57. lua_pushnumber(L, (lua_Number)n);
  58. return 1;
  59. }
  60. }
  61. }
  62. lua_pushnil(L); /* else not a number */
  63. return 1;
  64. }
  65. static int luaB_error (lua_State *L) {
  66. int level = luaL_optint(L, 2, 1);
  67. luaL_checkany(L, 1);
  68. if (!lua_isstring(L, 1) || level == 0)
  69. lua_pushvalue(L, 1); /* propagate error message without changes */
  70. else { /* add extra information */
  71. luaL_where(L, level);
  72. lua_pushvalue(L, 1);
  73. lua_concat(L, 2);
  74. }
  75. return lua_error(L);
  76. }
  77. static int luaB_getmetatable (lua_State *L) {
  78. luaL_checkany(L, 1);
  79. if (!lua_getmetatable(L, 1)) {
  80. lua_pushnil(L);
  81. return 1; /* no metatable */
  82. }
  83. luaL_getmetafield(L, 1, "__metatable");
  84. return 1; /* returns either __metatable field (if present) or metatable */
  85. }
  86. static int luaB_setmetatable (lua_State *L) {
  87. int t = lua_type(L, 2);
  88. luaL_checktype(L, 1, LUA_TTABLE);
  89. luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
  90. "nil or table expected");
  91. if (luaL_getmetafield(L, 1, "__metatable"))
  92. luaL_error(L, "cannot change a protected metatable");
  93. lua_settop(L, 2);
  94. lua_setmetatable(L, 1);
  95. return 1;
  96. }
  97. static void getfunc (lua_State *L) {
  98. if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
  99. else {
  100. lua_Debug ar;
  101. int level = luaL_optint(L, 1, 1);
  102. luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
  103. if (lua_getstack(L, level, &ar) == 0)
  104. luaL_argerror(L, 1, "invalid level");
  105. lua_getinfo(L, "f", &ar);
  106. if (lua_isnil(L, -1))
  107. luaL_error(L, "no function environment for tail call at level %d",
  108. level);
  109. }
  110. }
  111. static int aux_getfenv (lua_State *L) {
  112. lua_getfenv(L, -1);
  113. lua_pushliteral(L, "__fenv");
  114. lua_rawget(L, -2);
  115. return !lua_isnil(L, -1);
  116. }
  117. static int luaB_getfenv (lua_State *L) {
  118. getfunc(L);
  119. if (!aux_getfenv(L)) /* __fenv not defined? */
  120. lua_pop(L, 1); /* remove it, to return real environment */
  121. return 1;
  122. }
  123. static int luaB_setfenv (lua_State *L) {
  124. luaL_checktype(L, 2, LUA_TTABLE);
  125. getfunc(L);
  126. if (aux_getfenv(L)) /* __fenv defined? */
  127. luaL_error(L, "`setfenv' cannot change a protected environment");
  128. else
  129. lua_pop(L, 2); /* remove __fenv and real environment table */
  130. lua_pushvalue(L, 2);
  131. if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0)
  132. lua_replace(L, LUA_GLOBALSINDEX);
  133. else if (lua_setfenv(L, -2) == 0)
  134. luaL_error(L, "`setfenv' cannot change environment of given function");
  135. return 0;
  136. }
  137. static int luaB_rawequal (lua_State *L) {
  138. luaL_checkany(L, 1);
  139. luaL_checkany(L, 2);
  140. lua_pushboolean(L, lua_rawequal(L, 1, 2));
  141. return 1;
  142. }
  143. static int luaB_rawget (lua_State *L) {
  144. luaL_checktype(L, 1, LUA_TTABLE);
  145. luaL_checkany(L, 2);
  146. lua_rawget(L, 1);
  147. return 1;
  148. }
  149. static int luaB_rawset (lua_State *L) {
  150. luaL_checktype(L, 1, LUA_TTABLE);
  151. luaL_checkany(L, 2);
  152. luaL_checkany(L, 3);
  153. lua_rawset(L, 1);
  154. return 1;
  155. }
  156. static int luaB_gcinfo (lua_State *L) {
  157. lua_pushnumber(L, (lua_Number)lua_getgccount(L));
  158. lua_pushnumber(L, (lua_Number)lua_getgcthreshold(L));
  159. return 2;
  160. }
  161. static int luaB_collectgarbage (lua_State *L) {
  162. lua_setgcthreshold(L, luaL_optint(L, 1, 0));
  163. return 0;
  164. }
  165. static int luaB_type (lua_State *L) {
  166. luaL_checkany(L, 1);
  167. lua_pushstring(L, lua_typename(L, lua_type(L, 1)));
  168. return 1;
  169. }
  170. static int luaB_next (lua_State *L) {
  171. luaL_checktype(L, 1, LUA_TTABLE);
  172. lua_settop(L, 2); /* create a 2nd argument if there isn't one */
  173. if (lua_next(L, 1))
  174. return 2;
  175. else {
  176. lua_pushnil(L);
  177. return 1;
  178. }
  179. }
  180. static int luaB_pairs (lua_State *L) {
  181. luaL_checktype(L, 1, LUA_TTABLE);
  182. lua_pushliteral(L, "next");
  183. lua_rawget(L, LUA_GLOBALSINDEX); /* return generator, */
  184. lua_pushvalue(L, 1); /* state, */
  185. lua_pushnil(L); /* and initial value */
  186. return 3;
  187. }
  188. static int luaB_ipairs (lua_State *L) {
  189. lua_Number i = lua_tonumber(L, 2);
  190. luaL_checktype(L, 1, LUA_TTABLE);
  191. if (i == 0 && lua_isnone(L, 2)) { /* `for' start? */
  192. lua_pushliteral(L, "ipairs");
  193. lua_rawget(L, LUA_GLOBALSINDEX); /* return generator, */
  194. lua_pushvalue(L, 1); /* state, */
  195. lua_pushnumber(L, 0); /* and initial value */
  196. return 3;
  197. }
  198. else { /* `for' step */
  199. i++; /* next value */
  200. lua_pushnumber(L, i);
  201. lua_rawgeti(L, 1, (int)i);
  202. return (lua_isnil(L, -1)) ? 0 : 2;
  203. }
  204. }
  205. static int load_aux (lua_State *L, int status) {
  206. if (status == 0) /* OK? */
  207. return 1;
  208. else {
  209. lua_pushnil(L);
  210. lua_insert(L, -2); /* put before error message */
  211. return 2; /* return nil plus error message */
  212. }
  213. }
  214. static int luaB_loadstring (lua_State *L) {
  215. size_t l;
  216. const char *s = luaL_checklstring(L, 1, &l);
  217. const char *chunkname = luaL_optstring(L, 2, s);
  218. return load_aux(L, luaL_loadbuffer(L, s, l, chunkname));
  219. }
  220. static int luaB_loadfile (lua_State *L) {
  221. const char *fname = luaL_optstring(L, 1, NULL);
  222. return load_aux(L, luaL_loadfile(L, fname));
  223. }
  224. static int luaB_dofile (lua_State *L) {
  225. const char *fname = luaL_optstring(L, 1, NULL);
  226. int n = lua_gettop(L);
  227. int status = luaL_loadfile(L, fname);
  228. if (status != 0) lua_error(L);
  229. lua_call(L, 0, LUA_MULTRET);
  230. return lua_gettop(L) - n;
  231. }
  232. static int luaB_assert (lua_State *L) {
  233. luaL_checkany(L, 1);
  234. if (!lua_toboolean(L, 1))
  235. return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
  236. lua_settop(L, 1);
  237. return 1;
  238. }
  239. static int luaB_unpack (lua_State *L) {
  240. int n, i;
  241. luaL_checktype(L, 1, LUA_TTABLE);
  242. n = luaL_getn(L, 1);
  243. luaL_checkstack(L, n, "table too big to unpack");
  244. for (i=1; i<=n; i++) /* push arg[1...n] */
  245. lua_rawgeti(L, 1, i);
  246. return n;
  247. }
  248. static int luaB_pcall (lua_State *L) {
  249. int status;
  250. luaL_checkany(L, 1);
  251. status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
  252. lua_pushboolean(L, (status == 0));
  253. lua_insert(L, 1);
  254. return lua_gettop(L); /* return status + all results */
  255. }
  256. static int luaB_xpcall (lua_State *L) {
  257. int status;
  258. luaL_checkany(L, 2);
  259. lua_settop(L, 2);
  260. lua_insert(L, 1); /* put error function under function to be called */
  261. status = lua_pcall(L, 0, LUA_MULTRET, 1);
  262. lua_pushboolean(L, (status == 0));
  263. lua_replace(L, 1);
  264. return lua_gettop(L); /* return status + all results */
  265. }
  266. static int luaB_tostring (lua_State *L) {
  267. char buff[128];
  268. luaL_checkany(L, 1);
  269. if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
  270. return 1; /* use its value */
  271. switch (lua_type(L, 1)) {
  272. case LUA_TNUMBER:
  273. lua_pushstring(L, lua_tostring(L, 1));
  274. return 1;
  275. case LUA_TSTRING:
  276. lua_pushvalue(L, 1);
  277. return 1;
  278. case LUA_TBOOLEAN:
  279. lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false"));
  280. return 1;
  281. case LUA_TTABLE:
  282. sprintf(buff, "table: %p", lua_topointer(L, 1));
  283. break;
  284. case LUA_TFUNCTION:
  285. sprintf(buff, "function: %p", lua_topointer(L, 1));
  286. break;
  287. case LUA_TUSERDATA:
  288. case LUA_TLIGHTUSERDATA:
  289. sprintf(buff, "userdata: %p", lua_touserdata(L, 1));
  290. break;
  291. case LUA_TTHREAD:
  292. sprintf(buff, "thread: %p", (void *)lua_tothread(L, 1));
  293. break;
  294. case LUA_TNIL:
  295. lua_pushliteral(L, "nil");
  296. return 1;
  297. }
  298. lua_pushstring(L, buff);
  299. return 1;
  300. }
  301. static int luaB_newproxy (lua_State *L) {
  302. lua_settop(L, 1);
  303. lua_newuserdata(L, 0); /* create proxy */
  304. if (lua_toboolean(L, 1) == 0)
  305. return 1; /* no metatable */
  306. else if (lua_isboolean(L, 1)) {
  307. lua_newtable(L); /* create a new metatable `m' ... */
  308. lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */
  309. lua_pushboolean(L, 1);
  310. lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */
  311. }
  312. else {
  313. int validproxy = 0; /* to check if weaktable[metatable(u)] == true */
  314. if (lua_getmetatable(L, 1)) {
  315. lua_rawget(L, lua_upvalueindex(1));
  316. validproxy = lua_toboolean(L, -1);
  317. lua_pop(L, 1); /* remove value */
  318. }
  319. luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
  320. lua_getmetatable(L, 1); /* metatable is valid; get it */
  321. }
  322. lua_setmetatable(L, 2);
  323. return 1;
  324. }
  325. /*
  326. ** {======================================================
  327. ** `require' function
  328. ** =======================================================
  329. */
  330. /* name of global that holds table with loaded packages */
  331. #define REQTAB "_LOADED"
  332. /* name of global that holds the search path for packages */
  333. #define LUA_PATH "LUA_PATH"
  334. #ifndef LUA_PATH_SEP
  335. #define LUA_PATH_SEP ';'
  336. #endif
  337. #ifndef LUA_PATH_MARK
  338. #define LUA_PATH_MARK '?'
  339. #endif
  340. #ifndef LUA_PATH_DEFAULT
  341. #define LUA_PATH_DEFAULT "?;?.lua"
  342. #endif
  343. static const char *getpath (lua_State *L) {
  344. const char *path;
  345. lua_getglobal(L, LUA_PATH); /* try global variable */
  346. path = lua_tostring(L, -1);
  347. lua_pop(L, 1);
  348. if (path) return path;
  349. path = getenv(LUA_PATH); /* else try environment variable */
  350. if (path) return path;
  351. return LUA_PATH_DEFAULT; /* else use default */
  352. }
  353. static const char *pushnextpath (lua_State *L, const char *path) {
  354. const char *l;
  355. if (*path == '\0') return NULL; /* no more paths */
  356. if (*path == LUA_PATH_SEP) path++; /* skip separator */
  357. l = strchr(path, LUA_PATH_SEP); /* find next separator */
  358. if (l == NULL) l = path+strlen(path);
  359. lua_pushlstring(L, path, l - path); /* directory name */
  360. return l;
  361. }
  362. static void pushcomposename (lua_State *L) {
  363. const char *path = lua_tostring(L, -1);
  364. const char *wild;
  365. int n = 1;
  366. while ((wild = strchr(path, LUA_PATH_MARK)) != NULL) {
  367. /* is there stack space for prefix, name, and eventual last sufix? */
  368. luaL_checkstack(L, 3, "too many marks in a path component");
  369. lua_pushlstring(L, path, wild - path); /* push prefix */
  370. lua_pushvalue(L, 1); /* push package name (in place of MARK) */
  371. path = wild + 1; /* continue after MARK */
  372. n += 2;
  373. }
  374. lua_pushstring(L, path); /* push last sufix (`n' already includes this) */
  375. lua_concat(L, n);
  376. }
  377. static int luaB_require (lua_State *L) {
  378. const char *path;
  379. int status = LUA_ERRFILE; /* not found (yet) */
  380. luaL_checkstring(L, 1);
  381. lua_settop(L, 1);
  382. lua_getglobal(L, REQTAB);
  383. if (!lua_istable(L, 2)) return luaL_error(L, "`" REQTAB "' is not a table");
  384. path = getpath(L);
  385. lua_pushvalue(L, 1); /* check package's name in book-keeping table */
  386. lua_rawget(L, 2);
  387. if (lua_toboolean(L, -1)) /* is it there? */
  388. return 1; /* package is already loaded; return its result */
  389. else { /* must load it */
  390. while (status == LUA_ERRFILE) {
  391. lua_settop(L, 3); /* reset stack position */
  392. if ((path = pushnextpath(L, path)) == NULL) break;
  393. pushcomposename(L);
  394. status = luaL_loadfile(L, lua_tostring(L, -1)); /* try to load it */
  395. }
  396. }
  397. switch (status) {
  398. case 0: {
  399. lua_getglobal(L, "_REQUIREDNAME"); /* save previous name */
  400. lua_insert(L, -2); /* put it below function */
  401. lua_pushvalue(L, 1);
  402. lua_setglobal(L, "_REQUIREDNAME"); /* set new name */
  403. lua_call(L, 0, 1); /* run loaded module */
  404. lua_insert(L, -2); /* put result below previous name */
  405. lua_setglobal(L, "_REQUIREDNAME"); /* reset to previous name */
  406. if (lua_isnil(L, -1)) { /* no/nil return? */
  407. lua_pushboolean(L, 1);
  408. lua_replace(L, -2); /* replace to true */
  409. }
  410. lua_pushvalue(L, 1);
  411. lua_pushvalue(L, -2);
  412. lua_rawset(L, 2); /* mark it as loaded */
  413. return 1; /* return value */
  414. }
  415. case LUA_ERRFILE: { /* file not found */
  416. return luaL_error(L, "could not load package `%s' from path `%s'",
  417. lua_tostring(L, 1), getpath(L));
  418. }
  419. default: {
  420. return luaL_error(L, "error loading package `%s' (%s)",
  421. lua_tostring(L, 1), lua_tostring(L, -1));
  422. }
  423. }
  424. }
  425. /* }====================================================== */
  426. static const luaL_reg base_funcs[] = {
  427. {"error", luaB_error},
  428. {"getmetatable", luaB_getmetatable},
  429. {"setmetatable", luaB_setmetatable},
  430. {"getfenv", luaB_getfenv},
  431. {"setfenv", luaB_setfenv},
  432. {"next", luaB_next},
  433. {"ipairs", luaB_ipairs},
  434. {"pairs", luaB_pairs},
  435. {"print", luaB_print},
  436. {"tonumber", luaB_tonumber},
  437. {"tostring", luaB_tostring},
  438. {"type", luaB_type},
  439. {"assert", luaB_assert},
  440. {"unpack", luaB_unpack},
  441. {"rawequal", luaB_rawequal},
  442. {"rawget", luaB_rawget},
  443. {"rawset", luaB_rawset},
  444. {"pcall", luaB_pcall},
  445. {"xpcall", luaB_xpcall},
  446. {"collectgarbage", luaB_collectgarbage},
  447. {"gcinfo", luaB_gcinfo},
  448. {"loadfile", luaB_loadfile},
  449. {"dofile", luaB_dofile},
  450. {"loadstring", luaB_loadstring},
  451. {"require", luaB_require},
  452. {NULL, NULL}
  453. };
  454. /*
  455. ** {======================================================
  456. ** Coroutine library
  457. ** =======================================================
  458. */
  459. static int auxresume (lua_State *L, lua_State *co, int narg) {
  460. int status;
  461. if (!lua_checkstack(co, narg))
  462. luaL_error(L, "too many arguments to resume");
  463. lua_xmove(L, co, narg);
  464. status = lua_resume(co, narg);
  465. if (status == 0) {
  466. int nres = lua_gettop(co);
  467. if (!lua_checkstack(L, nres))
  468. luaL_error(L, "too many results to resume");
  469. lua_xmove(co, L, nres); /* move yielded values */
  470. return nres;
  471. }
  472. else {
  473. lua_xmove(co, L, 1); /* move error message */
  474. return -1; /* error flag */
  475. }
  476. }
  477. static int luaB_coresume (lua_State *L) {
  478. lua_State *co = lua_tothread(L, 1);
  479. int r;
  480. luaL_argcheck(L, co, 1, "coroutine expected");
  481. r = auxresume(L, co, lua_gettop(L) - 1);
  482. if (r < 0) {
  483. lua_pushboolean(L, 0);
  484. lua_insert(L, -2);
  485. return 2; /* return false + error message */
  486. }
  487. else {
  488. lua_pushboolean(L, 1);
  489. lua_insert(L, -(r + 1));
  490. return r + 1; /* return true + `resume' returns */
  491. }
  492. }
  493. static int luaB_auxwrap (lua_State *L) {
  494. lua_State *co = lua_tothread(L, lua_upvalueindex(1));
  495. int r = auxresume(L, co, lua_gettop(L));
  496. if (r < 0) {
  497. if (lua_isstring(L, -1)) { /* error object is a string? */
  498. luaL_where(L, 1); /* add extra info */
  499. lua_insert(L, -2);
  500. lua_concat(L, 2);
  501. }
  502. lua_error(L); /* propagate error */
  503. }
  504. return r;
  505. }
  506. static int luaB_cocreate (lua_State *L) {
  507. lua_State *NL = lua_newthread(L);
  508. luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
  509. "Lua function expected");
  510. lua_pushvalue(L, 1); /* move function to top */
  511. lua_xmove(L, NL, 1); /* move function from L to NL */
  512. return 1;
  513. }
  514. static int luaB_cowrap (lua_State *L) {
  515. luaB_cocreate(L);
  516. lua_pushcclosure(L, luaB_auxwrap, 1);
  517. return 1;
  518. }
  519. static int luaB_yield (lua_State *L) {
  520. return lua_yield(L, lua_gettop(L));
  521. }
  522. static int luaB_costatus (lua_State *L) {
  523. lua_State *co = lua_tothread(L, 1);
  524. luaL_argcheck(L, co, 1, "coroutine expected");
  525. if (L == co) lua_pushliteral(L, "running");
  526. else {
  527. lua_Debug ar;
  528. if (lua_getstack(co, 0, &ar) == 0 && lua_gettop(co) == 0)
  529. lua_pushliteral(L, "dead");
  530. else
  531. lua_pushliteral(L, "suspended");
  532. }
  533. return 1;
  534. }
  535. static const luaL_reg co_funcs[] = {
  536. {"create", luaB_cocreate},
  537. {"wrap", luaB_cowrap},
  538. {"resume", luaB_coresume},
  539. {"yield", luaB_yield},
  540. {"status", luaB_costatus},
  541. {NULL, NULL}
  542. };
  543. /* }====================================================== */
  544. static void base_open (lua_State *L) {
  545. lua_pushliteral(L, "_G");
  546. lua_pushvalue(L, LUA_GLOBALSINDEX);
  547. luaL_openlib(L, NULL, base_funcs, 0); /* open lib into global table */
  548. lua_pushliteral(L, "_VERSION");
  549. lua_pushliteral(L, LUA_VERSION);
  550. lua_rawset(L, -3); /* set global _VERSION */
  551. /* `newproxy' needs a weaktable as upvalue */
  552. lua_pushliteral(L, "newproxy");
  553. lua_newtable(L); /* new table `w' */
  554. lua_pushvalue(L, -1); /* `w' will be its own metatable */
  555. lua_setmetatable(L, -2);
  556. lua_pushliteral(L, "__mode");
  557. lua_pushliteral(L, "k");
  558. lua_rawset(L, -3); /* metatable(w).__mode = "k" */
  559. lua_pushcclosure(L, luaB_newproxy, 1);
  560. lua_rawset(L, -3); /* set global `newproxy' */
  561. lua_rawset(L, -1); /* set global _G */
  562. }
  563. LUALIB_API int luaopen_base (lua_State *L) {
  564. base_open(L);
  565. luaL_openlib(L, LUA_COLIBNAME, co_funcs, 0);
  566. lua_newtable(L);
  567. lua_setglobal(L, REQTAB);
  568. return 0;
  569. }