From c460a26850eca5ded047d0eb0d183b861087aa53 Mon Sep 17 00:00:00 2001 From: standenboy Date: Tue, 30 Apr 2024 14:22:45 +0100 Subject: write up update --- comp/cw/code/parser/readfile.c | 61 ------------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 comp/cw/code/parser/readfile.c (limited to 'comp/cw/code/parser/readfile.c') diff --git a/comp/cw/code/parser/readfile.c b/comp/cw/code/parser/readfile.c deleted file mode 100644 index 391d5a5..0000000 --- a/comp/cw/code/parser/readfile.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include -#include -#include - -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; -} -- cgit v1.2.3