From 7be0923d486cd6ed2e304d3673146563ad677ea7 Mon Sep 17 00:00:00 2001 From: c+1 Date: Fri, 17 Nov 2023 10:59:06 -0500 Subject: Minor tweaks to cli --- src/include/tree.h | 6 ++++++ src/source.c | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/include/tree.h b/src/include/tree.h index d529bff..fa64fce 100644 --- a/src/include/tree.h +++ b/src/include/tree.h @@ -64,4 +64,10 @@ typedef struct TREE { tree_t* tree_init(int type); void tree_destroy(tree_t* tree); +/* TODO: + + Array of targets, for now just linear but implement something better in the future + tree_targ_t struct contains pointer to a tree_t +*/ + #endif diff --git a/src/source.c b/src/source.c index d0c39b3..f5f3ab1 100644 --- a/src/source.c +++ b/src/source.c @@ -31,10 +31,18 @@ char* source_get_from_fpath(char* path) { char* source_get_from_stdin() { char* src; + size_t l; src = ecalloc(256, sizeof(char)); + l = 0; - src = fgets(src, 256, stdin); + while (fgets(src + l, 20, stdin) != NULL) { + l += strlen(src + l); + } + + (src[l - 1] == '\n') && (src[l - 1] = '\0'); + +// src = fgets(src, 256, stdin); return src; } -- cgit v1.2.3