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-5505-g964a4


From: Arnold Robbins
Subject: [SCM] gawk branch, stable/printf-rework, updated. gawk-4.1.0-5505-g964a4516
Date: Sun, 14 Jul 2024 08:57:30 -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  964a4516d5cf3e7ec4191f3559b0358d6562c762 (commit)
       via  75f7cf551720c1a240626c10f37972cf3563ddc3 (commit)
      from  fd33a7cd1eb2c5372e30d5e79a3164cd2fdc133e (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=964a4516d5cf3e7ec4191f3559b0358d6562c762

commit 964a4516d5cf3e7ec4191f3559b0358d6562c762
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Sun Jul 14 15:56:05 2024 +0300

    Checkpoint commit. -M and all but printf-corners passing.

diff --git a/printf.c b/printf.c
index ebaca2b1..8f189898 100644
--- a/printf.c
+++ b/printf.c
@@ -2912,7 +2912,7 @@ format_mpg_integer(NODE *arg, struct flags *flags)
        char *cp;
        char cpbuf[30];
        int nc;
-       bool need_to_add_thousands = false;
+       bool need_to_add_thousands = (strchr("diu", flags->format) != NULL);
 
        fmt_type = flags->have_prec ? MP_INT_WITH_PREC : MP_INT_WITHOUT_PREC;
        if (is_mpg_integer(arg)) {
@@ -2929,6 +2929,7 @@ format_mpg_integer(NODE *arg, struct flags *flags)
                                mf = mpz2mpfr(zi);
                                goto mpf1;
                        }
+                       flags->plus = flags->space = false;     // Don't print 
the +
                }
 
 //             fmt_type = flags->have_prec ? MP_INT_WITH_PREC : 
MP_INT_WITHOUT_PREC;
@@ -2960,6 +2961,7 @@ mpf1:
                                }
                                goto fmt0;
                        }
+                       flags->plus = flags->space = false;     // Don't print 
the +
                }
 
                (void) mpfr_get_z(mpzval, mf, MPFR_RNDZ);       /* convert to 
GMP integer */
@@ -2977,6 +2979,7 @@ fmt0:
        else if (flags->space)
                signchar = ' ';
 
+       bool zero_flag = compute_zero_flag(flags);
        cp = cpbuf;
        *cp++ = '%';
        if (flags->left_just)
@@ -2985,7 +2988,7 @@ fmt0:
                *cp++ = signchar;
        if (flags->alt)
                *cp++ = '#';
-       if (flags->zero)
+       if (zero_flag)
                *cp++ = '0';
        if (flags->quote)
                *cp++ = '\'';

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

commit 75f7cf551720c1a240626c10f37972cf3563ddc3
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Sun Jul 14 14:37:37 2024 +0300

    Checkpiont commit, passing all tests!

diff --git a/printf.c b/printf.c
index 800d9651..ebaca2b1 100644
--- a/printf.c
+++ b/printf.c
@@ -2493,21 +2493,37 @@ format_signed_integer(NODE *arg, struct flags *flags)
                int fw = flags->field_width;
                char *cp;
 
+               /*
+                * No actual value. But if there is plus or space or wide
+                * field width or left just, we have to handle those. Bleah.
+                */
                free((void *) number_value);
 
-               if (flags->field_width == 0) {
+               emalloc(buf1, char *, flags->field_width + (flags->plus || 
flags->space) + 1,
+                               "format_signed_integer");
+               cp = buf1;
+               if (flags->left_just) {
+                       if (flags->plus) {
+                               *cp++ = '+';
+                               fw--;
+                       } else if (flags->space) {
+                               *cp++ = ' ';
+                               fw--;
+                       }
+                       for (; fw > 0; fw--)
+                               *cp++ = ' ';
+                       *cp = '\0';
+               } else if (fw > 0 || flags->plus || flags->space) {
+                       char final = ' ';
                        if (flags->plus)
-                               return estrdup("+", 1);
-                       else if (flags->space)
-                               return estrdup(" ", 1);
-                       else
-                               return estrdup("", 1);
-               }
+                               final = '+';
 
-               emalloc(buf1, char *, flags->field_width + 1, 
"format_signed_integer");
-               for (cp = buf1; fw > 0; fw--)
-                       *cp++ = ' ';
-               *cp = '\0';
+                       for (fw--; fw > 0; fw--)
+                               *cp++ = ' ';
+                       *cp++ = final;
+                       *cp = '\0';
+               } else
+                       buf1[0] = '\0';
 
                return buf1;
        } else if (flags->have_prec && val_len < flags->precision) {
@@ -2695,7 +2711,12 @@ format_unsigned_integer(NODE *arg, struct flags *flags)
                                        buf1 = (char *) number_value;
                        } else {
                                free((void *) number_value);
-                               buf1 = estrdup("", 1);
+                               if (flags->plus)
+                                       buf1 = estrdup("+", 1);
+                               else if (flags->space)
+                                       buf1 = estrdup(" ", 1);
+                               else
+                                       buf1 = estrdup("", 1);
                        }
                } else
                        buf1 = (char *) number_value;
@@ -2783,6 +2804,14 @@ format_unsigned_integer(NODE *arg, struct flags *flags)
                val_len = strlen(buf1);
        }
 
+       if (is_zero(arg) && (flags->plus || flags->space)) {
+               emalloc(buf2, char *, val_len + 3, "format_unsigned_integer");
+               strcpy(buf2, " ");
+               free((void *) buf1);
+               buf1 = buf2;
+               val_len = strlen(buf1);
+       }
+
        return buf1;
 }
 
@@ -3064,17 +3093,17 @@ adjust_flags(struct flags *flags)
 
        if (flags->base != 10) {
                flags->quote = false;
-//             flags->plus = false;
-//             flags->space = false;
        }
 
        if (flags->plus)
                flags->space = false;
 
+/*
        if (flags->format == 'u') {
                flags->plus = false;
                flags->space = false;
        }
+*/
 
        if (strchr("diouxX", flags->format) != NULL && flags->have_prec)
                flags->zero = false;

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

Summary of changes:
 printf.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 48 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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