Roberto Ierusalimschy 10 ani în urmă
părinte
comite
fd6e680e21
1 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 3 3
      lua.c

+ 3 - 3
lua.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lua.c,v 1.222 2014/11/11 19:41:27 roberto Exp roberto $
+** $Id: lua.c,v 1.223 2015/03/09 21:57:05 roberto Exp roberto $
 ** Lua stand-alone interpreter
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -313,11 +313,11 @@ static int pushline (lua_State *L, int firstline) {
   lua_pop(L, 1);  /* remove prompt */
   lua_pop(L, 1);  /* remove prompt */
   l = strlen(b);
   l = strlen(b);
   if (l > 0 && b[l-1] == '\n')  /* line ends with newline? */
   if (l > 0 && b[l-1] == '\n')  /* line ends with newline? */
-    b[l-1] = '\0';  /* remove it */
+    b[--l] = '\0';  /* remove it */
   if (firstline && b[0] == '=')  /* for compatibility with 5.2, ... */
   if (firstline && b[0] == '=')  /* for compatibility with 5.2, ... */
     lua_pushfstring(L, "return %s", b + 1);  /* change '=' to 'return' */
     lua_pushfstring(L, "return %s", b + 1);  /* change '=' to 'return' */
   else
   else
-    lua_pushstring(L, b);
+    lua_pushlstring(L, b, l);
   lua_freeline(L, b);
   lua_freeline(L, b);
   return 1;
   return 1;
 }
 }