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-5498-g1cd00


From: Arnold Robbins
Subject: [SCM] gawk branch, stable/printf-rework, updated. gawk-4.1.0-5498-g1cd00fb6
Date: Thu, 11 Jul 2024 06:25:47 -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  1cd00fb6721736922f01c19d2455ebe1d5b3950c (commit)
      from  a6726a26cc61aaee4043cd3cae3237f46df27c48 (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=1cd00fb6721736922f01c19d2455ebe1d5b3950c

commit 1cd00fb6721736922f01c19d2455ebe1d5b3950c
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Thu Jul 11 13:25:30 2024 +0300

    Continuing to improve printf.

diff --git a/ChangeLog b/ChangeLog
index f1484301..bdb6153a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-07-11         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * printf.c: Signed and unsigned integer printing and float printing
+       working for current tests.
+
 2024-07-09         Arnold D. Robbins     <arnold@skeeve.com>
 
        * printf.c: Signed printing I think is working. Unsigned is better.
diff --git a/printf.c b/printf.c
index d134e91c..96a4f84c 100644
--- a/printf.c
+++ b/printf.c
@@ -2654,11 +2654,18 @@ format_unsigned_integer(NODE *arg, struct flags *flags)
 
                        strcpy(cp, src);
                        free((void *) number_value);
-               } else if (flags->have_prec && flags->precision == 0 && 
flags->base == 8
-                               && number_value[0] != '0') {
-                       emalloc(buf1, char *, val_len + 2, 
"format_unsigned_integer");
-                       sprintf(buf1, "0%s", number_value);
-                       free((void *) number_value);
+               } else if (flags->have_prec && flags->precision == 0) {
+                       if (flags->base == 8) {
+                               if (number_value[0] != '0') {
+                                       emalloc(buf1, char *, val_len + 2, 
"format_unsigned_integer");
+                                       sprintf(buf1, "0%s", number_value);
+                                       free((void *) number_value);
+                               } else
+                                       buf1 = (char *) number_value;
+                       } else {
+                               free((void *) number_value);
+                               buf1 = strdup("");
+                       }
                } else
                        buf1 = (char *) number_value;
 
@@ -2686,9 +2693,9 @@ format_unsigned_integer(NODE *arg, struct flags *flags)
                                        for (; fw > val_len; fw--)
                                                *cp++ = fill[0];
                                } else {
-                                       for (; fw > val_len; fw--)
-                                               *cp++ = fill[0];
                                        fw -= 2;
+                                       // for (; fw > val_len; fw--)
+                                       //      *cp++ = fill[0];
                                        *cp++ = '0';
                                        *cp++ = flags->format;
                                }
@@ -2703,10 +2710,11 @@ format_unsigned_integer(NODE *arg, struct flags *flags)
 
                val_len = strlen(buf1);
 
-               if (val_len < fw) {
+               if (val_len < flags->field_width) {
                        emalloc(buf2, char *, flags->field_width + 1, 
"format_unsigned_integer");
                        cp = buf2;
 
+                       fw = flags->field_width;
                        if (flags->left_just) {
                                strcpy(cp, buf1);
                                cp += val_len;
@@ -2949,7 +2957,7 @@ adjust_flags(struct flags *flags)
        if (flags->base == 0)
                cant_happen("%s", "flags->base == 0");
 
-       if (flags->base == 10 || strchr("cdisu", flags->format) != NULL)
+       if (flags->base == 10 && strchr("cdisu", flags->format) != NULL)
                flags->alt = false;
 
        if (flags->field_width < 0) {

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

Summary of changes:
 ChangeLog |  5 +++++
 printf.c  | 26 +++++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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