diff options
author | standenboy <standenboy@seacrossedlovers.xyz> | 2024-05-06 09:32:48 +0100 |
---|---|---|
committer | standenboy <standenboy@seacrossedlovers.xyz> | 2024-05-06 09:32:48 +0100 |
commit | 319e7ea0a724cd97041c1aaf1281c4ca6aa688d1 (patch) | |
tree | 7411f4636ce9ce9733760666f3311a17b6e4d17c /comp/lucas-standen-NEA/code/parser/readfile.c | |
parent | 0ca35b27de52a5d3acf5f2eb877a440c1103e928 (diff) |
added a load of stuff, and fixed a git conflict
Diffstat (limited to 'comp/lucas-standen-NEA/code/parser/readfile.c')
-rw-r--r-- | comp/lucas-standen-NEA/code/parser/readfile.c | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/comp/lucas-standen-NEA/code/parser/readfile.c b/comp/lucas-standen-NEA/code/parser/readfile.c deleted file mode 100644 index 391d5a5..0000000 --- a/comp/lucas-standen-NEA/code/parser/readfile.c +++ /dev/null @@ -1,61 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <stdbool.h> - -bool instring = false; - -char *readfile(char *filepath){ - FILE *fptr; - fptr = fopen(filepath, "r"); - - if (fptr == NULL) - return NULL; - int size = 10; - char *buf = malloc(size); - char c; - - int i = 0; - - buf = buf+i; - buf[0] = '{'; - buf = buf-i; - - i++; - - while ((c = getc(fptr)) != EOF){ - if (i > size + 1){ - size = size + 10; - buf = realloc(buf, size); - } - if (c == '"'){ - if (instring == false) - instring = true; - else - instring = false; - } - - if (c == '!' && instring == false){ - while ((c = getc(fptr)) != EOF && c != '\n'){} - } - buf = buf+i; - buf[0] = c; - buf = buf-i; - i++; - - } - - buf = buf+i; - buf[0] = '}'; - buf = buf-i; - - i++; - - buf = buf+i; - buf[0] = '\0'; - buf = buf-i; - - fclose(fptr); - - return buf; -} |