Update to latest submodules, fix iniparser and critbit.

I did this before, must have lost it in the merge. Crazy.
This commit is contained in:
Enno Rehling 2015-07-12 10:35:09 +02:00
parent 11e1fab0d0
commit 7087c0e0ab
23 changed files with 1741 additions and 36 deletions

30
.travis.yml.orig Normal file
View File

@ -0,0 +1,30 @@
sudo: false
language: c
compiler:
<<<<<<< HEAD
- gcc
- clang
before_install:
- sudo apt-get update -qq
install:
- sudo apt-get install -qq zlib1g-dev libtolua-dev liblua5.1-dev libncurses5-dev libsqlite3-dev libxml2-dev valgrind clang
script:
- s/travis-build
=======
- gcc
- clang
script: s/travis-build
addons:
apt:
packages:
- liblua5.2-dev
- libncurses5-dev
- libsqlite3-dev
- libxml2-dev
>>>>>>> hotfix-3.4.1
os:
- linux
- osx
notifications:
slack:
secure: F89aXLWaE125PaJIlETv12jT4EfH6wLXJmGCPZzrN3OcLn2ahDWqjwuzR7lOEDf2nAISmeMPyDZMhEHXLNHAE5qP6lg9yliYQw5hzGmDK9m1xUq/pPEne/b2Y7K3my1mkRZ6n3asbHgSmBWAfCIk1JN8R5Rv+rmbLuWLc+zofts=

2
cmake

@ -1 +1 @@
Subproject commit ce0a1c882fa44b882c29cc8c68012295328dc352 Subproject commit f1fb3943ace59994d90d71a891b80033dc2700a2

@ -1 +1 @@
Subproject commit b38f6f8acdc2ce5b0613a4bb2ff8082051a25ac3 Subproject commit e538739b38593b90312831a5e52d2e3bd731069b

2
cutest

@ -1 +1 @@
Subproject commit 788659594ef87e9f497b8039da764182adfd2943 Subproject commit 6e268687dbf6ae55afb63210c3753530d216a622

@ -1 +1 @@
Subproject commit 4292cd5e81395d09a7457ab93659ea3b7784e958 Subproject commit f1446c47ca1774ae84bf86a28502e91daf6b421a

@ -1 +1 @@
Subproject commit f84066fb7d3254bdd9e89694acc4c1c20d001eed Subproject commit ecf956b9808c28c2db52e6b73930f57876dbb258

@ -1 +1 @@
Subproject commit 40ae383100a8f012393ab29bc3d98e182fe57c19 Subproject commit 45f4577b8205d87b78d2b1f30b5c9baa25c86779

48
s/build.orig Normal file
View File

@ -0,0 +1,48 @@
#!/bin/sh
ROOT=`pwd`
while [ ! -d $ROOT/.git ]; do
ROOT=`dirname $ROOT`
done
<<<<<<< HEAD
[ -z $BUILD ] && BUILD=Debug
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BIN_DIR="build-$MACHINE-$CC-$BUILD"
=======
[ -z "$CC" ] && CC=clang
[ -z "$BUILD" ] && BUILD=Debug
>>>>>>> hotfix-3.4.1
[ -z "$JOBS" ] && [ "" != "which nproc" ] && JOBS=`nproc`
DISTCC=`which distcc`
if [ ! -z "$DISTCC" ] ; then
JOBS=`distcc -j`
if [ -z "$JOBS" ] ; then
JOBS=1
elif [ $JOBS -gt 1 ] ; then
CC="$DISTCC $CC"
MAKEOPTS=-j$JOBS
fi
fi
echo "Building with CC=$CC and $JOBS jobs"
if [ ! -d $ROOT/$BUILD ]; then
echo "cannot find build directory $BUILD in $ROOT. did you run cmake-init?"
exit
fi
git submodule update
if [ -z `which tolua` ]; then
echo "build tolua"
cd $ROOT/tolua ; make
fi
echo "build eressea"
cd $ROOT/$BUILD
make $MAKEOPTS && make test
cd $OLDPWD

80
s/cmake-init.orig Normal file
View File

@ -0,0 +1,80 @@
#!/bin/sh
ROOT=$(pwd)
while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
if [ "$ROOT" == "/" ; then
echo "could not find root, are you in the git repository?"
exit
fi
done
[ -z $BUILD ] && BUILD=Debug
MACHINE=`uname -m`
<<<<<<< HEAD
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
=======
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="clang"
>>>>>>> hotfix-3.4.1
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD"
mkdir -p $BIN_DIR
ln -sf $BIN_DIR $BUILD
MACHINE=$(gcc -dumpmachine)
rm -f CMakeCache.txt
# use anything installed in /opt or /usr
LIBRARY_PATH=/opt/lib:/opt/lib/$MACHINE:/usr/lib/$MACHINE
INCLUDE_PATH=/opt/include:/usr/include
PREFIX_PATH=/opt
# I like to put stuff in ~/usr if I don't have permission to install packages on the machine:
if [ -d $HOME/usr ]; then
LIBRARY_PATH=$HOME/usr/lib:$HOME/usr/lib/$MACHINE:$LIBRARY_PATH
INCLUDE_PATH=$HOME/usr/include:$HOME/usr/include/$MACHINE:$INCLUDE_PATH
PREFIX_PATH=$HOME/usr:$HOME/usr/local:$PREFIX_PATH
fi
<<<<<<< HEAD
if [ -z $PC_LUA ] && [ -e /opt/include/lua.h ]; then
PC_LUA=/opt/include
fi
if [ -z $PC_TOLUA ] && [ -e /opt/include/tolua.h ]; then
PC_TOLUA=/opt/include
fi
if [ ! -z $PC_TOLUA ]; then
PC_ARGS="$PC_ARGS -DPC_TOLUA_INCLUDEDIR=$PC_TOLUA/include -DPC_TOLUA_LIBDIR=$PC_TOLUA/lib"
fi
if [ ! -z $PC_LUA ]; then
PC_ARGS="$PC_ARGS -DPC_LUA_INCLUDEDIR=$PC_LUA/include -DPC_LUA_LIBDIR=$PC_LUA/lib"
fi
cmake .. $PC_ARGS \
-DCMAKE_MODULE_PATH=$PWD/../cmake/Modules \
=======
ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \
>>>>>>> hotfix-3.4.1
-DCMAKE_BUILD_TYPE=$BUILD \
-DCMAKE_LIBRARY_PATH=$LIBRARY_PATH \
-DCMAKE_INCLUDE_PATH=$INCLUDE_PATH \
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
-DCMAKE_INSTALL_PREFIX=$HOME/eressea/server"
path="$(which tolua)"
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
echo "tolua is not installed, building from source"
cd $ROOT/tolua ; make
ARGS="$ARGS -DPC_TOLUA_DIR=$ROOT/tolua"
else
echo "tolua is $path"
fi
unset path
set -e
cd $BIN_DIR
cmake .. $ARGS $*
cd $OLDPWD

37
s/runtests.orig Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
set -e
ROOT=$(pwd)
while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
done
<<<<<<< HEAD
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BIN_DIR="build-$MACHINE-$CC-Debug"
=======
[ -z $BUILD ] && BUILD=Debug ; export BUILD
>>>>>>> hotfix-3.4.1
if [ ! -e $ROOT/$BUILD ]; then
echo "cannot find build directory $BUILD in $ROOT. did you run cmake-init?"
exit
fi
$ROOT/$BUILD/eressea/test_eressea
cd $ROOT
[ -e eressea.ini ] || ln -sf conf/eressea.ini
<<<<<<< HEAD
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests.lua
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e2.lua
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e3.lua
=======
$ROOT/$BUILD/eressea/eressea -v0 sacripts/run-tests.lua
$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua
>>>>>>> hotfix-3.4.1
cd $OLDWPD

83
s/travis-build.orig Normal file
View File

@ -0,0 +1,83 @@
#!/bin/sh
<<<<<<< HEAD
set -e
ROOT=`pwd`
SUPP=../share/ubuntu-12_04.supp
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
BUILD="$ROOT/build-$MACHINE-$CC-Debug"
=======
ROOT=`pwd`
>>>>>>> hotfix-3.4.1
inifile() {
cd $ROOT
if [ ! -e eressea.ini ]; then
cp conf/eressea.ini .
$BUILD/iniparser/inifile eressea.ini add lua:paths lunit:scripts
fi
}
<<<<<<< HEAD
build() {
cd $BUILD
cmake -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules -DCMAKE_BUILD_TYPE=Debug ..
scan-build make
}
test_valgrind_report () {
cd $ROOT/tests
ln -sf ../scripts/config.lua
valgrind --suppressions=$SUPP --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/reports.lua
}
test_valgrind_turn () {
cd $ROOT/tests
ln -sf ../scripts/config.lua
valgrind --suppressions=$SUPP --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/run-turn.lua
}
test_unittests() {
$BUILD/eressea/test_eressea
}
cleanup() {
cd $ROOT/tests
rm -rf reports score eressea.log* config.lua data/185.dat datum passwd parteien parteien.full turn
}
test_server() {
cd $ROOT
inifile
$BUILD/eressea/eressea -v0 scripts/run-tests.lua
$BUILD/eressea/eressea -v0 scripts/run-tests-e2.lua
$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua
}
# information
echo "* base directory: $ROOT"
echo "* build directory: $BUILD"
echo "* lsb_release:"
lsb_release -a
echo "* zlib1g-dev package:"
dpkg -l zlib1g-dev
echo
# build the code
[ -d $BUILD ] || mkdir $BUILD
build
test_unittests
test_server
test_valgrind_report
test_valgrind_turn
cleanup
=======
[ -z $BUILD ] && BUILD=Debug ; export BUILD
s/cmake-init
s/build
cd $ROOT
inifile
s/runtests
>>>>>>> hotfix-3.4.1

View File

@ -355,7 +355,7 @@ static int tolua_region_get_resource(lua_State * L)
const char *type; const char *type;
const resource_type *rtype; const resource_type *rtype;
int result = 0; int result = 0;
const void * matches; void * matches;
critbit_tree * cb = special_resources(); critbit_tree * cb = special_resources();
r = (region *)tolua_tousertype(L, 1, 0); r = (region *)tolua_tousertype(L, 1, 0);
@ -399,7 +399,7 @@ static int tolua_region_set_resource(lua_State * L)
const char *type = tolua_tostring(L, 2, 0); const char *type = tolua_tostring(L, 2, 0);
int result, value = (int)tolua_tonumber(L, 3, 0); int result, value = (int)tolua_tonumber(L, 3, 0);
critbit_tree * cb = special_resources(); critbit_tree * cb = special_resources();
const void * matches; void * matches;
if (cb_find_prefix(cb, type, strlen(type) + 1, &matches, 1, 0)) { if (cb_find_prefix(cb, type, strlen(type) + 1, &matches, 1, 0)) {
cb_get_kv(matches, &result, sizeof(result)); cb_get_kv(matches, &result, sizeof(result));

View File

@ -686,7 +686,7 @@ param_t findparam(const char *s, const struct locale * lang)
if (str && *str) { if (str && *str) {
int i; int i;
const void * match; void * match;
void **tokens = get_translations(lang, UT_PARAMS); void **tokens = get_translations(lang, UT_PARAMS);
critbit_tree *cb = (critbit_tree *)*tokens; critbit_tree *cb = (critbit_tree *)*tokens;
if (!cb) { if (!cb) {

View File

@ -384,7 +384,7 @@ const potion_type *resource2potion(const resource_type * rtype)
resource_type *rt_find(const char *name) resource_type *rt_find(const char *name)
{ {
const void * matches; void * matches;
resource_type *result = 0; resource_type *result = 0;
if (cb_find_prefix(&cb_resources, name, strlen(name) + 1, &matches, 1, 0)) { if (cb_find_prefix(&cb_resources, name, strlen(name) + 1, &matches, 1, 0)) {
@ -1069,7 +1069,7 @@ const resource_type *findresourcetype(const char *name, const struct locale *lan
char buffer[128]; char buffer[128];
if (transliterate(buffer, sizeof(buffer), name)) { if (transliterate(buffer, sizeof(buffer), name)) {
const void * match; void * match;
if (!cb->root) { if (!cb->root) {
/* first-time initialization of resource names for this locale */ /* first-time initialization of resource names for this locale */
cb_foreach(&cb_resources, "", 0, add_resourcename_cb, (void *)lang); cb_foreach(&cb_resources, "", 0, add_resourcename_cb, (void *)lang);
@ -1122,7 +1122,7 @@ const item_type *finditemtype(const char *name, const struct locale *lang)
assert(name); assert(name);
if (transliterate(buffer, sizeof(buffer), name)) { if (transliterate(buffer, sizeof(buffer), name)) {
const void * match; void * match;
if (!cb->root) { if (!cb->root) {
/* first-time initialization of item names for this locale */ /* first-time initialization of item names for this locale */
cb_foreach(&cb_resources, "", 0, add_itemname_cb, (void *)lang); cb_foreach(&cb_resources, "", 0, add_itemname_cb, (void *)lang);

1426
src/kernel/region.c.orig Normal file

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,7 @@ keyword_t get_keyword(const char *s, const struct locale *lang) {
if (str) { if (str) {
int i; int i;
const void *match; void *match;
void **tokens = get_translations(lang, UT_KEYWORDS); void **tokens = get_translations(lang, UT_KEYWORDS);
critbit_tree *cb = (critbit_tree *)*tokens; critbit_tree *cb = (critbit_tree *)*tokens;
if (cb && cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) { if (cb && cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {

View File

@ -2962,7 +2962,7 @@ spellbook * get_spellbook(const char * name)
{ {
char buffer[64]; char buffer[64];
spellbook * result; spellbook * result;
const void * match; void * match;
if (cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0)) { if (cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0)) {
cb_get_kv(match, &result, sizeof(result)); cb_get_kv(match, &result, sizeof(result));

View File

@ -80,13 +80,13 @@ static void load_inifile(dictionary * d)
str = iniparser_getstring(d, "eressea:locales", "de,en"); str = iniparser_getstring(d, "eressea:locales", "de,en");
make_locales(str); make_locales(str);
if (global.inifile) iniparser_free(global.inifile); if (global.inifile) iniparser_freedict(global.inifile);
global.inifile = d; global.inifile = d;
} }
static void parse_config(const char *filename) static void parse_config(const char *filename)
{ {
dictionary *d = iniparser_new(filename); dictionary *d = iniparser_load(filename);
if (d) { if (d) {
load_inifile(d); load_inifile(d);
log_debug("reading from configuration file %s\n", filename); log_debug("reading from configuration file %s\n", filename);
@ -132,32 +132,33 @@ static int parse_args(int argc, char **argv, int *exitcode)
int i; int i;
for (i = 1; i != argc; ++i) { for (i = 1; i != argc; ++i) {
if (argv[i][0] != '-') { char *argi = argv[i];
luafile = argv[i]; if (argi[0] != '-') {
luafile = argi;
} }
else if (argv[i][1] == '-') { /* long format */ else if (argi[1] == '-') { /* long format */
if (strcmp(argv[i] + 2, "version") == 0) { if (strcmp(argi + 2, "version") == 0) {
printf("\n%s PBEM host\n" printf("\n%s PBEM host\n"
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n" "Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %d.%d.%d\n\n", "Compilation: " __DATE__ " at " __TIME__ "\nVersion: %d.%d.%d\n\n",
game_name(), VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); game_name(), VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
#ifdef USE_CURSES #ifdef USE_CURSES
} }
else if (strcmp(argv[i] + 2, "color") == 0) { else if (strcmp(argi + 2, "color") == 0) {
/* force the editor to have colors */ /* force the editor to have colors */
force_color = 1; force_color = 1;
#endif #endif
} }
else if (strcmp(argv[i] + 2, "help") == 0) { else if (strcmp(argi + 2, "help") == 0) {
return usage(argv[0], NULL); return usage(argv[0], NULL);
} }
else { else {
return usage(argv[0], argv[i]); return usage(argv[0], argi);
} }
} }
else { else {
const char *arg; const char *arg;
switch (argv[i][1]) { switch (argi[1]) {
case 'r': case 'r':
i = get_arg(argc, argv, 2, i, &arg, 0); i = get_arg(argc, argv, 2, i, &arg, 0);
set_param(&global.parameters, "config.rules", arg); set_param(&global.parameters, "config.rules", arg);
@ -184,7 +185,7 @@ static int parse_args(int argc, char **argv, int *exitcode)
return 1; return 1;
default: default:
*exitcode = -1; *exitcode = -1;
usage(argv[0], argv[i]); usage(argv[0], argi);
return 1; return 1;
} }
} }
@ -317,7 +318,7 @@ int main(int argc, char **argv)
lua_done(L); lua_done(L);
log_close(); log_close();
if (global.inifile) { if (global.inifile) {
iniparser_free(global.inifile); iniparser_freedict(global.inifile);
} }
return 0; return 0;
} }

View File

@ -97,7 +97,7 @@ skill_t get_skill(const char *s, const struct locale * lang)
char * str = transliterate(buffer, sizeof(buffer) - sizeof(int), s); char * str = transliterate(buffer, sizeof(buffer) - sizeof(int), s);
if (str) { if (str) {
int i; int i;
const void * match; void * match;
void **tokens = get_translations(lang, UT_SKILLS); void **tokens = get_translations(lang, UT_SKILLS);
struct critbit_tree *cb = (critbit_tree *)*tokens; struct critbit_tree *cb = (critbit_tree *)*tokens;
if (cb && cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) { if (cb && cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {

View File

@ -39,7 +39,7 @@ static unsigned int __at_hashkey(const char *s)
while (i > 0) { while (i > 0) {
key = (s[--i] + key * 37); key = (s[--i] + key * 37);
} }
return key & 0x7fffffff; return key & 0x7fffffff; //TODO: V112 http://www.viva64.com/en/V112 Dangerous magic number 0x7fffffff used: return key & 0x7fffffff;.
} }
void at_register(attrib_type * at) void at_register(attrib_type * at)
@ -47,7 +47,7 @@ void at_register(attrib_type * at)
attrib_type *find; attrib_type *find;
if (at->read == NULL) { if (at->read == NULL) {
log_warning("registering non-persistent attribute %s.\n", at->name); log_warning("registering non-persistent attribute %s.\n", at->name); //TODO: V111 http://www.viva64.com/en/V111 Call of function 'log_warning' with variable number of arguments. Second argument has memsize type.
} }
at->hashkey = __at_hashkey(at->name); at->hashkey = __at_hashkey(at->name);
find = at_hash[at->hashkey % MAXATHASH]; find = at_hash[at->hashkey % MAXATHASH];
@ -55,7 +55,7 @@ void at_register(attrib_type * at)
find = find->nexthash; find = find->nexthash;
} }
if (find && find == at) { if (find && find == at) {
log_warning("attribute '%s' was registered more than once\n", at->name); log_warning("attribute '%s' was registered more than once\n", at->name); //TODO: V111 http://www.viva64.com/en/V111 Call of function 'log_warning' with variable number of arguments. Second argument has memsize type.
return; return;
} }
else { else {
@ -299,7 +299,7 @@ int a_read(struct storage *store, attrib ** attribs, void *owner)
na = a_new(at); na = a_new(at);
} }
else { else {
const void * kv = 0; void * kv = 0;
cb_find_prefix(&cb_deprecated, zText, strlen(zText) + 1, &kv, 1, 0); cb_find_prefix(&cb_deprecated, zText, strlen(zText) + 1, &kv, 1, 0);
if (kv) { if (kv) {
cb_get_kv(kv, &reader, sizeof(reader)); cb_get_kv(kv, &reader, sizeof(reader));

View File

@ -30,14 +30,14 @@ extern "C" {
typedef struct attrib { typedef struct attrib {
const struct attrib_type *type; const struct attrib_type *type;
union { union {
afun f; afun f; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union.
void *v; void *v; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union.
int i; int i;
float flt; float flt;
char c; char c;
short s; short s;
short sa[2]; short sa[2];
char ca[4]; char ca[4]; //TODO: V112 http://www.viva64.com/en/V112 Dangerous magic number 4 used: char ca[4];.
} data; } data;
/* internal data, do not modify: */ /* internal data, do not modify: */
struct attrib *next; /* next attribute in the list */ struct attrib *next; /* next attribute in the list */

View File

@ -30,7 +30,7 @@ static critbit_tree cb_functions;
pf_generic get_function(const char *name) pf_generic get_function(const char *name)
{ {
const void * matches; void * matches;
pf_generic result; pf_generic result;
if (cb_find_prefix(&cb_functions, name, strlen(name) + 1, &matches, 1, 0)) { if (cb_find_prefix(&cb_functions, name, strlen(name) + 1, &matches, 1, 0)) {
cb_get_kv(matches, &result, sizeof(result)); cb_get_kv(matches, &result, sizeof(result));

View File

@ -168,7 +168,7 @@ void add_function(const char *symbol, evalfun parse)
static evalfun find_function(const char *symbol) static evalfun find_function(const char *symbol)
{ {
const void * matches; void * matches;
if (cb_find_prefix(&functions, symbol, strlen(symbol) + 1, &matches, 1, 0)) { if (cb_find_prefix(&functions, symbol, strlen(symbol) + 1, &matches, 1, 0)) {
evalfun result; evalfun result;
cb_get_kv(matches, &result, sizeof(result)); cb_get_kv(matches, &result, sizeof(result));