diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-05 12:22:55 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-05 12:22:55 -0200 |
| commit | 1721d09ac8e55bb4b675cea26cbe6b707fd21a2c (patch) | |
| tree | 14a418ac50b6b54d1a2a5051a0caa11cdc1e62ea | |
| parent | 2f3da00e514068ab301c72ae0f07383b8a609c71 (diff) | |
| download | lua-1721d09ac8e55bb4b675cea26cbe6b707fd21a2c.tar.gz lua-1721d09ac8e55bb4b675cea26cbe6b707fd21a2c.tar.bz2 lua-1721d09ac8e55bb4b675cea26cbe6b707fd21a2c.zip | |
still accepts initial '=' for expressions, for compatibility with old
versions (and old habits...)
| -rw-r--r-- | lua.c | 7 |
1 files changed, 5 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.c,v 1.207 2013/10/07 14:20:31 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.208 2013/12/16 14:27:17 roberto Exp roberto $ |
| 3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -270,7 +270,10 @@ static int pushline (lua_State *L, int firstline) { | |||
| 270 | l = strlen(b); | 270 | l = strlen(b); |
| 271 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ | 271 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ |
| 272 | b[l-1] = '\0'; /* remove it */ | 272 | b[l-1] = '\0'; /* remove it */ |
| 273 | lua_pushstring(L, b); /* save line in Lua */ | 273 | if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */ |
| 274 | lua_pushfstring(L, "return %s", b + 1); /* change '=' to 'return' */ | ||
| 275 | else | ||
| 276 | lua_pushstring(L, b); | ||
| 274 | lua_freeline(L, b); | 277 | lua_freeline(L, b); |
| 275 | return 1; | 278 | return 1; |
| 276 | } | 279 | } |
