summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'config.c')
-rw-r--r--config.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/config.c b/config.c
index 9d71ceb..c434a43 100644
--- a/config.c
+++ b/config.c
@@ -9,7 +9,13 @@
#include <stdlib.h>
#include <string.h>
-#ifdef _WIN32
+#ifdef __MINGW64_VERSION_MAJOR
+#define MINGW_W64_VERSION (__MINGW64_VERSION_MAJOR * 1000 + __MINGW64_VERSION_MINOR)
+#else
+#define MINGW_W64_VERSION 0
+#endif
+
+#if defined(_WIN32) && (MINGW_W64_VERSION < 3003)
char * strtok_r(char * input, char * sep, char ** state)
{
if (input) {
@@ -42,11 +48,11 @@ tern_node * parse_config_int(char **state, int started, int *line)
curline = strip_ws(curline);
int len = strlen(curline);
if (!len) {
- *line++;
+ *line = *line + 1;
continue;
}
if (curline[0] == '#') {
- *line++;
+ *line = *line + 1;
continue;
}
if (curline[0] == '}') {
@@ -60,7 +66,7 @@ tern_node * parse_config_int(char **state, int started, int *line)
if (*end == '{') {
*end = 0;
curline = strip_ws(curline);
- *line++;
+ *line = *line + 1;
head = tern_insert_node(head, curline, parse_config_int(state, 1, line));
} else {
char * val = strip_ws(split_keyval(curline));
@@ -70,7 +76,7 @@ tern_node * parse_config_int(char **state, int started, int *line)
} else {
fprintf(stderr, "Key %s is missing a value on line %d\n", key, *line);
}
- *line++;
+ *line = *line + 1;
}
}
return head;
@@ -93,10 +99,12 @@ tern_node * parse_config_file(char * config_path)
if (!config_size) {
goto config_empty;
}
- char * config_data = malloc(config_size);
+ char * config_data = malloc(config_size+1);
if (fread(config_data, 1, config_size, config_file) != config_size) {
goto config_read_fail;
}
+ config_data[config_size] = '\0';
+
ret = parse_config(config_data);
config_read_fail:
free(config_data);