diff options
author | Lua Team <team@lua.org> | 2011-07-08 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2011-07-08 12:00:00 +0000 |
commit | c17c598e967843fa77a465caf0e0df15d9019409 (patch) | |
tree | 660021a0217430f2c9962203b398e388b88a971e | |
parent | 76e52968cfea8eccaffae99512879d664796e6a6 (diff) | |
download | lua-github-c17c598e967843fa77a465caf0e0df15d9019409.tar.gz |
Lua 5.2.0-beta5.2.0-beta-rc75.2.0-beta
-rw-r--r-- | doc/manual.html | 24 | ||||
-rw-r--r-- | src/llex.c | 71 | ||||
-rw-r--r-- | src/lua.hpp | 9 | ||||
-rw-r--r-- | src/luaconf.h | 12 |
4 files changed, 64 insertions, 52 deletions
diff --git a/doc/manual.html b/doc/manual.html index 00b73095..72155652 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -38,7 +38,7 @@ Freely available under the terms of the <!-- ====================================================================== --> <p> -<!-- $Id: manual.of,v 1.85 2011/07/05 19:15:00 roberto Exp $ --> +<!-- $Id: manual.of,v 1.86 2011/07/08 20:00:45 roberto Exp $ --> @@ -2962,8 +2962,8 @@ This is considered good programming practice. <hr><h3><a name="lua_callk"><code>lua_callk</code></a></h3><p> <span class="apii">[-(nargs + 1), +nresults, <em>e</em>]</span> -<pre>void lua_callk (lua_State *L, int nargs, int nresults, - int ctx, lua_CFunction k);</pre> +<pre>void lua_callk (lua_State *L, int nargs, int nresults, int ctx, + lua_CFunction k);</pre> <p> This function behaves exactly like <a href="#lua_call"><code>lua_call</code></a>, @@ -3857,7 +3857,7 @@ It is generated by the garbage collector.) <hr><h3><a name="lua_pcallk"><code>lua_pcallk</code></a></h3><p> <span class="apii">[-(nargs + 1), +(nresults|1), <em>-</em>]</span> <pre>int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, - int ctx, lua_CFunction k);</pre> + int ctx, lua_CFunction k);</pre> <p> This function behaves exactly like <a href="#lua_pcall"><code>lua_pcall</code></a>, @@ -4839,8 +4839,7 @@ the function calling <code>lua_yield</code>. <hr><h3><a name="lua_yieldk"><code>lua_yieldk</code></a></h3><p> <span class="apii">[-?, +?, <em>-</em>]</span> -<pre>int lua_yieldk (lua_State *L, int nresults, int ctx, - lua_CFunction k);</pre> +<pre>int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k);</pre> <p> Yields a coroutine. @@ -5362,7 +5361,7 @@ will return identical ids for those upvalue indices. <hr><h3><a name="lua_upvaluejoin"><code>lua_upvaluejoin</code></a></h3> <pre>void lua_upvaluejoin (lua_State *L, int fidx1, int n1, - int fidx2, int n2);</pre> + int fidx2, int n2);</pre> <p> Make the <code>n1</code>-th upvalue of the Lua closure at index <code>fidx1</code> @@ -5926,8 +5925,7 @@ process-related functions in the standard library <hr><h3><a name="luaL_fileresult"><code>luaL_fileresult</code></a></h3><p> <span class="apii">[-0, +(1|3), <em>m</em>]</span> -<pre>int luaL_fileresult (lua_State *L, int stat, - const char *fname);</pre> +<pre>int luaL_fileresult (lua_State *L, int stat, const char *fname);</pre> <p> This function produces the return values for @@ -6394,7 +6392,7 @@ in which both <code>name</code> and <code>func</code> are <code>NULL</code>. <hr><h3><a name="luaL_requiref"><code>luaL_requiref</code></a></h3><p> <span class="apii">[-0, +1, <em>e</em>]</span> <pre>void luaL_requiref (lua_State *L, const char *modname, - lua_CFunction openf, int glb);</pre> + lua_CFunction openf, int glb);</pre> <p> Calls function <code>openf</code> with string <code>modname</code> as an argument @@ -6486,8 +6484,8 @@ and uses the result of the call as its result. <hr><h3><a name="luaL_traceback"><code>luaL_traceback</code></a></h3><p> <span class="apii">[-0, +1, <em>m</em>]</span> -<pre>void luaL_traceback (lua_State *L, lua_State *L1, - const char *msg, int level);</pre> +<pre>void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, + int level);</pre> <p> Creates and pushes a traceback of the stack <code>L1</code>. @@ -10204,7 +10202,7 @@ Here is the complete syntax of Lua in extended BNF. <HR> <SMALL CLASS="footer"> Last update: -Tue Jul 5 19:16:15 BRT 2011 +Fri Jul 8 17:11:02 BRT 2011 </SMALL> <!-- Last change: revised for Lua 5.2.0 (beta) @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.50 2011/07/05 19:13:45 roberto Exp $ +** $Id: llex.c,v 2.53 2011/07/08 20:01:38 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -286,45 +286,51 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { } +static void escerror (LexState *ls, int *c, int n, const char *msg) { + int i; + luaZ_resetbuffer(ls->buff); /* prepare error message */ + save(ls, '\\'); + for (i = 0; i < n && c[i] != EOZ; i++) + save(ls, c[i]); + lexerror(ls, msg, TK_STRING); +} + + static int readhexaesc (LexState *ls) { - int c1 = next(ls); - int c2 = EOZ; - if (lisxdigit(c1)) { - c2 = next(ls); - if (lisxdigit(c2)) - return (luaO_hexavalue(c1) << 4) + luaO_hexavalue(c2); + int c[3]; /* keep input for error message */ + int i = 2; /* at least 'x?' will go to error message */ + c[0] = 'x'; + c[1] = next(ls); /* first hexa digit */ + if (lisxdigit(c[1])) { + c[i++] = next(ls); /* second hexa digit */ + if (lisxdigit(c[2])) + return (luaO_hexavalue(c[1]) << 4) + luaO_hexavalue(c[2]); /* else go through to error */ } - luaZ_resetbuffer(ls->buff); /* prepare error message */ - save(ls, '\\'); save(ls, 'x'); - if (c1 != EOZ) save(ls, c1); - if (c2 != EOZ) save(ls, c2); - lexerror(ls, "hexadecimal digit expected", TK_STRING); + escerror(ls, c, i, "hexadecimal digit expected"); return 0; /* to avoid warnings */ } static int readdecesc (LexState *ls) { - int c1 = ls->current; /* first char must be a digit */ - int c2 = next(ls); /* read second char */ - int c = c1 - '0'; /* partial result */ - if (lisdigit(c2)) { - int c3 = next(ls); /* read third char */ - c = 10*c + c2 - '0'; /* update result */ - if (lisdigit(c3)) { - c = 10*c + c3 - '0'; /* update result */ - if (c > UCHAR_MAX) { - luaZ_resetbuffer(ls->buff); /* prepare error message */ - save(ls, '\\'); - save(ls, c1); save(ls, c2); save(ls, c3); - lexerror(ls, "decimal escape too large", TK_STRING); - } - return c; + int c[3], r; + int i = 2; /* at least two chars will be read */ + c[0] = ls->current; /* first char must be a digit */ + c[1] = next(ls); /* read second char */ + r = c[0] - '0'; /* partial result */ + if (lisdigit(c[1])) { + c[i++] = next(ls); /* read third char */ + r = 10*r + c[1] - '0'; /* update result */ + if (lisdigit(c[2])) { + r = 10*r + c[2] - '0'; /* update result */ + if (r > UCHAR_MAX) + escerror(ls, c, i, "decimal escape too large"); + return r; } } /* else, has read one character that was not a digit */ zungetc(ls->z); /* return it to input stream */ - return c; + return r; } @@ -353,9 +359,10 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { case 'x': c = readhexaesc(ls); break; case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case '\\': case '\"': case '\'': c = ls->current; break; case EOZ: continue; /* will raise an error next loop */ case 'z': { /* zap following span of spaces */ - next(ls); /* skip the '*' */ + next(ls); /* skip the 'z' */ while (lisspace(ls->current)) { if (currIsNewline(ls)) inclinenumber(ls); else next(ls); @@ -364,9 +371,9 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { } default: { if (!lisdigit(ls->current)) - c = ls->current; /* handles \\, \", and \' */ - else /* digital escape \ddd */ - c = readdecesc(ls); + escerror(ls, &ls->current, 1, "invalid escape sequence"); + /* digital escape \ddd */ + c = readdecesc(ls); break; } } diff --git a/src/lua.hpp b/src/lua.hpp new file mode 100644 index 00000000..ec417f59 --- /dev/null +++ b/src/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <<extern "C">> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/src/luaconf.h b/src/luaconf.h index e1ffee7e..1135e508 100644 --- a/src/luaconf.h +++ b/src/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.160 2011/06/28 17:14:12 roberto Exp $ +** $Id: luaconf.h,v 1.161 2011/07/08 20:07:11 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -499,12 +499,12 @@ ** doubles with conventional endianess (12345678 or 87654321), in CPUs ** that do not produce signaling NaN values (all NaNs are quiet). */ -#if defined(LUA_CORE) /* { */ - -#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +#if defined(LUA_CORE) && \ + defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ /* little-endian architectures that satisfy those conditions */ -#if defined(__i386__) || defined(__i386) || defined(__X86__) +#if defined(__i386__) || defined(__i386) || defined(__X86__) || \ + defined(_M_IX86) #define LUA_NANTRICKLE @@ -512,8 +512,6 @@ #endif /* } */ -#endif /* } */ - |