lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I think this is because in lua.c, pushline() checks just the first character for = "" possible whitespace.
This simple patch works for me (but there could be a simpler patch).
 
--- lua.c
+++ lua.c
@@ -314,12 +314,14 @@
     return 0;  /* no input (prompt will be popped by caller) */
   lua_pop(L, 1);  /* remove prompt */
   l = strlen(b);
   if (l > 0 && b[l-1] == '\n')  /* line ends with newline? */
     b[--l] = '\0';  /* remove it */
-  if (firstline && b[0] == '=')  /* for compatibility with 5.2, ... */
-    lua_pushfstring(L, "return %s", b + 1);  /* change '=' to 'return' */
+  int i = 0;
+  while (b[i] == ' ' || b[i] == '\t') i++;
+  if (firstline && b[i] == '=')  /* for compatibility with 5.2, ... */
+    lua_pushfstring(L, "return %s", b + i + 1);  /* change '=' to 'return' */
   else
     lua_pushlstring(L, b, l);
   lua_freeline(L, b);
   return 1;
}
 
 
Sent: Sunday, April 30, 2017 9:33 PM
Subject: Re: [bug?] = doesn't work properly
 
On Sun, Apr 30, 2017 at 7:04 PM, Soni L. <fakedme@gmail.com> wrote:
$ lua
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> =1
1
>  =1
stdin:1: unexpected symbol near '='

 
Yes, it looks like a bug.