code_junkie

Lua = operator as print

Nov 11th, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. > = a
  2. nil
  3. > a = 8
  4. > = a
  5. 8
  6. > = 'hello'
  7. hello
  8. > = print
  9. function: 003657C8
  10.  
  11. while ((status = loadline(L)) != -1) {
  12. if (status == 0) status = docall(L, 0, 0);
  13. report(L, status);
  14. if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */
  15. lua_getglobal(L, "print");
  16. lua_insert(L, 1);
  17. if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
  18. l_message(progname, lua_pushfstring(L,
  19. "error calling " LUA_QL("print") " (%s)",
  20. lua_tostring(L, -1)));
  21. }
  22. }
  23.  
  24. if (firstline && b[0] == '=') /* first line starts with `=' ? */
  25. lua_pushfstring(L, "return %s", b+1); /* change it to `return' */
Add Comment
Please, Sign In to add comment