aboutsummaryrefslogtreecommitdiff
path: root/src/markov.h
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-11-11 00:24:24 +0200
committerkartofen <mladenovnasko0@gmail.com>2022-11-11 00:24:24 +0200
commit7578a9d04b666cff3f02aa2d2c1b2cce8a3d3939 (patch)
treeaaa7b7a7aae5f893d38e649ff3001206f6c9dd5b /src/markov.h
parent6516b26acec2abd862a3c1f42886e749e2dfad5c (diff)
add bigger stack fixHEADmaster
Diffstat (limited to 'src/markov.h')
-rw-r--r--src/markov.h29
1 files changed, 20 insertions, 9 deletions
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 <string.h>
#include <ctype.h>
+#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));