瀏覽代碼

new command 'print' (to print literal strings) in mini-language

Roberto Ierusalimschy 7 年之前
父節點
當前提交
c6fedc92f8
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      ltests.c

+ 6 - 2
ltests.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.c,v 2.236 2017/12/11 18:55:31 roberto Exp roberto $
+** $Id: ltests.c,v 2.237 2017/12/15 18:53:48 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -1377,7 +1377,7 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
     else if EQ("pop") {
     else if EQ("pop") {
       lua_pop(L1, getnum);
       lua_pop(L1, getnum);
     }
     }
-    else if EQ("print") {
+    else if EQ("printstack") {
       int n = getnum;
       int n = getnum;
       if (n != 0) {
       if (n != 0) {
         printf("%s\n", luaL_tolstring(L1, n, NULL));
         printf("%s\n", luaL_tolstring(L1, n, NULL));
@@ -1385,6 +1385,10 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
       }
       }
       else printstack(L1);
       else printstack(L1);
     }
     }
+    else if EQ("print") {
+      const char *msg = getstring;
+      printf("%s\n", msg);
+    }
     else if EQ("pushbool") {
     else if EQ("pushbool") {
       lua_pushboolean(L1, getnum);
       lua_pushboolean(L1, getnum);
     }
     }