Advertisement
losinggeneration

KOS Example: Lua 5.2 diff

May 30th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.92 KB | None | 0 0
  1. iff --git a/examples/dreamcast/lua/basic/Makefile b/examples/dreamcast/lua/basic/Makefile
  2. index a0698b3..941c444 100644
  3. --- a/examples/dreamcast/lua/basic/Makefile
  4. +++ b/examples/dreamcast/lua/basic/Makefile
  5. @@ -21,7 +21,7 @@ rm-elf:
  6.  
  7.  lua.elf: $(OBJS)
  8.     $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o lua.elf $(KOS_START) $(OBJS) $(DATAOBJS) \
  9. -       $(OBJEXTRA) -llua -llualib -lconio $(KOS_LIBS) -lm
  10. +       $(OBJEXTRA) -llua -lconio $(KOS_LIBS) -lm
  11.  
  12.  run: lua.elf
  13.     $(KOS_LOADER) lua.elf
  14. diff --git a/examples/dreamcast/lua/basic/lua.c b/examples/dreamcast/lua/basic/lua.c
  15. index 6377bb2..ff7c046 100644
  16. --- a/examples/dreamcast/lua/basic/lua.c
  17. +++ b/examples/dreamcast/lua/basic/lua.c
  18. @@ -16,8 +16,10 @@
  19.  /* #include "lua.h"
  20.  
  21.  #include "luadebug.h"
  22. -#include "lualib.h" */
  23. +#include "lualib.h"*/
  24.  #include <lua/lua.h>
  25. +#include <lua/lualib.h>
  26. +#include <lua/lauxlib.h>
  27.  
  28.  
  29.  static lua_State *L = NULL;
  30. @@ -34,14 +36,14 @@ static lua_Hook old_linehook = NULL;
  31.  static lua_Hook old_callhook = NULL;
  32.  
  33.  static void userinit(void) {
  34. -    lua_baselibopen(L);
  35. -    lua_iolibopen(L);
  36. -    lua_strlibopen(L);
  37. -    lua_mathlibopen(L);
  38. -    lua_dblibopen(L);
  39. +   luaL_openlibs(L);
  40.      /* add your libraries here */
  41.  }
  42.  
  43. +static int lua_dostring(lua_State *L, const char *str) {
  44. +   return luaL_dostring(L, str);
  45. +}
  46. +
  47.  static int ldo(int (*f)(lua_State *l, const char *), const char *name) {
  48.      int res;
  49.      int top = lua_gettop(L);
  50. @@ -126,24 +128,24 @@ static void manual_input(int version, int prompt) {
  51.          assert(r >= 0);
  52.  
  53.          if(strlen(buffer)) {
  54. -            ldo(lua_dostring, buffer);
  55. -            lua_settop(L, 0);  /* remove eventual results */
  56. -        }
  57. -    }
  58. +           ldo(lua_dostring, buffer);
  59. +           lua_settop(L, 0);  /* remove eventual results */
  60. +       }
  61. +   }
  62.  
  63. -    conio_printf("\n");
  64. +   conio_printf("\n");
  65.  }
  66.  
  67.  #if 0
  68.  static int handle_argv(char *argv[], struct Options *opt) {
  69. -    if(opt->stacksize > 0) argv++;   /* skip option `-s' (if present) */
  70. -
  71. -    if(*argv == NULL) {   /* no more arguments? */
  72. -        if(isatty(0)) {
  73. -            manual_input(1, 1);
  74. -        }
  75. -        else
  76. -            ldo(lua_dofile, NULL);  /* executes stdin as a file */
  77. +   if(opt->stacksize > 0) argv++;   /* skip option `-s' (if present) */
  78. +
  79. +   if(*argv == NULL) {   /* no more arguments? */
  80. +       if(isatty(0)) {
  81. +           manual_input(1, 1);
  82. +       }
  83. +       else
  84. +           ldo(lua_dofile, NULL);  /* executes stdin as a file */
  85.      }
  86.      else {  /* other arguments; loop over them */
  87.          int i;
  88. @@ -233,9 +235,9 @@ int main(int argc, char *argv[]) {
  89.      pvr_init_defaults();
  90.      conio_init(CONIO_TTY_SERIAL, CONIO_INPUT_LINE);
  91.  
  92. -    luaB_set_fputs((void (*)(const char *))conio_printf);
  93. +    //luaB_set_fputs((void (*)(const char *))conio_printf);
  94.  
  95. -    L = lua_open();  /* create state */
  96. +    L = luaL_newstate();  /* create state */
  97.  
  98.      if(L == NULL) {
  99.          printf("Invalid state.. giving up\n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement