Skip to content

Commit 7704b82

Browse files
committed
add ci scripts.
1 parent 5efe9f7 commit 7704b82

File tree

5 files changed

+180
-139
lines changed

5 files changed

+180
-139
lines changed

.travis.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
language: c
2+
sudo: false
3+
4+
env:
5+
global:
6+
- LUAROCKS=2.4.3
7+
- ROCKSPEC=rockspecs/lua-protobuf-scm-1.rockspec
8+
matrix:
9+
- LUA="lua 5.1"
10+
- LUA="lua 5.2"
11+
- LUA="lua 5.3"
12+
- LUA="luajit 2.0"
13+
- LUA="luajit 2.1"
14+
15+
branches:
16+
only:
17+
- master
18+
- new
19+
20+
before_install:
21+
- pip install --user hererocks urllib3[secure] cpp-coveralls
22+
- hererocks env --$LUA -rlatest # Use latest LuaRocks, install into 'env' directory.
23+
- source env/bin/activate # Add directory with all installed binaries to PATH.
24+
25+
install:
26+
# - sudo luarocks make $ROCKSPEC CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage"
27+
- luarocks make $ROCKSPEC CFLAGS="-O3 -fPIC -Wall -Wextra --coverage" LIBFLAG="-shared --coverage"
28+
29+
script:
30+
- lua test.lua
31+
# - lunit.sh test.lua
32+
33+
after_success:
34+
- coveralls
35+
# - coveralls -b .. -r .. --dump c.report.json
36+
# - luacov-coveralls -j c.report.json -v
37+
38+
notifications:
39+
email:
40+
on_success: change
41+
on_failure: always
42+
43+
# vim: ft=yaml nu et sw=2 fdc=2 fdm=syntax

pb.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
# define LUA_OK 0
2929
# define lua_rawlen lua_objlen
30-
# define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
3130
# define luaL_setfuncs(L,l,n) (assert(n==0), luaL_register(L,NULL,l))
3231
# define luaL_setmetatable(L, name) \
3332
(luaL_getmetatable((L), (name)), lua_setmetatable(L, -2))
@@ -49,12 +48,22 @@ void lua_rawsetp(lua_State *L, int idx, const void *p) {
4948
lua_rawset(L, relindex(idx, 1));
5049
}
5150

51+
#ifndef luaL_newlib /* not LuaJIT 2.1 */
52+
#define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
53+
5254
static lua_Integer lua_tointegerx(lua_State *L, int idx, int *isint) {
5355
lua_Integer i = lua_tointeger(L, idx);
5456
if (isint) *isint = (i != 0 || lua_type(L, idx) == LUA_TNUMBER);
5557
return i;
5658
}
5759

60+
static lua_Number lua_tonumberx(lua_State *L, int idx, int *isnum) {
61+
lua_Number i = lua_tonumber(L, idx);
62+
if (isnum) *isnum = (i != 0 || lua_type(L, idx) == LUA_TNUMBER);
63+
return i;
64+
}
65+
#endif
66+
5867
#ifdef LUAI_BITSINT /* not LuaJIT */
5968
#include <errno.h>
6069
static int luaL_fileresult(lua_State *L, int stat, const char *fname) {
@@ -834,7 +843,7 @@ static int Lslice_enter(lua_State *L) {
834843
pb_SliceExt view;
835844
if (lua_isnoneornil(L, 2)) {
836845
if (pb_readbytes(&s->curr.base, &view.base) == 0)
837-
argerror(L, 1, "bytes wireformat expected at offset %d",
846+
return argerror(L, 1, "bytes wireformat expected at offset %d",
838847
lpb_offset(&s->curr));
839848
view.head = view.base.p;
840849
lpb_enterview(L, s, view);
@@ -1412,7 +1421,7 @@ LUALIB_API int luaopen_pb(lua_State *L) {
14121421
return 1;
14131422
}
14141423

1415-
/* cc: flags+='-ggdb -pedantic -std=c90 -Wall -Wextra --coverage'
1424+
/* cc: flags+='-O3 -ggdb -pedantic -std=c90 -Wall -Wextra --coverage'
14161425
* maccc: flags+='-shared -undefined dynamic_lookup' output='pb.so'
14171426
* win32cc: flags+='-mdll -DLUA_BUILD_AS_DLL ' output='pb.dll' libs+='-llua53' */
14181427

0 commit comments

Comments
 (0)