logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0002-Build-in-luaposix-modules.patch (4701B)


  1. From 53565af85003022be06bc6662e72a9291d338b14 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Sun, 2 Feb 2025 03:03:11 -0800
  4. Subject: [PATCH] Build in luaposix modules
  5. ---
  6. lua.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. 1 file changed, 88 insertions(+)
  8. diff --git a/src/lua.c b/src/lua.c
  9. index 0ff88454..ca160217 100644
  10. --- a/src/lua.c
  11. +++ b/src/lua.c
  12. @@ -609,6 +609,35 @@ static void doREPL (lua_State *L) {
  13. /* }================================================================== */
  14. +int luaopen_posix_ctype(lua_State *L);
  15. +int luaopen_posix_dirent(lua_State *L);
  16. +int luaopen_posix_errno(lua_State *L);
  17. +int luaopen_posix_fcntl(lua_State *L);
  18. +int luaopen_posix_fnmatch(lua_State *L);
  19. +int luaopen_posix_glob(lua_State *L);
  20. +int luaopen_posix_grp(lua_State *L);
  21. +int luaopen_posix_libgen(lua_State *L);
  22. +int luaopen_posix_poll(lua_State *L);
  23. +int luaopen_posix_pwd(lua_State *L);
  24. +int luaopen_posix_sched(lua_State *L);
  25. +int luaopen_posix_signal(lua_State *L);
  26. +int luaopen_posix_stdio(lua_State *L);
  27. +int luaopen_posix_stdlib(lua_State *L);
  28. +int luaopen_posix_sys_msg(lua_State *L);
  29. +int luaopen_posix_sys_resource(lua_State *L);
  30. +int luaopen_posix_sys_socket(lua_State *L);
  31. +int luaopen_posix_sys_stat(lua_State *L);
  32. +int luaopen_posix_sys_statvfs(lua_State *L);
  33. +int luaopen_posix_sys_time(lua_State *L);
  34. +int luaopen_posix_sys_times(lua_State *L);
  35. +int luaopen_posix_sys_utsname(lua_State *L);
  36. +int luaopen_posix_sys_wait(lua_State *L);
  37. +int luaopen_posix_syslog(lua_State *L);
  38. +int luaopen_posix_termio(lua_State *L);
  39. +int luaopen_posix_time(lua_State *L);
  40. +int luaopen_posix_unistd(lua_State *L);
  41. +int luaopen_posix_utime(lua_State *L);
  42. +
  43. /*
  44. ** Main body of stand-alone interpreter (to be called in protected mode).
  45. @@ -632,6 +661,65 @@ static int pmain (lua_State *L) {
  46. lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
  47. }
  48. luaL_openlibs(L); /* open standard libraries */
  49. + luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
  50. + /* luaposix */
  51. + lua_pushcfunction(L, luaopen_posix_ctype);
  52. + lua_setfield(L, -2, "posix.ctype");
  53. + lua_pushcfunction(L, luaopen_posix_dirent);
  54. + lua_setfield(L, -2, "posix.dirent");
  55. + lua_pushcfunction(L, luaopen_posix_errno);
  56. + lua_setfield(L, -2, "posix.errno");
  57. + lua_pushcfunction(L, luaopen_posix_fcntl);
  58. + lua_setfield(L, -2, "posix.fcntl");
  59. + lua_pushcfunction(L, luaopen_posix_fnmatch);
  60. + lua_setfield(L, -2, "posix.fnmatch");
  61. + lua_pushcfunction(L, luaopen_posix_glob);
  62. + lua_setfield(L, -2, "posix.glob");
  63. + lua_pushcfunction(L, luaopen_posix_grp);
  64. + lua_setfield(L, -2, "posix.grp");
  65. + lua_pushcfunction(L, luaopen_posix_libgen);
  66. + lua_setfield(L, -2, "posix.libgen");
  67. + lua_pushcfunction(L, luaopen_posix_poll);
  68. + lua_setfield(L, -2, "posix.poll");
  69. + lua_pushcfunction(L, luaopen_posix_pwd);
  70. + lua_setfield(L, -2, "posix.pwd");
  71. + lua_pushcfunction(L, luaopen_posix_sched);
  72. + lua_setfield(L, -2, "posix.sched");
  73. + lua_pushcfunction(L, luaopen_posix_signal);
  74. + lua_setfield(L, -2, "posix.signal");
  75. + lua_pushcfunction(L, luaopen_posix_stdio);
  76. + lua_setfield(L, -2, "posix.stdio");
  77. + lua_pushcfunction(L, luaopen_posix_stdlib);
  78. + lua_setfield(L, -2, "posix.stdlib");
  79. + lua_pushcfunction(L, luaopen_posix_sys_msg);
  80. + lua_setfield(L, -2, "posix.sys.msg");
  81. + lua_pushcfunction(L, luaopen_posix_sys_resource);
  82. + lua_setfield(L, -2, "posix.sys.resource");
  83. + lua_pushcfunction(L, luaopen_posix_sys_socket);
  84. + lua_setfield(L, -2, "posix.sys.socket");
  85. + lua_pushcfunction(L, luaopen_posix_sys_stat);
  86. + lua_setfield(L, -2, "posix.sys.stat");
  87. + lua_pushcfunction(L, luaopen_posix_sys_statvfs);
  88. + lua_setfield(L, -2, "posix.sys.statvfs");
  89. + lua_pushcfunction(L, luaopen_posix_sys_time);
  90. + lua_setfield(L, -2, "posix.sys.time");
  91. + lua_pushcfunction(L, luaopen_posix_sys_times);
  92. + lua_setfield(L, -2, "posix.sys.times");
  93. + lua_pushcfunction(L, luaopen_posix_sys_utsname);
  94. + lua_setfield(L, -2, "posix.sys.utsname");
  95. + lua_pushcfunction(L, luaopen_posix_sys_wait);
  96. + lua_setfield(L, -2, "posix.sys.wait");
  97. + lua_pushcfunction(L, luaopen_posix_syslog);
  98. + lua_setfield(L, -2, "posix.syslog");
  99. + lua_pushcfunction(L, luaopen_posix_termio);
  100. + lua_setfield(L, -2, "posix.termio");
  101. + lua_pushcfunction(L, luaopen_posix_time);
  102. + lua_setfield(L, -2, "posix.time");
  103. + lua_pushcfunction(L, luaopen_posix_unistd);
  104. + lua_setfield(L, -2, "posix.unistd");
  105. + lua_pushcfunction(L, luaopen_posix_utime);
  106. + lua_setfield(L, -2, "posix.utime");
  107. + lua_pop(L, 1);
  108. createargtable(L, argv, argc, script); /* create table 'arg' */
  109. lua_gc(L, LUA_GCRESTART); /* start GC... */
  110. lua_gc(L, LUA_GCGEN, 0, 0); /* ...in generational mode */
  111. --
  112. 2.44.0