gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, stable/printf-rework, updated. gawk-4.1.0-5528-g8a88c


From: Arnold Robbins
Subject: [SCM] gawk branch, stable/printf-rework, updated. gawk-4.1.0-5528-g8a88c089
Date: Tue, 6 Aug 2024 14:43:10 -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, stable/printf-rework has been updated
       via  8a88c089d0aab4cb416b36a985cb4fd3367cf6ae (commit)
      from  f76ca80261ac84e129c1b553ff35a0ae0959f524 (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=8a88c089d0aab4cb416b36a985cb4fd3367cf6ae

commit 8a88c089d0aab4cb416b36a985cb4fd3367cf6ae
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Tue Aug 6 21:42:45 2024 +0300

    Fix some additional printf corner cases and add tests.

diff --git a/ChangeLog b/ChangeLog
index ee42aec0..358d3274 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-08-06         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * printf.c (format_unsigned_integer, format_signed_integer):
+       Additional fixes. New added tests pass.
+
 2024-07-26         Arnold D. Robbins     <arnold@skeeve.com>
 
        * re.c (check_bracket_exp): Make the code actually work.
diff --git a/printf.c b/printf.c
index 648c9f38..5c604a92 100644
--- a/printf.c
+++ b/printf.c
@@ -1022,7 +1022,9 @@ format_signed_integer(NODE *arg, struct flags *flags)
                number_value[0] = '\0';         // value is empty
 
                return add_plus_or_space_and_fill(number_value, flags);
-       } else if (flags->have_prec && val_len < flags->precision) {
+       } else if (flags->have_prec &&
+                       (val_len < flags->precision ||
+                        flags->negative && val_len - 1 < flags->precision)) {
                buf1 = zero_fill_to_precision(number_value, flags);
                val_len = strlen(buf1);
 
@@ -1125,6 +1127,8 @@ format_unsigned_integer(NODE *arg, struct flags *flags)
        // Add more output digits to match the precision
        if (flags->have_prec && val_len < flags->precision) {
                // we ignore flags->alt when there's a precision
+               // also plus and space
+               flags->plus = flags->space = false;
                buf1 = zero_fill_to_precision(number_value, flags);     // 
frees number_value
                val_len = strlen(buf1);
                number_value = buf1;
diff --git a/test/ChangeLog b/test/ChangeLog
index 478199af..963bd31e 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2024-08-06         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * printf-corners.awk, printf-corners.ok, printf-corners-mpfr: Add
+       six additional test cases. Thanks to Maciej W. Rozycki
+       <macro@redhat.com>.
+
 2024-07-23         Arnold D. Robbins     <arnold@skeeve.com>
 
        * printf-corners.awk, printf-corners.ok, printf-corners-mpfr: Add
diff --git a/test/printf-corners-mpfr.ok b/test/printf-corners-mpfr.ok
index d9fa07bc..5eb24699 100644
--- a/test/printf-corners-mpfr.ok
+++ b/test/printf-corners-mpfr.ok
@@ -77,3 +77,10 @@
 <                -inf>
 <                -INF>
 <   00045>
+<-01>
+<-012>
+<-001>
+<01>
+<01>
+<012>
+<12>
diff --git a/test/printf-corners.awk b/test/printf-corners.awk
index b1f991ed..2dee4abb 100644
--- a/test/printf-corners.awk
+++ b/test/printf-corners.awk
@@ -78,4 +78,11 @@ BEGIN {
        printf "<%20.20a>\n", "-inf"    # "                -inf"
        printf "<%20.20A>\n", "-inf"    # "                -INF"
        printf "<%3$*2$.*1$d>\n", 5, 8, 45      # "   00045"
+       printf "<%.2i>\n", -1           # "-01"
+       printf "<%.3i>\n", -12          # "-012"
+       printf "<%.3i>\n", -1           # "-001"
+       printf "<%.2i>\n", 1            # "01"
+       printf "<%+.2u>\n", 1           # "01"
+       printf "<% .3u>\n", 12          # "012
+       printf "<%+.2u>\n", 12          # "12"
 }
diff --git a/test/printf-corners.ok b/test/printf-corners.ok
index d9fa07bc..5eb24699 100644
--- a/test/printf-corners.ok
+++ b/test/printf-corners.ok
@@ -77,3 +77,10 @@
 <                -inf>
 <                -INF>
 <   00045>
+<-01>
+<-012>
+<-001>
+<01>
+<01>
+<012>
+<12>

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

Summary of changes:
 ChangeLog                   | 5 +++++
 printf.c                    | 6 +++++-
 test/ChangeLog              | 6 ++++++
 test/printf-corners-mpfr.ok | 7 +++++++
 test/printf-corners.awk     | 7 +++++++
 test/printf-corners.ok      | 7 +++++++
 6 files changed, 37 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
gawk



reply via email to

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