aboutsummaryrefslogtreecommitdiff
path: root/src/source.c
diff options
context:
space:
mode:
authorc2024-02-03 17:34:25 -0500
committerc2024-02-03 17:34:25 -0500
commit7dbec8d29413d62967ed7eb5854dd56b1a2814ab (patch)
treeafc43e283ded4d99a1d1050617e3e0ecdf68e3ee /src/source.c
parent0b84414bdde53b367bc28563a6936513c4d3b50c (diff)
Parser now parses blocks and simple calls.
Diffstat (limited to 'src/source.c')
-rw-r--r--src/source.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/source.c b/src/source.c
index 813e9f5..bf6655c 100644
--- a/src/source.c
+++ b/src/source.c
@@ -12,7 +12,7 @@ char* source_get_from_fpath(char* path) {
char* src;
f = fopen(path, "rb");
- if (!f) { die("source file not found: %s", path); }
+ if (!f) { DIEF("source file not found: %s", path); }
fseek(f, 0L, SEEK_END);
f_size = ftell(f);
@@ -23,7 +23,7 @@ char* source_get_from_fpath(char* path) {
if ((fread(src, f_size, 1, f) != 1) || !src) {
fclose(f);
free(src);
- die("could not read source file: %s", path);
+ DIEF("could not read source file: %s", path);
}
return src;
@@ -34,16 +34,21 @@ char* source_get_from_stdin() {
char* src;
size_t l;
+#if 0
l = 0;
src = ecalloc(16, sizeof(char));
while ((s = fgets(src + l, 20, stdin))) {
- l = MIN(16, l + strlen(src + l));
+ l = MIN(15, l + strlen(src + l));
}
/* This works, I guess. */
s && src[l - 1] == '\n' && (src[l - 1] = '\0');
+#endif
- return src;
+ src = ecalloc(256, sizeof(char));
+ fgets(src, 256, stdin);
+
+ return src;
}