aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordx <aryadevchavali1@gmail.com>2020-05-07 01:23:45 +0100
committerdx <aryadevchavali1@gmail.com>2020-05-07 01:23:45 +0100
commite0072175f5195088542b6080ec55102ecbaa1b05 (patch)
treed22734b8a939027ac54be1479102f3518c472f83
parent991acdace4cce69c816b1ca661d87e3affa2258c (diff)
downloadmdhtml-e0072175f5195088542b6080ec55102ecbaa1b05.tar.gz
mdhtml-e0072175f5195088542b6080ec55102ecbaa1b05.tar.bz2
mdhtml-e0072175f5195088542b6080ec55102ecbaa1b05.zip
+!fix for REPL bug with missing end tags
When using fgets(), the returned string doesn't have a null terminator but rather a newline (you use a RET to end input). So I made a little script portion dedicate to finding the first newline and wholly removing it.
-rw-r--r--Converter/src/main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Converter/src/main.c b/Converter/src/main.c
index fbcd938..f9c96a3 100644
--- a/Converter/src/main.c
+++ b/Converter/src/main.c
@@ -24,12 +24,19 @@ int main(int argc, char *argv[])
else
{
+ int i;
+ char *buf;
while (1)
{
+
printf("> ");
- char *buf = malloc(sizeof(*buf) * 1024);
+ buf = malloc(sizeof(*buf) * 1024);
fgets(buf, 1024, stdin);
- string output = (compile_line(buf, 1024, "<stdin>"));
+
+ for (i = 0; buf[i] != '\n'; ++i) continue;
+ buf[i] = '\0'; // terminate
+
+ string output = (compile_line(buf, strlen(buf), "<stdin>"));
puts(output);
free(output);
}