gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-468


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-468-gc2cda8d
Date: Thu, 30 Oct 2014 19:38:36 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-4.1-stable has been updated
       via  c2cda8d3736b59738f579fce748e94ca109ccc58 (commit)
       via  e982e87ced45d48d23ffc86fa0b6cf6fabfbef8d (commit)
      from  3b13df110f42b26417de73151eb4a03657e85de4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=c2cda8d3736b59738f579fce748e94ca109ccc58

commit c2cda8d3736b59738f579fce748e94ca109ccc58
Author: Arnold D. Robbins <address@hidden>
Date:   Thu Oct 30 21:33:59 2014 +0200

    Fixes in pretty-printer.

diff --git a/ChangeLog b/ChangeLog
index 8f4657a..a74dadd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,15 @@
 
        * configure: Regenerated after fix to m4/readline.m4.
 
+       Unrelated; fixes to profiling. Thanks to Hermann Peifer and
+       Manuel Collado for pointing out problems:
+
+       * profile.c (pprint): For Op_unary_minus, parenthesize -(-x)
+       correctly.
+       (prec_level): Get the levels right (checked the grammar).
+       (is_unary_minus): New function.
+       (pp_concat): Add checks for unary minus; needs to be parenthesized.
+
 2014-10-29         Arnold D. Robbins     <address@hidden>
 
        * dfa.c: Sync with GNU grep. Again, again.
diff --git a/profile.c b/profile.c
index a5ed381..ed17e62 100644
--- a/profile.c
+++ b/profile.c
@@ -395,7 +395,8 @@ cleanup:
                case Op_unary_minus:
                case Op_not:
                        t1 = pp_pop();
-                       if (is_binary(t1->type))
+                       if (is_binary(t1->type)
+                           || (((OPCODE) t1->type) == pc->opcode && pc->opcode 
== Op_unary_minus))
                                pp_parenthesize(t1);
 
                        /* optypes table (eval.c) includes space after ! */
@@ -1000,25 +1001,25 @@ prec_level(int type)
        case Op_func_call:
        case Op_K_delete_loop:
        case Op_builtin:
-               return 15;
+               return 16;
 
        case Op_field_spec:
        case Op_field_spec_lhs:
-               return 14;
-
-       case Op_exp:
-       case Op_exp_i:
-               return 13;
+               return 15;
 
        case Op_preincrement:
        case Op_predecrement:
        case Op_postincrement:
        case Op_postdecrement:
-               return 12;
+               return 14;
+
+       case Op_exp:
+       case Op_exp_i:
+               return 13;
 
        case Op_unary_minus:
        case Op_not:
-               return 11;
+               return 12;
 
        case Op_times:
        case Op_times_i:
@@ -1026,23 +1027,26 @@ prec_level(int type)
        case Op_quotient_i:
        case Op_mod:
        case Op_mod_i:
-               return 10;
+               return 11;
 
        case Op_plus:
        case Op_plus_i:
        case Op_minus:
        case Op_minus_i:
-               return 9;
+               return 10;
 
        case Op_concat:
        case Op_assign_concat:
-               return 8;
+               return 9;
 
        case Op_equal:
        case Op_notequal:
        case Op_greater:
+       case Op_less:
        case Op_leq:
        case Op_geq:
+               return 8;
+
        case Op_match:
        case Op_nomatch:
                return 7;
@@ -1051,7 +1055,6 @@ prec_level(int type)
        case Op_K_getline_redir:
                return 6;
 
-       case Op_less:
        case Op_in_array:
                return 5;
 
@@ -1360,6 +1363,14 @@ pp_list(int nargs, const char *paren, const char *delim)
        return str;                                     
 }
 
+/* is_unary_minus --- return true if string starts with unary minus */
+
+static bool
+is_unary_minus(const char *str)
+{
+       return str[0] == '-' && str[1] != '-';
+}
+
 /* pp_concat --- handle concatenation and correct parenthesizing of 
expressions */
 
 static char *
@@ -1401,7 +1412,12 @@ pp_concat(int nargs)
                pl_l = prec_level(pp_args[i]->type);
                pl_r = prec_level(pp_args[i+1]->type);
 
-               if (is_scalar(pp_args[i]->type) && 
is_scalar(pp_args[i+1]->type)) {
+               if (i >= 2 && is_unary_minus(r->pp_str)) {
+                       *s++ = '(';
+                       memcpy(s, r->pp_str, r->pp_len);
+                       s += r->pp_len;
+                       *s++ = ')';
+               } else if (is_scalar(pp_args[i]->type) && 
is_scalar(pp_args[i+1]->type)) {
                        memcpy(s, r->pp_str, r->pp_len);
                        s += r->pp_len;
                } else if (pl_l <= pl_r || is_scalar(pp_args[i+1]->type)) {
@@ -1423,7 +1439,7 @@ pp_concat(int nargs)
        pl_l = prec_level(pp_args[nargs-1]->type);
        pl_r = prec_level(pp_args[nargs]->type);
        r = pp_args[nargs];
-       if (pl_l >= pl_r && ! is_scalar(pp_args[nargs]->type)) {
+       if (is_unary_minus(r->pp_str) || ((pl_l >= pl_r && ! 
is_scalar(pp_args[nargs]->type)))) {
                *s++ = '(';
                memcpy(s, r->pp_str, r->pp_len);
                s += r->pp_len;
diff --git a/test/ChangeLog b/test/ChangeLog
index f85de80..c9fe4a2 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2014-10-30         Arnold D. Robbins     <address@hidden>
+
+       * Makefile.am (profile6): New test.
+       * profile6.awk, profile6.ok: New files.
+
 2014-10-17         Andrew J. Schorr     <address@hidden>
 
        * Makefile.am (profile1, testext): Use explicit ./foo.awk to avoid
diff --git a/test/Makefile.am b/test/Makefile.am
index f0965d7..1553950 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -706,6 +706,8 @@ EXTRA_DIST = \
        profile4.ok \
        profile5.awk \
        profile5.ok \
+       profile6.awk \
+       profile6.ok \
        prt1eval.awk \
        prt1eval.ok \
        prtoeval.awk \
@@ -1017,7 +1019,7 @@ GAWK_EXT_TESTS = \
        manyfiles match1 match2 match3 mbstr1 \
        nastyparm next nondec nondec2 \
        patsplit posix printfbad1 printfbad2 printfbad3 printhuge procinfs \
-       profile1 profile2 profile3 profile4 profile5 pty1 \
+       profile1 profile2 profile3 profile4 profile5 profile6 pty1 \
        rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline 
rsglstdin rsstart1 \
        rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \
        splitarg4 strftime \
@@ -1699,6 +1701,12 @@ profile5:
        @sed 1,2d < address@hidden > _$@; rm address@hidden
        @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
 
+profile6:
+       @echo $@
+       @GAWK_NO_PP_RUN=1 $(AWK) address@hidden -f "$(srcdir)"/address@hidden > 
/dev/null
+       @sed 1,2d < address@hidden > _$@; rm address@hidden
+       @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+
 posix2008sub:
        @echo $@
        @$(AWK) --posix -f "$(srcdir)"/address@hidden > _$@ 2>&1
diff --git a/test/Makefile.in b/test/Makefile.in
index 3df3452..9e56dbf 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -952,6 +952,8 @@ EXTRA_DIST = \
        profile4.ok \
        profile5.awk \
        profile5.ok \
+       profile6.awk \
+       profile6.ok \
        prt1eval.awk \
        prt1eval.ok \
        prtoeval.awk \
@@ -1262,7 +1264,7 @@ GAWK_EXT_TESTS = \
        manyfiles match1 match2 match3 mbstr1 \
        nastyparm next nondec nondec2 \
        patsplit posix printfbad1 printfbad2 printfbad3 printhuge procinfs \
-       profile1 profile2 profile3 profile4 profile5 pty1 \
+       profile1 profile2 profile3 profile4 profile5 profile6 pty1 \
        rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline 
rsglstdin rsstart1 \
        rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \
        splitarg4 strftime \
@@ -2123,6 +2125,12 @@ profile5:
        @sed 1,2d < address@hidden > _$@; rm address@hidden
        @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
 
+profile6:
+       @echo $@
+       @GAWK_NO_PP_RUN=1 $(AWK) address@hidden -f "$(srcdir)"/address@hidden > 
/dev/null
+       @sed 1,2d < address@hidden > _$@; rm address@hidden
+       @-$(CMP) "$(srcdir)"/address@hidden _$@ && rm -f _$@
+
 posix2008sub:
        @echo $@
        @$(AWK) --posix -f "$(srcdir)"/address@hidden > _$@ 2>&1
diff --git a/test/profile6.awk b/test/profile6.awk
new file mode 100644
index 0000000..754f8ae
--- /dev/null
+++ b/test/profile6.awk
@@ -0,0 +1,7 @@
+BEGIN {
+       x = 3
+       print -(-x)
+       Q = "|"
+       print -3 Q (-4)
+       print -3 Q (-4) (-5)
+}
diff --git a/test/profile6.ok b/test/profile6.ok
new file mode 100644
index 0000000..86ff68a
--- /dev/null
+++ b/test/profile6.ok
@@ -0,0 +1,10 @@
+       # BEGIN rule(s)
+
+       BEGIN {
+               x = 3
+               print -(-x)
+               Q = "|"
+               print -3 Q (-4)
+               print -3 Q (-4) (-5)
+       }
+

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=e982e87ced45d48d23ffc86fa0b6cf6fabfbef8d

commit e982e87ced45d48d23ffc86fa0b6cf6fabfbef8d
Author: Arnold D. Robbins <address@hidden>
Date:   Thu Oct 30 20:49:19 2014 +0200

    Enable cross-compiling for readline during configuring.

diff --git a/ChangeLog b/ChangeLog
index 34554e2..8f4657a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-10-30         Arnold D. Robbins     <address@hidden>
+
+       * configure: Regenerated after fix to m4/readline.m4.
+
 2014-10-29         Arnold D. Robbins     <address@hidden>
 
        * dfa.c: Sync with GNU grep. Again, again.
diff --git a/configure b/configure
index 44b420b..d98aeb1 100755
--- a/configure
+++ b/configure
@@ -10439,7 +10439,39 @@ fi
 $as_echo_n "checking whether readline via \"$_combo\" is present and sane... " 
>&6; }
 
        if test "$cross_compiling" = yes; then :
-              _found_readline=no
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+int
+main ()
+{
+
+       int fd;
+       char *line;
+
+       close(0);
+       close(1);
+       fd = open("/dev/null", 2);      /* should get fd 0 */
+       dup(fd);
+       line = readline("giveittome> ");
+
+       /* some printfs don't handle NULL for %s */
+       printf("got <%s>\n", line ? line : "(NULL)");
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+                       _found_readline=yes
+else
+                       _found_readline=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 81fdcec..17c482c 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-30         Arnold D. Robbins     <address@hidden>
+
+       * readline.m4: Enable cross compiling. Thanks to
+       Christer Solskogen <address@hidden> for
+       motivating and testing.
+
 2014-04-08         Arnold D. Robbins     <address@hidden>
 
        * 4.1.1: Release tar ball made.
diff --git a/m4/readline.m4 b/m4/readline.m4
index 77ed8b2..740b9c7 100644
--- a/m4/readline.m4
+++ b/m4/readline.m4
@@ -62,7 +62,28 @@ dnl action if true:
 dnl action if false:
             [_found_readline=no],
 dnl action if cross compiling:
-            [_found_readline=no]
+               AC_TRY_LINK([#include <stdio.h>
+#include <readline/readline.h>
+#include <readline/history.h>],                dnl includes
+                       dnl function body
+                       [
+       int fd;
+       char *line;
+
+       close(0);
+       close(1);
+       fd = open("/dev/null", 2);      /* should get fd 0 */
+       dup(fd);
+       line = readline("giveittome> ");
+
+       /* some printfs don't handle NULL for %s */
+       printf("got <%s>\n", line ? line : "(NULL)");
+],
+dnl action if found:
+                       [_found_readline=yes],
+dnl action if not found:
+                       [_found_readline=no]
+               )
        )
 
         AC_MSG_RESULT([$_found_readline])

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog         |   13 +++++++++++++
 configure         |   34 +++++++++++++++++++++++++++++++++-
 m4/ChangeLog      |    6 ++++++
 m4/readline.m4    |   23 ++++++++++++++++++++++-
 profile.c         |   46 +++++++++++++++++++++++++++++++---------------
 test/ChangeLog    |    5 +++++
 test/Makefile.am  |   10 +++++++++-
 test/Makefile.in  |   10 +++++++++-
 test/profile6.awk |    7 +++++++
 test/profile6.ok  |   10 ++++++++++
 10 files changed, 145 insertions(+), 19 deletions(-)
 create mode 100644 test/profile6.awk
 create mode 100644 test/profile6.ok


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]