diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 2 | ||||
| -rw-r--r-- | src/linit.c | 10 | ||||
| -rw-r--r-- | src/loadlib.c | 16 | ||||
| -rw-r--r-- | src/lobject.h | 4 | ||||
| -rw-r--r-- | src/lopcodes.c | 4 | ||||
| -rw-r--r-- | src/ltable.c | 4 | ||||
| -rw-r--r-- | src/luac.c | 17 |
7 files changed, 39 insertions, 18 deletions
diff --git a/src/Makefile b/src/Makefile index 4be6dc13..2e7a4120 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,7 +6,7 @@ # Your platform. See PLATS for possible values. PLAT= none -CC= gcc -std=c99 +CC= gcc -std=gnu99 CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) LIBS= -lm $(SYSLIBS) $(MYLIBS) diff --git a/src/linit.c b/src/linit.c index ca9d100d..8ce94ccb 100644 --- a/src/linit.c +++ b/src/linit.c @@ -1,5 +1,5 @@ /* -** $Id: linit.c,v 1.37 2014/12/09 15:00:17 roberto Exp $ +** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $ ** Initialization of libraries for lua.c and other clients ** See Copyright Notice in lua.h */ @@ -8,9 +8,6 @@ #define linit_c #define LUA_LIB -#include "lprefix.h" - - /* ** If you embed Lua in your program and need to open the standard ** libraries, call luaL_openlibs in your program. If you need a @@ -27,6 +24,11 @@ ** lua_pop(L, 1); // remove _PRELOAD table */ +#include "lprefix.h" + + +#include <stddef.h> + #include "lua.h" #include "lualib.h" diff --git a/src/loadlib.c b/src/loadlib.c index 1dab9bd0..7f8d9902 100644 --- a/src/loadlib.c +++ b/src/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.123 2014/11/12 13:31:51 roberto Exp $ +** $Id: loadlib.c,v 1.124 2015/01/05 13:51:39 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -135,6 +135,18 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym); #include <dlfcn.h> +/* +** Macro to covert pointer to void* to pointer to function. This cast +** is undefined according to ISO C, but POSIX assumes that it must work. +** (The '__extension__' in gnu compilers is only to avoid warnings.) +*/ +#if defined(__GNUC__) +#define cast_func(p) (__extension__ (lua_CFunction)(p)) +#else +#define cast_func(p) ((lua_CFunction)(p)) +#endif + + static void lsys_unloadlib (void *lib) { dlclose(lib); } @@ -148,7 +160,7 @@ static void *lsys_load (lua_State *L, const char *path, int seeglb) { static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { - lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + lua_CFunction f = cast_func(dlsym(lib, sym)); if (f == NULL) lua_pushstring(L, dlerror()); return f; } diff --git a/src/lobject.h b/src/lobject.h index 77b4e470..d7d0ebf3 100644 --- a/src/lobject.h +++ b/src/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.105 2014/12/19 13:36:32 roberto Exp $ +** $Id: lobject.h,v 2.106 2015/01/05 13:52:37 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -473,7 +473,7 @@ typedef union TKey { /* copy a value into a key without messing up field 'next' */ -#define setkey(L,key,obj) \ +#define setnodekey(L,key,obj) \ { TKey *k_=(key); const TValue *io_=(obj); \ k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ (void)L; checkliveness(G(L),io_); } diff --git a/src/lopcodes.c b/src/lopcodes.c index 8e2e6da3..a1cbef85 100644 --- a/src/lopcodes.c +++ b/src/lopcodes.c @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.c,v 1.54 2014/11/02 19:19:04 roberto Exp $ +** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -10,6 +10,8 @@ #include "lprefix.h" +#include <stddef.h> + #include "lopcodes.h" diff --git a/src/ltable.c b/src/ltable.c index e8ef146c..38be0051 100644 --- a/src/ltable.c +++ b/src/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.99 2014/11/02 19:19:04 roberto Exp $ +** $Id: ltable.c,v 2.100 2015/01/05 13:52:37 roberto Exp $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -484,7 +484,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { mp = f; } } - setkey(L, &mp->i_key, key); + setnodekey(L, &mp->i_key, key); luaC_barrierback(L, t, key); lua_assert(ttisnil(gval(mp))); return gval(mp); @@ -1,5 +1,5 @@ /* -** $Id: luac.c,v 1.71 2014/11/26 12:08:59 lhf Exp $ +** $Id: luac.c,v 1.72 2015/01/06 03:09:13 lhf Exp $ ** Lua compiler (saves bytecodes to files; also lists bytecodes) ** See Copyright Notice in lua.h */ @@ -50,14 +50,14 @@ static void cannot(const char* what) static void usage(const char* message) { if (*message=='-') - fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message); + fprintf(stderr,"%s: unrecognized option '%s'\n",progname,message); else fprintf(stderr,"%s: %s\n",progname,message); fprintf(stderr, "usage: %s [options] [filenames]\n" "Available options are:\n" " -l list (use -l -l for full listing)\n" - " -o name output to file " LUA_QL("name") " (default is \"%s\")\n" + " -o name output to file 'name' (default is \"%s\")\n" " -p parse only\n" " -s strip debug information\n" " -v show version information\n" @@ -92,7 +92,7 @@ static int doargs(int argc, char* argv[]) { output=argv[++i]; if (output==NULL || *output==0 || (*output=='-' && output[1]!=0)) - usage(LUA_QL("-o") " needs argument"); + usage("'-o' needs argument"); if (IS("-")) output=NULL; } else if (IS("-p")) /* parse only */ @@ -206,7 +206,7 @@ int main(int argc, char* argv[]) } /* -** $Id: print.c,v 1.74 2014/07/21 01:41:45 lhf Exp $ +** $Id: print.c,v 1.76 2015/01/05 16:12:50 lhf Exp $ ** print bytecodes ** See Copyright Notice in lua.h */ @@ -263,8 +263,13 @@ static void PrintConstant(const Proto* f, int i) printf(bvalue(o) ? "true" : "false"); break; case LUA_TNUMFLT: - printf(LUA_NUMBER_FMT,fltvalue(o)); + { + char buff[100]; + sprintf(buff,LUA_NUMBER_FMT,fltvalue(o)); + printf("%s",buff); + if (buff[strspn(buff,"-0123456789")]=='\0') printf(".0"); break; + } case LUA_TNUMINT: printf(LUA_INTEGER_FMT,ivalue(o)); break; |
