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;
}
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)
{
@ -364,7 +364,8 @@ static int add_gvs_to_awk (hawk_t* awk, arg_t* arg)
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
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)
# define hawk_addgbl hawk_addgblwithbcstr
# define hawk_delgbl hawk_delgblwithbcstr
# define hawk_findgbl hawk_findgblwithbcstr
# define hawk_addgblwithoocstr hawk_addgblwithbcstr
# define hawk_delgblwithoocstr hawk_delgblwithbcstr
# define hawk_findgblwithoocstr hawk_findgblwithbcstr
#else
# define hawk_addgbl hawk_addgblwithucstr
# define hawk_delgbl hawk_delgblwithucstr
# define hawk_findgbl hawk_findgblwithucstr
# define hawk_addgblwithoocstr hawk_addgblwithucstr
# define hawk_delgblwithoocstr hawk_delgblwithucstr
# define hawk_findgblwithoocstr hawk_findgblwithucstr
#endif
/**

View File

@ -4174,8 +4174,8 @@ static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc)
hawk_nde_t* right = HAWK_NULL;
hawk_loc_t rloc;
left = parse_additive (awk, xloc);
if (left == HAWK_NULL) goto oops;
left = parse_additive(awk, xloc);
if (HAWK_UNLIKELY(!left)) goto oops;
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)
{
/*
* [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) ||
/* unary operators */
MATCH(awk,TOK_PLUS) || MATCH(awk,TOK_MINUS) ||
@ -4205,11 +4212,11 @@ static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc)
else break;
rloc = awk->tok.loc;
right = parse_additive (awk, &rloc);
if (right == HAWK_NULL) goto oops;
right = parse_additive(awk, &rloc);
if (HAWK_UNLIKELY(!right)) goto oops;
tmp = new_exp_bin_node (awk, xloc, HAWK_BINOP_CONCAT, left, right);
if (tmp == HAWK_NULL) goto oops;
tmp = new_exp_bin_node(awk, xloc, HAWK_BINOP_CONCAT, left, right);
if (HAWK_UNLIKELY(!tmp)) goto oops;
left = tmp; right = HAWK_NULL;
}
while (1);
@ -4262,8 +4269,8 @@ static hawk_nde_t* parse_unary (hawk_t* awk, const hawk_loc_t* xloc)
(MATCH(awk,TOK_LNOT))? HAWK_UNROP_LNOT:
(MATCH(awk,TOK_TILDE))? HAWK_UNROP_BNOT: -1;
/*if (opcode <= -1) return parse_increment (awk);*/
if (opcode <= -1) return parse_exponent (awk, xloc);
/*if (opcode <= -1) return parse_increment(awk);*/
if (opcode <= -1) return parse_exponent(awk, xloc);
if (awk->opt.depth.s.expr_parse > 0 &&
awk->parse.depth.expr >= awk->opt.depth.s.expr_parse)

View File

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