gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, long-double, updated. 42dd95107c29fc8f2e


From: John Haque
Subject: [gawk-diffs] [SCM] gawk branch, long-double, updated. 42dd95107c29fc8f2e1ca370a083a2d63e17fb57
Date: Fri, 11 Jan 2013 12:47:24 +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, long-double has been updated
       via  42dd95107c29fc8f2e1ca370a083a2d63e17fb57 (commit)
       via  951972c4d26b8ae2f42fd4133a0983b2d10dc88d (commit)
       via  b97f64ab95ef7407de4ce4f14b3477b8d62e5430 (commit)
      from  549fa6fcb6633c2e99c6853735443f4ae2880c5e (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=42dd95107c29fc8f2e1ca370a083a2d63e17fb57

commit 42dd95107c29fc8f2e1ca370a083a2d63e17fb57
Author: John Haque <address@hidden>
Date:   Fri Jan 11 06:36:00 2013 -0600

    Updated long_double.c for format_tree() related changes.

diff --git a/long_double.c b/long_double.c
index e5a5261..7d94afd 100644
--- a/long_double.c
+++ b/long_double.c
@@ -35,17 +35,10 @@
 
 #define AWKLDBL        long double
 
-/* XXX: define to 1 to try AWKNUM as long double */
-/* #define AWKNUM_LDBL 1 */
-
 
 #include "long_double.h"
 
-#ifdef AWKNUM_LDBL
-#define LDBL(n)        ((n)->numbr)
-#else
 #define LDBL(n)        (*((AWKLDBL *) (n)->qnumbr))
-#endif
 
 /* Can declare these, since we always use the random shipped with gawk */
 extern char *initstate(unsigned long seed, char *state, long n);
@@ -59,8 +52,6 @@ extern void srandom(unsigned long seed);
  */
 #define GAWK_RANDOM_MAX 0x7fffffffL
 
-extern NODE **fmt_list;          /* declared in eval.c */
-
 /*
  * FIXME -- some of these are almost identical except for the number definition
  * #define DBLNUM      AWKNUM
@@ -124,20 +115,13 @@ static int is_ieee_magic_val(const char *val);
 static AWKLDBL get_ieee_magic_val(const char *val);
 static AWKLDBL calc_exp(AWKLDBL x1, AWKLDBL x2);
 static AWKLDBL double_to_int(AWKLDBL d);
-#ifndef AWKNUM_LDBL
 static NODE *make_awkldbl(AWKLDBL);
-#endif
 
 static long MFNR;
 static long MNR;
 
-#ifdef AWKNUM_LDBL
-#define get_long_double(d)     /* nothing */
-#define free_long_double(d)    /* nothing */
-#else
 #define get_long_double(d)     getblock(d, BLOCK_LDBL, AWKLDBL *)
 #define free_long_double(d)    freeblock(d, BLOCK_LDBL)
-#endif
 
 #if 0
 #define get_long_double(d)     emalloc(d, void *, sizeof(AWKLDBL), 
"long_double")
@@ -151,11 +135,7 @@ numbr_handler_t awkldbl_hndlr = {
        make_awknum,
        str2awkldbl,
        awkldbl_copy,
-#ifndef AWKNUM_LDBL
        free_awkldbl,
-#else
-       NULL,   /* free_awkldbl --- not needed for AWKNUM */
-#endif
        force_awkldbl,
        negate_awkldbl,
        cmp_awkldbls,
@@ -434,7 +414,6 @@ awkldbl_init_vars()
  *     this routine is not exported. 
  */
 
-#ifndef AWKNUM_LDBL
 static NODE *
 make_awkldbl(AWKLDBL x)
 {
@@ -453,7 +432,6 @@ make_awkldbl(AWKLDBL x)
 #endif /* defined MBS_SUPPORT */
        return r;
 }
-#endif
 
 /* make_awknum --- allocate a node with defined AWKNUM */
 
@@ -478,14 +456,12 @@ make_awknum(AWKNUM x)
 
 /* free_awkldbl --- free all storage allocated for a AWKLDBL */
 
-#ifndef AWKNUM_LDBL
 static void
 free_awkldbl(NODE *tmp)
 {
        assert((tmp->flags & (NUMBER|NUMCUR)) != 0);
         free_long_double(tmp->qnumbr);
 }
-#endif
 
 /* make_integer --- Convert an integer to a number node. */
 
@@ -1134,10 +1110,17 @@ format_awkldbl_val(const char *format, int index, NODE 
*s)
 
        d = LDBL(s);
 
+       if ((s->flags & STRCUR) != 0)
+               efree(s->stptr);
+       free_wstr(s);
+
        /* not an integral value, or out of range */
        if ((ival = double_to_int(d)) != d
                        || ival <= LONG_MIN || ival >= LONG_MAX
        ) {
+               struct format_spec spec;
+               struct print_fmt_buf *outb;
+
                /*
                 * Once upon a time, we just blindly did this:
                 *      sprintf(sp, format, s->numbr);
@@ -1147,30 +1130,24 @@ format_awkldbl_val(const char *format, int index, NODE 
*s)
                 * and just always format the value ourselves.
                 */
 
-               NODE *dummy[2], *r;
-               unsigned int oflags;
-
-               /* create dummy node for a sole use of format_tree */
-               dummy[1] = s;
-               oflags = s->flags;
+               /* XXX: format_spec copied since can be altered in the 
formatting routine */
 
                if (ival == d) {
                        /* integral value, but outside range of %ld, use %.0f */
-                       r = format_tree("%.0f", 4, dummy, 2);
+                       spec = *fmt_list[INT_0f_FMT_INDEX].spec;
                        s->stfmt = -1;
                } else {
-                       r = format_tree(format, fmt_list[index]->stlen, dummy, 
2);
-                       assert(r != NULL);
-                       s->stfmt = (char) index;
+                       assert(fmt_list[index].spec != NULL);   /* or can use 
fmt_parse() --- XXX */
+                       spec = *fmt_list[index].spec;
+                       s->stfmt = (char) index;        
                }
-               s->flags = oflags;
-               s->stlen = r->stlen;
-               if ((s->flags & STRCUR) != 0)
-                       efree(s->stptr);
-               s->stptr = r->stptr;
-               freenode(r);    /* Do not unref(r)! We want to keep s->stptr == 
r->stpr.  */
-
-               goto no_malloc;
+
+               outb = get_fmt_buf();
+               format_awkldbl_printf(s, & spec, outb);
+               (void) bytes2node(outb, s);
+               free_fmt_buf(outb);
+
+               s->stptr[s->stlen] = '\0';
        } else {
                /*
                 * integral value; force conversion to long only once.
@@ -1189,14 +1166,12 @@ format_awkldbl_val(const char *format, int index, NODE 
*s)
                        s->flags &= ~(INTIND|NUMBER);
                        s->flags |= STRING;
                }
+
+               emalloc(s->stptr, char *, s->stlen + 2, "format_awkldbl_val");
+               memcpy(s->stptr, sp, s->stlen + 1);
        }
-       if (s->stptr != NULL)
-               efree(s->stptr);
-       emalloc(s->stptr, char *, s->stlen + 2, "format_awkldbl_val");
-       memcpy(s->stptr, sp, s->stlen + 1);
-no_malloc:
+
        s->flags |= STRCUR;
-       free_wstr(s);
        return s;
 }
 

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

commit 951972c4d26b8ae2f42fd4133a0983b2d10dc88d
Merge: 549fa6f b97f64a
Author: John Haque <address@hidden>
Date:   Fri Jan 11 06:13:47 2013 -0600

    Merge branch 'num-handler' into long-double


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

Summary of changes:
 ChangeLog                   |   12 +++
 TODO.NUMH                   |   26 +++++++-
 array.c                     |    4 +-
 awk.h                       |   10 ++-
 awklib/eg/lib/repl_math.awk |   23 ++++---
 builtin.c                   |   72 +++++++++++++++++---
 double.c                    |   53 ++++++++-------
 eval.c                      |   65 +++++++++++++++---
 format.h                    |   42 ++++++++++--
 long_double.c               |   71 ++++++-------------
 mpfr.c                      |  156 +++++++++++++++++++++++--------------------
 11 files changed, 348 insertions(+), 186 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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