From 1721d09ac8e55bb4b675cea26cbe6b707fd21a2c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 5 Feb 2014 12:22:55 -0200 Subject: still accepts initial '=' for expressions, for compatibility with old versions (and old habits...) --- lua.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lua.c') diff --git a/lua.c b/lua.c index 70f7cc24..e0ca0669 100644 --- a/lua.c +++ b/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.207 2013/10/07 14:20:31 roberto Exp roberto $ +** $Id: lua.c,v 1.208 2013/12/16 14:27:17 roberto Exp roberto $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -270,7 +270,10 @@ static int pushline (lua_State *L, int firstline) { l = strlen(b); if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ b[l-1] = '\0'; /* remove it */ - lua_pushstring(L, b); /* save line in Lua */ + if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */ + lua_pushfstring(L, "return %s", b + 1); /* change '=' to 'return' */ + else + lua_pushstring(L, b); lua_freeline(L, b); return 1; } -- cgit v1.2.3-55-g6feb