gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, feature/bool, updated. gawk-4.1.0-4258-ge1b7b04


From: Arnold Robbins
Subject: [SCM] gawk branch, feature/bool, updated. gawk-4.1.0-4258-ge1b7b04
Date: Sat, 20 Mar 2021 15:37:48 -0400 (EDT)

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, feature/bool has been updated
       via  e1b7b04b63a83913f62e4bfff645b940eacf7803 (commit)
      from  40cd3b0df6128e5b111c9b7c5c9892eac13a3497 (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=e1b7b04b63a83913f62e4bfff645b940eacf7803

commit e1b7b04b63a83913f62e4bfff645b940eacf7803
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Sat Mar 20 21:37:35 2021 +0200

    Handle bools for array sorting.

diff --git a/ChangeLog b/ChangeLog
index e248bcc..5f2794d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2021-03-20         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * array.c (do_sort_up_value_type): Add logic for handling bools.
+
 2021-03-08         Arnold D. Robbins     <arnold@skeeve.com>
 
        * awk.h (warn_bool, do_bool): Add function declarations.
diff --git a/array.c b/array.c
index 50efddb..b4ce86b 100644
--- a/array.c
+++ b/array.c
@@ -1209,11 +1209,24 @@ do_sort_up_value_type(const void *p1, const void *p2)
        (void) fixtype(n1);
        (void) fixtype(n2);
 
+       /* 3a. Bools first */
+       if ((n1->flags & BOOL) != 0 && (n2->flags & BOOL) != 0) {
+               return cmp_numbers(n1, n2);
+       }
+
+       /* 3b. Numbers next */
        if ((n1->flags & NUMBER) != 0 && (n2->flags & NUMBER) != 0) {
                return cmp_numbers(n1, n2);
        }
 
-       /* 3. All numbers are less than all strings. This is aribitrary. */
+       /* 3c. Bools before everything else */
+       if ((n1->flags & BOOL) != 0 && (n2->flags & BOOL) == 0) {
+               return -1;
+       } else if ((n1->flags & BOOL) == 0 && (n2->flags & BOOL) != 0) {
+               return 1;
+       }
+
+       /* 3d. All numbers are less than all strings. This is aribitrary. */
        if ((n1->flags & NUMBER) != 0 && (n2->flags & STRING) != 0) {
                return -1;
        } else if ((n1->flags & STRING) != 0 && (n2->flags & NUMBER) != 0) {

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

Summary of changes:
 ChangeLog |  4 ++++
 array.c   | 15 ++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
gawk



reply via email to

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