From a02573fc3201f8410d2994f2c0305aead5373265 Mon Sep 17 00:00:00 2001 From: g012 Date: Thu, 28 Sep 2017 23:37:03 +0200 Subject: [PATCH] Fixed warnings on clang. Removed dl lib for osx. Fixed lpeg build on windows with numsiblings static. --- CMakeLists.txt | 5 ++++- README.md | 7 +++++-- lpeg.c | 4 ++-- main.c | 8 ++++---- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a7693e..d37eb2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,10 @@ if (MSVC) elseif (UNIX) - list(APPEND LINKLIBS m dl) + list(APPEND LINKLIBS m) + if (NOT APPLE) + list(APPEND LINKLIBS dl) + endif() endif() diff --git a/README.md b/README.md index aa154ef..79fe277 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # l65 +[![Build Status](https://travis-ci.org/g012/l65.svg?branch=master)](https://travis-ci.org/g012/l65) l65 is a 6502 assembler, operating from within Lua and written in Lua. This means assembler mnemonics become regular Lua statements anywhere in the middle of Lua code. @@ -13,6 +14,7 @@ Use CMake to build a standalone executable. Following are basic instructions if mkdir build\win32 cd build\win32 cmake -G "Visual Studio 15 2017" ..\.. +cd .. cmake --build win32 --config Release ``` @@ -21,13 +23,14 @@ cmake --build win32 --config Release mkdir build\win64 cd build\win64 cmake -G "Visual Studio 15 2017 Win64" ..\.. +cd .. cmake --build win64 --config Release ``` ### Linux ``` -mkdir build/linux +mkdir -p build/linux cd build/linux cmake ../.. -DCMAKE_BUILD_TYPE=Release make @@ -35,7 +38,7 @@ make Force 32b build on 64b system: ``` -mkdir build/linux32 +mkdir -p build/linux32 cd build/linux32 cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m32 make diff --git a/lpeg.c b/lpeg.c index db0d3b8..f28f182 100644 --- a/lpeg.c +++ b/lpeg.c @@ -283,7 +283,7 @@ typedef struct Pattern { /* number of children for each tree */ -static const byte numsiblings[]; +static const byte numsiblings[17]; /* access to children */ #define sib1(t) ((t) + 1) @@ -2203,7 +2203,7 @@ static void printktable (lua_State *L, int idx) { */ /* number of siblings for each tree */ -static const byte numsiblings[] = { +static const byte numsiblings[17] = { 0, 0, 0, /* char, set, any */ 0, 0, /* true, false */ 1, /* rep */ diff --git a/main.c b/main.c index 488804f..9d0a5c4 100644 --- a/main.c +++ b/main.c @@ -5,7 +5,7 @@ extern int luaopen_lpeg(lua_State *L); extern int luaopen_lfs(lua_State *L); -static struct script { const char *name; int t; const char *data; size_t sz; } embedded[] = { +static struct script { const char *name; int t; const unsigned char *data; size_t sz; } embedded[] = { { "l65cfg", 0, script_l65cfg_lua, sizeof(script_l65cfg_lua) }, { "vcs", 1, script_vcs_l65, sizeof(script_vcs_l65) }, }; @@ -17,7 +17,7 @@ static int getembedded(lua_State *L) { if (!strcmp(s->name, name)) { - lua_pushlstring(L, s->data, s->sz); + lua_pushlstring(L, (const char*)s->data, s->sz); lua_pushboolean(L, s->t); return 2; } @@ -47,14 +47,14 @@ int main(int argc, char *argv[]) // preload embedded lua scripts luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); - luaL_loadbufferx(L, script_6502_lua, sizeof(script_6502_lua), "6502.lua", "b"); + luaL_loadbufferx(L, (const char*)script_6502_lua, sizeof(script_6502_lua), "6502.lua", "b"); lua_setfield(L, -2, "6502"); lua_pop(L, 1); // error handler lua_pushcfunction(L, msghandler); // l65.lua script - luaL_loadbufferx(L, script_l65_lua, sizeof(script_l65_lua), "l65.lua", "b"); + luaL_loadbufferx(L, (const char*)script_l65_lua, sizeof(script_l65_lua), "l65.lua", "b"); // arg[] table lua_createtable(L, argc-1, 2); lua_pushcfunction(L, getembedded); // pass embedded script lookup function as arg[-1]