fixed a bug handling -v in bin/main.c

This commit is contained in:
hyung-hwan 2020-03-04 13:59:03 +00:00
parent 7980e12999
commit e8e5aa7935
4 changed files with 30 additions and 38 deletions

View File

@ -356,7 +356,7 @@ static hawk_htb_walk_t print_awk_value (hawk_htb_t* map, hawk_htb_pair_t* pair,
return HAWK_HTB_WALK_FORWARD; return HAWK_HTB_WALK_FORWARD;
} }
static int add_gvs_to_awk (hawk_t* awk, arg_t* arg) static int add_gvs_to_awk (hawk_t* hawk, arg_t* arg)
{ {
if (arg->gvm.size > 0) if (arg->gvm.size > 0)
{ {
@ -364,7 +364,8 @@ static int add_gvs_to_awk (hawk_t* awk, arg_t* arg)
for (i = 0; i < arg->gvm.size; i++) for (i = 0; i < arg->gvm.size; i++)
{ {
arg->gvm.ptr[i].idx = hawk_addgbl(awk, arg->gvm.ptr[i].name); arg->gvm.ptr[i].idx = arg->gvm.ptr[i].uc? hawk_addgblwithucstr(hawk, arg->gvm.ptr[i].name):
hawk_addgblwithbcstr(hawk, arg->gvm.ptr[i].name);
} }
} }
@ -1012,20 +1013,6 @@ static void print_hawk_rtx_error (hawk_rtx_t* rtx)
); );
} }
hawk_htb_walk_t add_global (hawk_htb_t* map, hawk_htb_pair_t* pair, void* arg)
{
hawk_t* awk = (hawk_t*)arg;
struct gv_t* gvmv = (struct gv_t*)HAWK_HTB_VPTR(pair);
/* the key was inserted to the table with a null at the end
* and the key length was even incremetned for that.
* so i can pass the pointer without other adjustments. */
gvmv->idx = hawk_addgbl(awk, HAWK_HTB_KPTR(pair));
if (gvmv->idx <= -1) return HAWK_HTB_WALK_STOP;
return HAWK_HTB_WALK_FORWARD;
}
#if 0 #if 0
static void* xma_alloc (hawk_mmgr_t* mmgr, hawk_oow_t size) static void* xma_alloc (hawk_mmgr_t* mmgr, hawk_oow_t size)
{ {

View File

@ -1737,13 +1737,13 @@ HAWK_EXPORT int hawk_findgblwithucstr (
); );
#if defined(HAWK_OOCH_IS_BCH) #if defined(HAWK_OOCH_IS_BCH)
# define hawk_addgbl hawk_addgblwithbcstr # define hawk_addgblwithoocstr hawk_addgblwithbcstr
# define hawk_delgbl hawk_delgblwithbcstr # define hawk_delgblwithoocstr hawk_delgblwithbcstr
# define hawk_findgbl hawk_findgblwithbcstr # define hawk_findgblwithoocstr hawk_findgblwithbcstr
#else #else
# define hawk_addgbl hawk_addgblwithucstr # define hawk_addgblwithoocstr hawk_addgblwithucstr
# define hawk_delgbl hawk_delgblwithucstr # define hawk_delgblwithoocstr hawk_delgblwithucstr
# define hawk_findgbl hawk_findgblwithucstr # define hawk_findgblwithoocstr hawk_findgblwithucstr
#endif #endif
/** /**

View File

@ -4175,7 +4175,7 @@ static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc)
hawk_loc_t rloc; hawk_loc_t rloc;
left = parse_additive(awk, xloc); left = parse_additive(awk, xloc);
if (left == HAWK_NULL) goto oops; if (HAWK_UNLIKELY(!left)) goto oops;
do do
{ {
@ -4187,6 +4187,13 @@ static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc)
} }
else if (awk->opt.trait & HAWK_BLANKCONCAT) else if (awk->opt.trait & HAWK_BLANKCONCAT)
{ {
/*
* [NOTE]
* TOK_TILDE has been commented out in the if condition below because
* BINOP_MA has lower precedence than concatenation and it is not certain
* the tilde is an unary bitwise negation operator at this phase.
* You may use (~10) rather than ~10 after concatenation to avoid confusion.
*/
if (MATCH(awk,TOK_LPAREN) || MATCH(awk,TOK_DOLLAR) || if (MATCH(awk,TOK_LPAREN) || MATCH(awk,TOK_DOLLAR) ||
/* unary operators */ /* unary operators */
MATCH(awk,TOK_PLUS) || MATCH(awk,TOK_MINUS) || MATCH(awk,TOK_PLUS) || MATCH(awk,TOK_MINUS) ||
@ -4206,10 +4213,10 @@ static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc)
rloc = awk->tok.loc; rloc = awk->tok.loc;
right = parse_additive(awk, &rloc); right = parse_additive(awk, &rloc);
if (right == HAWK_NULL) goto oops; if (HAWK_UNLIKELY(!right)) goto oops;
tmp = new_exp_bin_node(awk, xloc, HAWK_BINOP_CONCAT, left, right); tmp = new_exp_bin_node(awk, xloc, HAWK_BINOP_CONCAT, left, right);
if (tmp == HAWK_NULL) goto oops; if (HAWK_UNLIKELY(!tmp)) goto oops;
left = tmp; right = HAWK_NULL; left = tmp; right = HAWK_NULL;
} }
while (1); while (1);

View File

@ -3081,13 +3081,11 @@ static int add_globals (hawk_t* awk)
{ {
xtn_t* xtn = GET_XTN(awk); xtn_t* xtn = GET_XTN(awk);
xtn->gbl_argc = hawk_addgbl(awk, HAWK_T("ARGC")); xtn->gbl_argc = hawk_addgblwithoocstr(awk, HAWK_T("ARGC"));
xtn->gbl_argv = hawk_addgbl(awk, HAWK_T("ARGV")); xtn->gbl_argv = hawk_addgblwithoocstr(awk, HAWK_T("ARGV"));
xtn->gbl_environ = hawk_addgbl(awk, HAWK_T("ENVIRON")); xtn->gbl_environ = hawk_addgblwithoocstr(awk, HAWK_T("ENVIRON"));
return (xtn->gbl_argc <= -1 || return (HAWK_UNLIKELY(xtn->gbl_argc <= -1 || xtn->gbl_argv <= -1 || xtn->gbl_environ <= -1))? -1: 0;
xtn->gbl_argv <= -1 ||
xtn->gbl_environ <= -1)? -1: 0;
} }
struct fnctab_t struct fnctab_t