remove autoconf.h from platform.h, fix lots of includes

This commit is contained in:
Enno Rehling 2016-11-25 20:15:11 +01:00
parent 5e49ac6fdf
commit e52cf75c59
29 changed files with 131 additions and 52 deletions

View File

@ -21,6 +21,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/attrib.h>
#include <stdlib.h>
attrib_type at_fleechance = {
"fleechance",
NULL,

View File

@ -3,6 +3,7 @@
#include <util/attrib.h>
#include <CuTest.h>
#include <stdlib.h>
static void test_get_set_keys(CuTest *tc) {
attrib *a = 0;

View File

@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "matmod.h"
#include <util/attrib.h>
#include <stddef.h>
attrib_type at_matmod = {
"matmod",

View File

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_LUA_CONSOLE
#define H_LUA_CONSOLE
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -1468,7 +1468,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
/* main function of the creport. creates the header and traverses all regions */
static int
report_computer(const char *filename, report_context * ctx, const char *charset)
report_computer(const char *filename, report_context * ctx, const char *bom)
{
static int era = -1;
int i;
@ -1488,9 +1488,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
perror(filename);
return -1;
}
else if (_strcmpl(charset, "utf-8") == 0 || _strcmpl(charset, "utf8") == 0) {
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
fwrite(utf8_bom, 1, 3, F);
else if (bom) {
fwrite(bom, 1, strlen(bom), F);
}
/* must call this to get all the neighbour regions */
@ -1498,8 +1497,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
/* initialisations, header and lists */
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
fprintf(F, "\"%s\";charset\n", charset);
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
fprintf(F, "\"utf-8\";charset\n\"%s\";locale\n",
locale_name(f->locale));
fprintf(F, "%d;noskillpoints\n", 1);
fprintf(F, "%lld;date\n", (long long)ctx->report_time);
fprintf(F, "\"%s\";Spiel\n", game_name());

View File

@ -1,5 +1,4 @@
#include <platform.h>
#include <config.h>
#include "creport.h"
#include "move.h"
#include "travelthru.h"

View File

@ -1,6 +1,5 @@
$#undef tolua_reg_types
$#define tolua_reg_types tolua_reg_types_game
$#include "config.h"
$#include "bind_eressea.h"
module eressea {

View File

@ -20,7 +20,6 @@ LUALIB_API int luaopen_game (lua_State* tolua_S);
#undef tolua_reg_types
#define tolua_reg_types tolua_reg_types_game
#include "config.h"
#include "bind_eressea.h"
/* function to register type */

View File

@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/types.h>
#include <util/variant.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -24,6 +24,7 @@ extern "C" {
#endif
/* this should always be the first thing included after platform.h */
#include <stddef.h>
#include "types.h"
struct param;

View File

@ -349,7 +349,7 @@ const curse_type *ct_find(const char *c)
}
else {
size_t k = _min(c_len, strlen(type->cname));
if (!_memicmp(c, type->cname, k)) {
if (!memcmp(c, type->cname, k)) {
return type;
}
}

View File

@ -12,12 +12,14 @@
#ifndef KRNL_ORDER_H
#define KRNL_ORDER_H
#include "keyword.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "keyword.h"
/* Encapsulation of an order
*
* This structure contains one order given by a unit. These used to be

View File

@ -1,5 +1,4 @@
#include <platform.h>
#include <config.h>
#include <kernel/config.h>
#include "order.h"

View File

@ -18,13 +18,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_RACE_H
#define H_KRNL_RACE_H
#include <stddef.h>
#include "magic.h" /* wegen MAXMAGIETYP */
#include "skill.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "magic.h" /* wegen MAXMAGIETYP */
#include "skill.h"
#define AT_NONE 0
#define AT_STANDARD 1
#define AT_DRAIN_EXP 2

View File

@ -18,13 +18,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_SHIP
#define H_KRNL_SHIP
#ifdef __cplusplus
extern "C" {
#endif
#include "types.h"
#include "direction.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DAMAGE_SCALE 100 /* multiplier for sh->damage */
/* ship_type::flags */

View File

@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/variant.h>
#include "types.h"
#include "skills.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -70,11 +70,6 @@ static void load_inifile(dictionary * d)
lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0;
str = iniparser_getstring(d, "eressea:encoding", NULL);
if (str && (_strcmpl(str, "utf8") == 0 || _strcmpl(str, "utf-8") == 0)) {
enc_gamedata = ENCODING_UTF8;
}
verbosity = iniparser_getint(d, "eressea:verbose", 2);
battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0;

View File

@ -18,6 +18,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef SCORE_H
#define SCORE_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_NAMES
#define H_KRNL_NAMES
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -81,10 +81,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#endif /* _MSC_VER_ */
#if defined __GNUC__
# define _POSIX_C_SOURCE 200809L
# undef _DEFAULT_SOURCE
# define _DEFAULT_SOURCE
# undef __USE_BSD
# define __USE_BSD
# define HAVE_SNPRINTF
# define HAVE_SYS_STAT_MKDIR
# define HAVE_STRDUP
# define HAVE_UNISTD_H
#endif
#ifdef SOLARIS
@ -104,10 +109,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define TOLUA_CAST (char*)
#ifdef USE_AUTOCONF
# include <autoconf.h>
#endif
#if !defined(MAX_PATH)
#if defined(PATH_MAX)
# define MAX_PATH PATH_MAX
@ -124,5 +125,72 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <strings.h>
#endif
#if defined(HAVE_STDBOOL_H)
# include <stdbool.h>
#else
# if ! HAVE__BOOL
# ifdef __cplusplus
typedef bool _Bool;
# else
typedef unsigned char _Bool;
# endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
#endif
#ifndef HAVE__ACCESS
#ifdef HAVE_ACCESS
#define _access(path, mode) access(path, mode)
#endif
#endif
#if defined(HAVE_DIRECT__MKDIR)
#include <direct.h>
#elif defined(HAVE_DIRECT_MKDIR)
#include <direct.h>
#define _mkdir(a) mkdir(a)
#elif defined(HAVE_SYS_STAT_MKDIR)
#include <sys/stat.h>
#define _mkdir(a) mkdir(a, 0777)
#endif
#ifndef _min
#define _min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef _max
#define _max(a,b) ((a) > (b) ? (a) : (b))
#endif
#if !defined(HAVE__STRDUP)
#if defined(HAVE_STRDUP)
#define _strdup(a) strdup(a)
#else
#define _strdup(a) lcp_strdup(a)
#endif
#endif
#if !defined(HAVE__SNPRINTF)
#if defined(HAVE_SNPRINTF)
#define _snprintf snprintf
#endif
#endif
#if !defined(HAVE__STRCMPL)
#if defined(HAVE_STRCMPL)
#define _strcmpl(a, b) strcmpl(a, b)
#elif defined(HAVE__STRICMP)
#define _strcmpl(a, b) _stricmp(a, b)
#elif defined(HAVE_STRICMP)
#define _strcmpl(a, b) stricmp(a, b)
#elif defined(HAVE_STRCASECMP)
#define _strcmpl(a, b) strcasecmp(a, b)
#else
#define _strcmpl(a, b) lcp_strcmpl(a, b)
#endif
#endif
#endif

View File

@ -1379,7 +1379,7 @@ static int buildingmaintenance(const building * b, const resource_type * rtype)
}
static int
report_template(const char *filename, report_context * ctx, const char *charset)
report_template(const char *filename, report_context * ctx, const char *bom)
{
const resource_type *rsilver = get_resourcetype(R_SILVER);
faction *f = ctx->f;
@ -1389,7 +1389,6 @@ report_template(const char *filename, report_context * ctx, const char *charset)
char buf[8192], *bufp;
size_t size;
int bytes;
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
const curse_type *nocost_ct = ct_find("nocostbuilding");
if (F == NULL) {
@ -1398,9 +1397,8 @@ report_template(const char *filename, report_context * ctx, const char *charset)
}
fstream_init(&strm, F);
if (utf8) {
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
swrite(utf8_bom, 1, 3, out);
if (bom) {
swrite(bom, 1, strlen(bom), out);
}
newline(out);
@ -2026,7 +2024,7 @@ void write_travelthru(struct stream *out, region *r, const faction *f)
int
report_plaintext(const char *filename, report_context * ctx,
const char *charset)
const char *bom)
{
int flag = 0;
char ch;
@ -2044,7 +2042,6 @@ report_plaintext(const char *filename, report_context * ctx,
stream strm = { 0 }, *out = &strm;
char buf[8192];
char *bufp;
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
size_t size;
int thisseason;
int nextseason;
@ -2061,9 +2058,8 @@ report_plaintext(const char *filename, report_context * ctx,
}
fstream_init(&strm, F);
if (utf8) {
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
fwrite(utf8_bom, 1, 3, F);
if (bom) {
fwrite(bom, 1, strlen(bom), F);
}
strftime(pzTime, 64, "%A, %d. %B %Y, %H:%M", localtime(&ctx->report_time));

View File

@ -1,5 +1,4 @@
#include <platform.h>
#include <config.h>
#include "report.h"
#include "move.h"
#include "travelthru.h"

View File

@ -1401,12 +1401,10 @@ void finish_reports(report_context *ctx) {
int write_reports(faction * f, time_t ltime)
{
unsigned int backup = 1, maxbackup = 128 * 1000;
bool gotit = false;
struct report_context ctx;
const char *encoding = "UTF-8";
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
report_type *rtype;
if (noreports) {
return false;
}
@ -1423,19 +1421,12 @@ int write_reports(faction * f, time_t ltime)
rtype->extension);
join_path(reportpath(), filename, path, sizeof(path));
errno = 0;
if (rtype->write(path, &ctx, encoding) == 0) {
if (rtype->write(path, &ctx, (const char *)utf8_bom) == 0) {
gotit = true;
}
if (errno) {
char zText[64];
log_warning("retrying, error %d during %s report for faction %s", errno, rtype->extension, factionname(f));
sprintf(zText, "waiting %u seconds before we retry", backup);
perror(zText);
_sleep(backup);
if (backup < maxbackup) {
backup *= 2;
}
error = errno;
log_fatal("error %d during %s report for faction %s: %s", errno, rtype->extension, factionname(f), strerror(error));
errno = 0;
}
} while (error);

View File

@ -1,5 +1,4 @@
#include <platform.h>
#include <config.h>
#include "reports.h"
#include "move.h"

View File

@ -3,6 +3,8 @@
#include <kernel/messages.h>
#include <util/language.h>
#include <stdlib.h>
static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, const struct curse * c, int self)
{
if (typ == TYP_UNIT) {

View File

@ -12,6 +12,9 @@
#ifndef H_UTIL_NRMESSAGE
#define H_UTIL_NRMESSAGE
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -10,6 +10,9 @@
#ifndef UTIL_PARSER_H
#define UTIL_PARSER_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef STRINGS_H
#define STRINGS_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -12,6 +12,9 @@
#ifndef H_UTIL_TRANSLATION
#define H_UTIL_TRANSLATION
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif