aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-06 10:57:45 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-06 10:57:45 +0300
commitc8178ecebb0853a222d8301566f1d54d3f106ae3 (patch)
treefbb6990afdfdfb248451fb3c66f164cf2340c6f9
parent1047a04edf933d57b88c264ee3dfb88633332f61 (diff)
parentf5df7fad8c8b864c3d817d8eb4f9fa3596c2a14b (diff)
downloadegawk-c8178ecebb0853a222d8301566f1d54d3f106ae3.tar.gz
egawk-c8178ecebb0853a222d8301566f1d54d3f106ae3.tar.bz2
egawk-c8178ecebb0853a222d8301566f1d54d3f106ae3.zip
Merge branch 'gawk-4.1-stable'
-rw-r--r--ChangeLog6
-rw-r--r--awk.h2
-rw-r--r--awkgram.c23
-rw-r--r--awkgram.y23
4 files changed, 35 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index d50e7c2d..749258f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-06 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (force_number): Add `!= 0' check to bitwise operation.
+ * awkgram.y: Same, many places.
+ (check_special): Simplify code for checking extension flags.
+
2015-04-05 Arnold D. Robbins <arnold@skeeve.com>
* awkgram.y (install_builtins): If do_traditional is true, do not
diff --git a/awk.h b/awk.h
index 6f812e71..c6467953 100644
--- a/awk.h
+++ b/awk.h
@@ -1784,7 +1784,7 @@ unref(NODE *r)
static inline NODE *
force_number(NODE *n)
{
- return (n->flags & NUMCUR) ? n : str2number(n);
+ return (n->flags & NUMCUR) != 0 ? n : str2number(n);
}
#endif /* GAWKDEBUG */
diff --git a/awkgram.c b/awkgram.c
index 52a17cb0..799570e5 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -3377,7 +3377,7 @@ regular_print:
if ((yyvsp[-1])->lasti->opcode == Op_concat) {
/* multiple (> 2) adjacent strings optimization */
- is_simple_var = ((yyvsp[-1])->lasti->concat_flag & CSVAR);
+ is_simple_var = ((yyvsp[-1])->lasti->concat_flag & CSVAR) != 0;
count = (yyvsp[-1])->lasti->expr_count + 1;
(yyvsp[-1])->lasti->opcode = Op_no_op;
} else {
@@ -4813,7 +4813,7 @@ add_srcfile(enum srctype stype, char *src, SRCFILE *thisfile, bool *already_incl
if (stype == SRC_CMDLINE || stype == SRC_STDIN)
return do_add_srcfile(stype, src, NULL, thisfile);
- path = find_source(src, & sbuf, &errno_val, stype == SRC_EXTLIB);
+ path = find_source(src, & sbuf, & errno_val, stype == SRC_EXTLIB);
if (path == NULL) {
if (errcode) {
*errcode = errno_val;
@@ -6675,10 +6675,10 @@ valinfo(NODE *n, Func_print print_func, FILE *fp)
{
if (n == Nnull_string)
print_func(fp, "uninitialized scalar\n");
- else if (n->flags & STRING) {
+ else if ((n->flags & STRING) != 0) {
pp_string_fp(print_func, fp, n->stptr, n->stlen, '"', false);
print_func(fp, "\n");
- } else if (n->flags & NUMBER) {
+ } else if ((n->flags & NUMBER) != 0) {
#ifdef HAVE_MPFR
if (is_mpg_float(n))
print_func(fp, "%s\n", mpg_fmt("%.17R*g", ROUND_MODE, n->mpg_numbr));
@@ -6687,10 +6687,10 @@ valinfo(NODE *n, Func_print print_func, FILE *fp)
else
#endif
print_func(fp, "%.17g\n", n->numbr);
- } else if (n->flags & STRCUR) {
+ } else if ((n->flags & STRCUR) != 0) {
pp_string_fp(print_func, fp, n->stptr, n->stlen, '"', false);
print_func(fp, "\n");
- } else if (n->flags & NUMCUR) {
+ } else if ((n->flags & NUMCUR) != 0) {
#ifdef HAVE_MPFR
if (is_mpg_float(n))
print_func(fp, "%s\n", mpg_fmt("%.17R*g", ROUND_MODE, n->mpg_numbr));
@@ -7658,7 +7658,7 @@ optimize_assignment(INSTRUCTION *exp)
switch (i2->opcode) {
case Op_concat:
if (i2->nexti->opcode == Op_push_lhs /* l.h.s is a simple variable */
- && (i2->concat_flag & CSVAR) /* 1st exp in r.h.s is a simple variable;
+ && (i2->concat_flag & CSVAR) != 0 /* 1st exp in r.h.s is a simple variable;
* see Op_concat in the grammer above.
*/
&& i2->nexti->memory == exp->nexti->memory /* and the same as in l.h.s */
@@ -8118,6 +8118,7 @@ check_special(const char *name)
{
int low, high, mid;
int i;
+ int non_standard_flags = 0;
#if 'a' == 0x81 /* it's EBCDIC */
static bool did_sort = false;
@@ -8129,6 +8130,11 @@ check_special(const char *name)
}
#endif
+ if (do_traditional)
+ non_standard_flags |= GAWKX;
+ if (do_posix)
+ non_standard_flags |= NOT_POSIX;
+
low = 0;
high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1;
while (low <= high) {
@@ -8142,8 +8148,7 @@ check_special(const char *name)
else if (i > 0) /* token > mid */
low = mid + 1;
else {
- if ((do_traditional && (tokentab[mid].flags & GAWKX))
- || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
+ if ((tokentab[mid].flags & non_standard_flags) != 0)
return -1;
return mid;
}
diff --git a/awkgram.y b/awkgram.y
index d429c9cd..db0cf8cd 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -1421,7 +1421,7 @@ common_exp
if ($1->lasti->opcode == Op_concat) {
/* multiple (> 2) adjacent strings optimization */
- is_simple_var = ($1->lasti->concat_flag & CSVAR);
+ is_simple_var = ($1->lasti->concat_flag & CSVAR) != 0;
count = $1->lasti->expr_count + 1;
$1->lasti->opcode = Op_no_op;
} else {
@@ -2475,7 +2475,7 @@ add_srcfile(enum srctype stype, char *src, SRCFILE *thisfile, bool *already_incl
if (stype == SRC_CMDLINE || stype == SRC_STDIN)
return do_add_srcfile(stype, src, NULL, thisfile);
- path = find_source(src, & sbuf, &errno_val, stype == SRC_EXTLIB);
+ path = find_source(src, & sbuf, & errno_val, stype == SRC_EXTLIB);
if (path == NULL) {
if (errcode) {
*errcode = errno_val;
@@ -4337,10 +4337,10 @@ valinfo(NODE *n, Func_print print_func, FILE *fp)
{
if (n == Nnull_string)
print_func(fp, "uninitialized scalar\n");
- else if (n->flags & STRING) {
+ else if ((n->flags & STRING) != 0) {
pp_string_fp(print_func, fp, n->stptr, n->stlen, '"', false);
print_func(fp, "\n");
- } else if (n->flags & NUMBER) {
+ } else if ((n->flags & NUMBER) != 0) {
#ifdef HAVE_MPFR
if (is_mpg_float(n))
print_func(fp, "%s\n", mpg_fmt("%.17R*g", ROUND_MODE, n->mpg_numbr));
@@ -4349,10 +4349,10 @@ valinfo(NODE *n, Func_print print_func, FILE *fp)
else
#endif
print_func(fp, "%.17g\n", n->numbr);
- } else if (n->flags & STRCUR) {
+ } else if ((n->flags & STRCUR) != 0) {
pp_string_fp(print_func, fp, n->stptr, n->stlen, '"', false);
print_func(fp, "\n");
- } else if (n->flags & NUMCUR) {
+ } else if ((n->flags & NUMCUR) != 0) {
#ifdef HAVE_MPFR
if (is_mpg_float(n))
print_func(fp, "%s\n", mpg_fmt("%.17R*g", ROUND_MODE, n->mpg_numbr));
@@ -5320,7 +5320,7 @@ optimize_assignment(INSTRUCTION *exp)
switch (i2->opcode) {
case Op_concat:
if (i2->nexti->opcode == Op_push_lhs /* l.h.s is a simple variable */
- && (i2->concat_flag & CSVAR) /* 1st exp in r.h.s is a simple variable;
+ && (i2->concat_flag & CSVAR) != 0 /* 1st exp in r.h.s is a simple variable;
* see Op_concat in the grammer above.
*/
&& i2->nexti->memory == exp->nexti->memory /* and the same as in l.h.s */
@@ -5780,6 +5780,7 @@ check_special(const char *name)
{
int low, high, mid;
int i;
+ int non_standard_flags = 0;
#if 'a' == 0x81 /* it's EBCDIC */
static bool did_sort = false;
@@ -5791,6 +5792,11 @@ check_special(const char *name)
}
#endif
+ if (do_traditional)
+ non_standard_flags |= GAWKX;
+ if (do_posix)
+ non_standard_flags |= NOT_POSIX;
+
low = 0;
high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1;
while (low <= high) {
@@ -5804,8 +5810,7 @@ check_special(const char *name)
else if (i > 0) /* token > mid */
low = mid + 1;
else {
- if ((do_traditional && (tokentab[mid].flags & GAWKX))
- || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
+ if ((tokentab[mid].flags & non_standard_flags) != 0)
return -1;
return mid;
}