From 7578a9d04b666cff3f02aa2d2c1b2cce8a3d3939 Mon Sep 17 00:00:00 2001 From: kartofen Date: Fri, 11 Nov 2022 00:24:24 +0200 Subject: add bigger stack fix --- src/markov.h | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/markov.h') diff --git a/src/markov.h b/src/markov.h index 1c95775..ca879f3 100644 --- a/src/markov.h +++ b/src/markov.h @@ -7,20 +7,28 @@ #include #include +#ifndef WALK_LEN +#define WALK_LEN 0 +#endif + +#ifndef FILE_PATH +#define FILE_PATH "" +#endif + +#ifndef ITEM_CAP +#define ITEM_CAP 1024 +#endif + extern int ITEMS; extern double chain[][ITEM_CAP]; extern char item_names[][64]; void generate_chain() { - char *file_path = NULL; - #ifdef FILE_PATH - file_path = FILE_PATH; - #endif - - FILE *fp = fopen(file_path, "r"); + printf("%s\n", FILE_PATH); + FILE *fp = fopen(FILE_PATH, "r"); if(!fp) { - fprintf(stderr, "ERROR: Could not open file %s\n", file_path); + fprintf(stderr, "ERROR: Could not open file %s\n", FILE_PATH); exit(EXIT_FAILURE); } @@ -33,7 +41,8 @@ void generate_chain() { if(ch != ' ' && ch != ',' && ch != '"' && ch != '\n' && ch != '[' && ch != ']' && - ch != '!' && ch != '?' && ch != '.') { + ch != '!' && ch != '?' && ch != '.' && + ch != ';' && ch != ':') { word[strlen(word)] = tolower(ch); continue; } @@ -49,6 +58,7 @@ void generate_chain() if(item == ITEMS) { ITEMS++; + assert(ITEMS <= ITEM_CAP); strcpy(item_names[item], word); } @@ -60,7 +70,8 @@ void generate_chain() manage_cur_item: if(ch == '\n' || ch == '[' || ch == ']' || - ch == '!' || ch == '?' || ch == '.') + ch == '!' || ch == '?' || ch == '.' || + ch == ';' || ch == ':') cur_item = -1; memset(word, 0, sizeof(word)); -- cgit v1.2.3