From 45bb26d97f454788e16f89c4d5589141dd29abb1 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 9 Feb 2018 17:15:31 +0000 Subject: [PATCH] fixed the way to drive hcl in main.c --- lib/main.c | 12 +++++++++--- lib/read.c | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/main.c b/lib/main.c index 673dbf3..940789a 100644 --- a/lib/main.c +++ b/lib/main.c @@ -1601,10 +1601,10 @@ int main (int argc, char* argv[]) hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot read object - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); } - break; + if (!xtn->reader_istty) goto oops; + continue; } - if (hcl_print(hcl, obj) <= -1) { hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot print object - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); @@ -1627,6 +1627,8 @@ int main (int argc, char* argv[]) hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot compile object - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); } /* carry on? */ + + if (!xtn->reader_istty) goto oops; } else if (xtn->reader_istty) { @@ -1660,7 +1662,11 @@ int main (int argc, char* argv[]) /*hcl_dumpsymtab (hcl);*/ } - hcl_close (hcl); + hcl_close (hcl); return 0; + +oops: + hcl_close (hcl); + return -1; } diff --git a/lib/read.c b/lib/read.c index fcb0363..5053ec1 100644 --- a/lib/read.c +++ b/lib/read.c @@ -1276,6 +1276,7 @@ static HCL_INLINE hcl_oop_t leave_list (hcl_t* hcl, int* flagv, int* oldflagv) /* the stack must not be empty - cannot leave a list without entering it */ HCL_ASSERT (hcl, !HCL_IS_NIL(hcl,hcl->c->r.s)); +/* TODO: fix bug here. unblanced ) cause assertion failure here */ /*head = HCL_CONS_CAR(HCL_CONS_CDR(hcl->c->r.s));*/