From da36b2deab8b416941a34e8aef449103e85a2473 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 30 Jul 2018 15:37:03 +0000 Subject: [PATCH] hmm.. just a few lines of cli mode code --- hcl/lib/read.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hcl/lib/read.c b/hcl/lib/read.c index 11b9619..0fed039 100644 --- a/hcl/lib/read.c +++ b/hcl/lib/read.c @@ -1017,7 +1017,7 @@ retry: /* skip spaces */ while (is_spacechar(hcl->c->lxc.c)) { - if ((hcl->option.trait & HCL_CLI_MODE) && hcl->c->lxc.c == '\n') + if ((hcl->option.trait & HCL_CLI_MODE) && hcl->c->lxc.c == '\n' && TOKEN_TYPE(hcl) != HCL_IOTOK_EOL) { SET_TOKEN_TYPE (hcl, HCL_IOTOK_EOL); CLEAR_TOKEN_NAME (hcl); @@ -1925,9 +1925,9 @@ static int read_object (hcl_t* hcl) GET_TOKEN (hcl); goto redo; - case HCL_IOTOK_RPAREN: /* xlist (), byte array #() */ - case HCL_IOTOK_RBRACK: /* array #[], qlist[] */ - case HCL_IOTOK_RBRACE: /* dictionary #{} */ + case HCL_IOTOK_RPAREN: /* xlist (), qlist #() */ + case HCL_IOTOK_RBRACK: /* bytearray #[], array[] */ + case HCL_IOTOK_RBRACE: /* dictionary {} */ { static struct { @@ -1939,7 +1939,7 @@ static int read_object (hcl_t* hcl) { HCL_IOTOK_RBRACK, HCL_SYNERR_RBRACK }, /* ARRAY [] */ { HCL_IOTOK_RBRACK, HCL_SYNERR_RBRACK }, /* BYTEARRAY #[] */ { HCL_IOTOK_RBRACE, HCL_SYNERR_RBRACE }, /* DIC {} */ - { HCL_IOTOK_RPAREN, HCL_SYNERR_RPAREN } /* QLIST $() */ + { HCL_IOTOK_RPAREN, HCL_SYNERR_RPAREN } /* QLIST #() */ }; int oldflagv; @@ -2229,6 +2229,7 @@ static int read_object_in_cli_mode (hcl_t* hcl) case HCL_IOTOK_LPAREN: /* () */ flagv = 0; LIST_FLAG_SET_CONCODE (flagv, HCL_CONCODE_XLIST); + SET_TOKEN_TYPE (hcl, HCL_IOTOK_EOL); /* to have get_token() to ignore immediate after ( */ start_list: if (level >= HCL_TYPE_MAX(int)) { @@ -2270,6 +2271,12 @@ static int read_object_in_cli_mode (hcl_t* hcl) goto done ; } + + case HCL_IOTOK_LBRACE: + + + case HCL_IOTOK_RBRACE: + case HCL_IOTOK_NUMLIT: case HCL_IOTOK_RADNUMLIT: obj = string_to_num(hcl, TOKEN_NAME(hcl), TOKEN_TYPE(hcl) == HCL_IOTOK_RADNUMLIT); @@ -2476,6 +2483,7 @@ int hcl_attachio (hcl_t* hcl, hcl_ioimpl_t reader, hcl_ioimpl_t printer) /* the stream is open. set it as the current input stream */ hcl->c->curinp = &hcl->c->inarg; + if (hcl->option.trait & HCL_CLI_MODE) SET_TOKEN_TYPE (hcl, HCL_IOTOK_EOL); return 0; oops: