diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | awkgram.c | 12 | ||||
-rw-r--r-- | awkgram.y | 12 | ||||
-rw-r--r-- | builtin.c | 10 | ||||
-rw-r--r-- | cint_array.c | 12 | ||||
-rw-r--r-- | debug.c | 34 | ||||
-rw-r--r-- | eval.c | 10 | ||||
-rw-r--r-- | gawkapi.c | 12 | ||||
-rw-r--r-- | int_array.c | 4 | ||||
-rw-r--r-- | io.c | 14 | ||||
-rw-r--r-- | mpfr.c | 6 | ||||
-rw-r--r-- | node.c | 12 | ||||
-rw-r--r-- | profile.c | 6 | ||||
-rw-r--r-- | str_array.c | 4 |
14 files changed, 81 insertions, 74 deletions
@@ -30,6 +30,13 @@ * awkgram.y (is_identchar): ... to here. This is safe, since the locale is C during parsing the program. + Also unrelated: Make all checks for bitflags being set consistent + in case we should wish to switch them to macro calls: + + * awkgram.y, builtin.c, cint_array.c, debug.c, eval.c, gawkapi.c, + int_array.c, io.c, mpfr.c, node.c, profile.c, str_array.c: Fix + as needed. + 2012-12-07 Arnold D. Robbins <arnold@skeeve.com> * awkgram.y (tokentab): `fflush()' is now in POSIX, remove the @@ -6137,28 +6137,28 @@ retry: goto out; if (do_lint) { - if ((tokentab[mid].flags & GAWKX) && ! (warntab[mid] & GAWKX)) { + if ((tokentab[mid].flags & GAWKX) != 0 && (warntab[mid] & GAWKX) == 0) { lintwarn(_("`%s' is a gawk extension"), tokentab[mid].operator); warntab[mid] |= GAWKX; } - if ((tokentab[mid].flags & NOT_POSIX) && ! (warntab[mid] & NOT_POSIX)) { + if ((tokentab[mid].flags & NOT_POSIX) != 0 && (warntab[mid] & NOT_POSIX) == 0) { lintwarn(_("POSIX does not allow `%s'"), tokentab[mid].operator); warntab[mid] |= NOT_POSIX; } } - if (do_lint_old && (tokentab[mid].flags & NOT_OLD) - && ! (warntab[mid] & NOT_OLD) + if (do_lint_old && (tokentab[mid].flags & NOT_OLD) != 0 + && (warntab[mid] & NOT_OLD) == 0 ) { warning(_("`%s' is not supported in old awk"), tokentab[mid].operator); warntab[mid] |= NOT_OLD; } - if (tokentab[mid].flags & BREAK) + if ((tokentab[mid].flags & BREAK) != 0) break_allowed++; - if (tokentab[mid].flags & CONTINUE) + if ((tokentab[mid].flags & CONTINUE) != 0) continue_allowed++; switch (class) { @@ -3604,28 +3604,28 @@ retry: goto out; if (do_lint) { - if ((tokentab[mid].flags & GAWKX) && ! (warntab[mid] & GAWKX)) { + if ((tokentab[mid].flags & GAWKX) != 0 && (warntab[mid] & GAWKX) == 0) { lintwarn(_("`%s' is a gawk extension"), tokentab[mid].operator); warntab[mid] |= GAWKX; } - if ((tokentab[mid].flags & NOT_POSIX) && ! (warntab[mid] & NOT_POSIX)) { + if ((tokentab[mid].flags & NOT_POSIX) != 0 && (warntab[mid] & NOT_POSIX) == 0) { lintwarn(_("POSIX does not allow `%s'"), tokentab[mid].operator); warntab[mid] |= NOT_POSIX; } } - if (do_lint_old && (tokentab[mid].flags & NOT_OLD) - && ! (warntab[mid] & NOT_OLD) + if (do_lint_old && (tokentab[mid].flags & NOT_OLD) != 0 + && (warntab[mid] & NOT_OLD) == 0 ) { warning(_("`%s' is not supported in old awk"), tokentab[mid].operator); warntab[mid] |= NOT_OLD; } - if (tokentab[mid].flags & BREAK) + if ((tokentab[mid].flags & BREAK) != 0) break_allowed++; - if (tokentab[mid].flags & CONTINUE) + if ((tokentab[mid].flags & CONTINUE) != 0) continue_allowed++; switch (class) { @@ -111,7 +111,7 @@ efwrite(const void *ptr, goto wrerror; if (flush && ((fp == stdout && output_is_tty) - || (rp != NULL && (rp->flag & RED_NOBUF)))) { + || (rp != NULL && (rp->flag & RED_NOBUF) != 0))) { if (rp != NULL) { rp->output.gawk_fflush(fp, rp->output.opaque); if (rp->output.gawk_ferror(fp, rp->output.opaque)) @@ -220,7 +220,7 @@ do_fflush(int nargs) status = -1; if (rp != NULL) { if ((rp->flag & (RED_WRITE|RED_APPEND)) == 0) { - if (rp->flag & RED_PIPE) + if ((rp->flag & RED_PIPE) != 0) warning(_("fflush: cannot flush: pipe `%s' opened for reading, not writing"), file); else @@ -1044,7 +1044,7 @@ check_pos: /* user input that looks numeric is numeric */ if ((arg->flags & (MAYBE_NUM|NUMBER)) == MAYBE_NUM) (void) force_number(arg); - if (arg->flags & NUMBER) { + if ((arg->flags & NUMBER) != 0) { uval = get_number_uj(arg); #if MBS_SUPPORT if (gawk_mb_cur_max > 1) { @@ -2750,7 +2750,7 @@ set_how_many: repllen--; ampersands++; } else if (*scan == '\\') { - if (flags & GENSUB) { /* gensub, behave sanely */ + if ((flags & GENSUB) != 0) { /* gensub, behave sanely */ if (isdigit((unsigned char) scan[1])) { ampersands++; scan++; @@ -2943,7 +2943,7 @@ done: } /* For a string literal, must not change the original string. */ - if (flags & LITERAL) + if ((flags & LITERAL) != 0) DEREF(t); else if (matches > 0) { unref(*lhs); diff --git a/cint_array.c b/cint_array.c index 22f9fbed..625730a7 100644 --- a/cint_array.c +++ b/cint_array.c @@ -447,7 +447,7 @@ cint_list(NODE *symbol, NODE *t) /* populate it with index in ascending or descending order */ for (ja = NHAT, jd = INT32_BIT - 1; ja < INT32_BIT && jd >= NHAT; ) { - j = (t->flags & ADESC) ? jd-- : ja++; + j = (t->flags & ADESC) != 0 ? jd-- : ja++; tn = symbol->nodes[j]; if (tn == NULL) continue; @@ -885,7 +885,7 @@ tree_list(NODE *tree, NODE **list, unsigned int flags) hsize /= 2; for (j = 0; j < hsize; j++) { - cj = (flags & ADESC) ? (hsize - 1 - j) : j; + cj = (flags & ADESC) != 0 ? (hsize - 1 - j) : j; tn = tree->nodes[cj]; if (tn == NULL) continue; @@ -1000,7 +1000,7 @@ tree_print(NODE *tree, size_t bi, int indent_level) hsize /= 2; fprintf(output_fp, "%4lu:%s[%4lu:%-4lu]\n", (unsigned long) bi, - (tree->flags & HALFHAT) ? "HH" : "H", + (tree->flags & HALFHAT) != 0 ? "HH" : "H", (unsigned long) hsize, (unsigned long) tree->table_size); for (j = 0; j < hsize; j++) { @@ -1146,14 +1146,14 @@ leaf_list(NODE *array, NODE **list, unsigned int flags) static char buf[100]; for (i = 0; i < size; i++) { - ci = (flags & ADESC) ? (size - 1 - i) : i; + ci = (flags & ADESC) != 0 ? (size - 1 - i) : i; r = array->nodes[ci]; if (r == NULL) continue; /* index */ num = array->array_base + ci; - if (flags & AISTR) { + if ((flags & AISTR) != 0) { sprintf(buf, "%ld", num); subs = make_string(buf, strlen(buf)); subs->numbr = num; @@ -1165,7 +1165,7 @@ leaf_list(NODE *array, NODE **list, unsigned int flags) list[k++] = subs; /* value */ - if (flags & AVALUE) { + if ((flags & AVALUE) != 0) { if (r->type == Node_val) { if ((flags & AVNUM) != 0) (void) force_number(r); @@ -745,16 +745,16 @@ do_info(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) gprintf(out_fp, _("Number Disp Enabled Location\n\n")); for (b = breakpoints.prev; b != &breakpoints; b = b->prev) { char *disp = "keep"; - if (b->flags & BP_ENABLE_ONCE) + if ((b->flags & BP_ENABLE_ONCE) != 0) disp = "dis"; - else if(b->flags & BP_TEMP) + else if ((b->flags & BP_TEMP) != 0) disp = "del"; gprintf(out_fp, "%-6d %-4.4s %-7.7s file %s, line #%d\n", - b->number, disp, (b->flags & BP_ENABLE) ? "yes" : "no", + b->number, disp, (b->flags & BP_ENABLE) != 0 ? "yes" : "no", b->src, b->bpi->source_line); if (b->hit_count > 0) gprintf(out_fp, _("\tno of hits = %ld\n"), b->hit_count); - if (b->flags & BP_IGNORE) + if ((b->flags & BP_IGNORE) != 0) gprintf(out_fp, _("\tignore next %ld hit(s)\n"), b->ignore_count); if (b->cndn.code != NULL) gprintf(out_fp, _("\tstop condition: %s\n"), b->cndn.expr); @@ -2172,8 +2172,8 @@ add_breakpoint(INSTRUCTION *prevp, INSTRUCTION *ip, char *src, bool silent) * This is more verbose that it might otherwise be, * in order to provide easily translatable strings. */ - if (b->flags & BP_ENABLE) { - if (b->flags & BP_IGNORE) + if ((b->flags & BP_ENABLE) != 0) { + if ((b->flags & BP_IGNORE) != 0) fprintf(out_fp, _("Note: breakpoint %d (enabled, ignore next %ld hits), also set at %s:%d"), b->number, @@ -2187,7 +2187,7 @@ add_breakpoint(INSTRUCTION *prevp, INSTRUCTION *ip, char *src, bool silent) b->src, lineno); } else { - if (b->flags & BP_IGNORE) + if ((b->flags & BP_IGNORE) != 0) fprintf(out_fp, _("Note: breakpoint %d (disabled, ignore next %ld hits), also set at %s:%d"), b->number, @@ -2402,7 +2402,7 @@ breakpoint_triggered(BREAKPOINT *b) return 0; b->hit_count++; - if (b->flags & BP_ENABLE_ONCE) { + if ((b->flags & BP_ENABLE_ONCE) != 0) { b->flags &= ~BP_ENABLE_ONCE; b->flags &= ~BP_ENABLE; } @@ -3404,9 +3404,9 @@ else \ valinfo(w->V, fprintf, out_fp); fprintf(out_fp, " Old value: "); - print_value((w->flags & OLD_IS_ARRAY), old_size, old_value); + print_value((w->flags & OLD_IS_ARRAY) != 0, old_size, old_value); fprintf(out_fp, " New value: "); - print_value((w->flags & CUR_IS_ARRAY), cur_size, cur_value); + print_value((w->flags & CUR_IS_ARRAY) != 0, cur_size, cur_value); #undef print_value } @@ -3656,9 +3656,9 @@ print_memory(NODE *m, NODE *func, Func_print print_func, FILE *fp) print_func(fp, "Nnull_string"); else if ((m->flags & NUMBER) != 0) { #ifdef HAVE_MPFR - if (m->flags & MPFN) + if ((m->flags & MPFN) != 0) print_func(fp, "%s", mpg_fmt("%R*g", ROUND_MODE, m->mpg_numbr)); - else if (m->flags & MPZN) + else if ((m->flags & MPZN) != 0) print_func(fp, "%s", mpg_fmt("%Zd", m->mpg_i)); else #endif @@ -3667,9 +3667,9 @@ print_memory(NODE *m, NODE *func, Func_print print_func, FILE *fp) pp_string_fp(print_func, fp, m->stptr, m->stlen, '"', false); else if ((m->flags & NUMCUR) != 0) { #ifdef HAVE_MPFR - if (m->flags & MPFN) + if ((m->flags & MPFN) != 0) print_func(fp, "%s", mpg_fmt("%R*g", ROUND_MODE, m->mpg_numbr)); - else if (m->flags & MPZN) + else if ((m->flags & MPZN) != 0) print_func(fp, "%s", mpg_fmt("%Zd", m->mpg_i)); else #endif @@ -3873,9 +3873,9 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) { 0, NULL } }; - if (pc->sub_flags & GSUB) + if ((pc->sub_flags & GSUB) != 0) fname = "gsub"; - else if (pc->sub_flags & GENSUB) + else if ((pc->sub_flags & GENSUB) != 0) fname = "gensub"; print_func(fp, "%s [arg_count = %ld] [sub_flags = %s]\n", fname, pc->expr_count, @@ -3918,7 +3918,7 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) /* NB: concat_flag CSVAR only used in grammar, don't display it */ print_func(fp, "[expr_count = %ld] [concat_flag = %s]\n", pc->expr_count, - (pc->concat_flag & CSUBSEP) ? "CSUBSEP" : "0"); + (pc->concat_flag & CSUBSEP) != 0 ? "CSUBSEP" : "0"); break; case Op_rule: @@ -576,16 +576,16 @@ cmp_nodes(NODE *t1, NODE *t2) if (t1 == t2) return 0; - if (t1->flags & MAYBE_NUM) + if ((t1->flags & MAYBE_NUM) != 0) (void) force_number(t1); - if (t2->flags & MAYBE_NUM) + if ((t2->flags & MAYBE_NUM) != 0) (void) force_number(t2); - if (t1->flags & INTIND) + if ((t1->flags & INTIND) != 0) t1 = force_string(t1); - if (t2->flags & INTIND) + if ((t2->flags & INTIND) != 0) t2 = force_string(t2); - if ((t1->flags & NUMBER) && (t2->flags & NUMBER)) + if ((t1->flags & NUMBER) != 0 && (t2->flags & NUMBER) != 0) return cmp_numbers(t1, t2); (void) force_string(t1); @@ -413,7 +413,7 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted) val->val_type = AWK_NUMBER; (void) force_number(node); - if (node->flags & NUMCUR) { + if ((node->flags & NUMCUR) != 0) { val->num_value = get_number_d(node); ret = true; } @@ -423,7 +423,7 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted) val->val_type = AWK_STRING; (void) force_string(node); - if (node->flags & STRCUR) { + if ((node->flags & STRCUR) != 0) { val->str_value.str = node->stptr; val->str_value.len = node->stlen; ret = true; @@ -431,9 +431,9 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted) break; case AWK_SCALAR: - if (node->flags & NUMBER) { + if ((node->flags & NUMBER) != 0) { val->val_type = AWK_NUMBER; - } else if (node->flags & STRING) { + } else if ((node->flags & STRING) != 0) { val->val_type = AWK_STRING; } else val->val_type = AWK_UNDEFINED; @@ -442,11 +442,11 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted) case AWK_UNDEFINED: /* return true and actual type for request of undefined */ - if (node->flags & NUMBER) { + if ((node->flags & NUMBER) != 0) { val->val_type = AWK_NUMBER; val->num_value = get_number_d(node); ret = true; - } else if (node->flags & STRING) { + } else if ((node->flags & STRING) != 0) { val->val_type = AWK_STRING; val->str_value.str = node->stptr; val->str_value.len = node->stlen; diff --git a/int_array.c b/int_array.c index a2c9e41e..2909f6f9 100644 --- a/int_array.c +++ b/int_array.c @@ -486,7 +486,7 @@ int_list(NODE *symbol, NODE *t) for (j = 0; j < b->aicount; j++) { /* index */ num = b->ainum[j]; - if (t->flags & AISTR) { + if ((t->flags & AISTR) != 0) { sprintf(buf, "%ld", num); subs = make_string(buf, strlen(buf)); subs->numbr = num; @@ -498,7 +498,7 @@ int_list(NODE *symbol, NODE *t) list[k++] = subs; /* value */ - if (t->flags & AVALUE) { + if ((t->flags & AVALUE) != 0) { r = b->aivalue[j]; if (r->type == Node_val) { if ((t->flags & AVNUM) != 0) @@ -733,7 +733,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) * we've gotten EOF from a child input pipeline, it's * a good bet that the child has died. So recover it. */ - if ((rp->flag & RED_EOF) && redirtype == redirect_pipein) { + if ((rp->flag & RED_EOF) != 0 && redirtype == redirect_pipein) { if (rp->pid != -1) wait_any(0); } @@ -779,7 +779,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) save_rp = rp; while (rp->output.fp == NULL && rp->iop == NULL) { - if (! new_rp && rp->flag & RED_EOF) { + if (! new_rp && (rp->flag & RED_EOF) != 0) { /* * Encountered EOF on file or pipe -- must be cleared * by explicit close() before reading more @@ -1233,12 +1233,12 @@ flush_io() } for (rp = red_head; rp != NULL; rp = rp->next) /* flush both files and pipes, what the heck */ - if ((rp->flag & RED_WRITE) && rp->output.fp != NULL) { + if ((rp->flag & RED_WRITE) != 0 && rp->output.fp != NULL) { if (rp->output.gawk_fflush(rp->output.fp, rp->output.opaque)) { - if (rp->flag & RED_PIPE) + if ((rp->flag & RED_PIPE) != 0) warning(_("pipe flush of `%s' failed (%s)."), rp->value, strerror(errno)); - else if (rp->flag & RED_TWOWAY) + else if ((rp->flag & RED_TWOWAY) != 0) warning(_("co-process flush of pipe to `%s' failed (%s)."), rp->value, strerror(errno)); else @@ -3563,9 +3563,9 @@ pty_vs_pipe(const char *command) return false; val = in_PROCINFO(command, "pty", NULL); if (val) { - if (val->flags & MAYBE_NUM) + if ((val->flags & MAYBE_NUM) != 0) (void) force_number(val); - if (val->flags & NUMBER) + if ((val->flags & NUMBER) != 0) return ! iszero(val); else return (val->stlen != 0); @@ -349,10 +349,10 @@ mpg_force_number(NODE *n) { unsigned int newflags = 0; - if (is_mpg_number(n) && (n->flags & NUMCUR)) + if (is_mpg_number(n) && (n->flags & NUMCUR) != 0) return n; - if (n->flags & MAYBE_NUM) { + if ((n->flags & MAYBE_NUM) != 0) { n->flags &= ~MAYBE_NUM; newflags = NUMBER; } @@ -528,7 +528,7 @@ set_PREC() return; val = PREC_node->var_value; - if (val->flags & MAYBE_NUM) + if ((val->flags & MAYBE_NUM) != 0) force_number(val); if ((val->flags & (STRING|NUMBER)) == STRING) { @@ -50,7 +50,7 @@ r_force_number(NODE *n) unsigned int newflags; extern double strtod(); - if (n->flags & NUMCUR) + if ((n->flags & NUMCUR) != 0) return n; /* all the conditionals are an attempt to avoid the expensive strtod */ @@ -75,7 +75,7 @@ r_force_number(NODE *n) if (isalpha((unsigned char) *cp)) { return n; } else if (n->stlen == 4 && is_ieee_magic_val(n->stptr)) { - if (n->flags & MAYBE_NUM) + if ((n->flags & MAYBE_NUM) != 0) n->flags &= ~MAYBE_NUM; n->flags |= NUMBER|NUMCUR; n->numbr = get_ieee_magic_val(n->stptr); @@ -101,7 +101,7 @@ r_force_number(NODE *n) return n; } - if (n->flags & MAYBE_NUM) { + if ((n->flags & MAYBE_NUM) != 0) { newflags = NUMBER; n->flags &= ~MAYBE_NUM; } else @@ -245,7 +245,7 @@ r_format_val(const char *format, int index, NODE *s) s->stlen = strlen(sp); } s->stfmt = -1; - if (s->flags & INTIND) { + if ((s->flags & INTIND) != 0) { s->flags &= ~(INTIND|NUMBER); s->flags |= STRING; } @@ -374,7 +374,7 @@ make_str_node(const char *s, size_t len, int flags) r->wstlen = 0; #endif /* MBS_SUPPORT */ - if (flags & ALREADY_MALLOCED) + if ((flags & ALREADY_MALLOCED) != 0) r->stptr = (char *) s; else { emalloc(r->stptr, char *, len + 2, "make_str_node"); @@ -448,7 +448,7 @@ r_unref(NODE *tmp) tmp->valref--; return; } - if (tmp->flags & STRCUR) + if ((tmp->flags & STRCUR) != 0) efree(tmp->stptr); } #else @@ -428,7 +428,7 @@ cleanup: case Op_concat: str = pp_list(pc->expr_count, NULL, - (pc->concat_flag & CSUBSEP) ? ", " : op2str(Op_concat)); + (pc->concat_flag & CSUBSEP) != 0 ? ", " : op2str(Op_concat)); pp_push(Op_concat, str, CAN_FREE); break; @@ -498,9 +498,9 @@ cleanup: case Op_sub_builtin: { const char *fname = "sub"; - if (pc->sub_flags & GSUB) + if ((pc->sub_flags & GSUB) != 0) fname = "gsub"; - else if (pc->sub_flags & GENSUB) + else if ((pc->sub_flags & GENSUB) != 0) fname = "gensub"; tmp = pp_list(pc->expr_count, "()", ", "); str = pp_concat(fname, tmp, ""); diff --git a/str_array.c b/str_array.c index 1b3a33f1..db6031d4 100644 --- a/str_array.c +++ b/str_array.c @@ -370,12 +370,12 @@ str_list(NODE *symbol, NODE *t) for (b = symbol->buckets[i]; b != NULL; b = b->ahnext) { /* index */ subs = b->ahname; - if (t->flags & AINUM) + if ((t->flags & AINUM) != 0) (void) force_number(subs); list[k++] = dupnode(subs); /* value */ - if (t->flags & AVALUE) { + if ((t->flags & AVALUE) != 0) { val = b->ahvalue; if (val->type == Node_val) { if ((t->flags & AVNUM) != 0) |