pspp-cvs
[Top][All Lists]
Advanced

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

[Pspp-cvs] pspp/src data/ChangeLog data/value.h language/s...


From: Ben Pfaff
Subject: [Pspp-cvs] pspp/src data/ChangeLog data/value.h language/s...
Date: Sat, 06 May 2006 23:04:05 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Branch:         
Changes by:     Ben Pfaff <address@hidden>      06/05/06 23:04:05

Modified files:
        src/data       : ChangeLog value.h 
        src/language/stats: ChangeLog aggregate.c autorecode.c 
        src/language/xforms: ChangeLog recode.c 

Log message:
        Get rid of `char *c' member in union value, for cleanliness.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/ChangeLog.diff?tr1=1.38&tr2=1.39&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/value.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/language/stats/ChangeLog.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/language/stats/aggregate.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/language/stats/autorecode.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/language/xforms/ChangeLog.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/language/xforms/recode.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: pspp/src/data/ChangeLog
diff -u pspp/src/data/ChangeLog:1.38 pspp/src/data/ChangeLog:1.39
--- pspp/src/data/ChangeLog:1.38        Sat May  6 22:37:30 2006
+++ pspp/src/data/ChangeLog     Sat May  6 23:04:05 2006
@@ -1,3 +1,9 @@
+Sat May  6 15:58:36 2006  Ben Pfaff  <address@hidden>
+
+       Get rid of `char *c' member in union value, for cleanliness.
+       
+       * value.h: (union value) Remove `c' member.
+
 Sat May  6 15:36:59 2006  Ben Pfaff  <address@hidden>
 
        Make dictionary compacting functions a little more general.
Index: pspp/src/data/value.h
diff -u pspp/src/data/value.h:1.3 pspp/src/data/value.h:1.4
--- pspp/src/data/value.h:1.3   Tue May  2 03:51:43 2006
+++ pspp/src/data/value.h       Sat May  6 23:04:05 2006
@@ -47,23 +47,12 @@
 #define LOWEST second_lowest_value
 #define HIGHEST DBL_MAX
 
-/* Describes one value, which is either a floating-point number or a
-   short string. */
+/* A numeric or short string value.
+   Multiple consecutive values represent a long string. */
 union value
   {
-    /* A numeric value. */
     double f;
-
-    /* A short-string value. */
     char s[MAX_SHORT_STRING];
-
-    /* Used by evaluate_expression() to return a string result.
-       As currently implemented, it's a pointer to a dynamic
-       buffer in the appropriate expression.
-
-       Also used by the AGGREGATE procedure in handling string
-       values. */
-    char *c;
   };
 
 /* Maximum number of `union value's in a single number or string
Index: pspp/src/language/stats/ChangeLog
diff -u pspp/src/language/stats/ChangeLog:1.19 
pspp/src/language/stats/ChangeLog:1.20
--- pspp/src/language/stats/ChangeLog:1.19      Sat May  6 17:46:52 2006
+++ pspp/src/language/stats/ChangeLog   Sat May  6 23:04:05 2006
@@ -1,3 +1,24 @@
+Sat May  6 16:00:13 2006  Ben Pfaff  <address@hidden>
+
+       Get rid of `char *c' member in union value, for cleanliness.
+       
+       * aggregate.c: (union agr_argument) New union.
+       (struct agr_var) Change element type of arg[] from union value to
+       union agr_argument.
+       (parse_aggregate_functions) Change local variable types likewise.
+
+       * autorecode.c: (union arc_value) New union.
+       (struct arc_item) Change "from" from union value to union
+       arc_value.
+       (recode) Change local variable from union value to union
+       arc_value.
+       (autorecode_trns_proc) Ditto.
+       (compare_alpha_value) Ditto.
+       (hash_alpha_value) Ditto.
+       (compare_numeric_value) Ditto.
+       (hash_numeric_value) Ditto.
+       (autorecode_proc_func) Ditto.
+
 Sat May  6 10:43:33 2006  Ben Pfaff  <address@hidden>
 
        Continue reforming procedure execution.  In this phase, get rid of
Index: pspp/src/language/stats/aggregate.c
diff -u pspp/src/language/stats/aggregate.c:1.8 
pspp/src/language/stats/aggregate.c:1.9
--- pspp/src/language/stats/aggregate.c:1.8     Sat May  6 18:01:13 2006
+++ pspp/src/language/stats/aggregate.c Sat May  6 23:04:05 2006
@@ -48,6 +48,13 @@
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
+/* Argument for AGGREGATE function. */
+union agr_argument
+  {
+    double f;                           /* Numeric. */
+    char *c;                            /* Short or long string. */
+  };
+
 /* Specifies how to make an aggregate variable. */
 struct agr_var
   {
@@ -58,7 +65,7 @@
     struct variable *dest;     /* Target variable. */
     int function;              /* Function. */
     int include_missing;       /* 1=Include user-missing values. */
-    union value arg[2];                /* Arguments. */
+    union agr_argument arg[2]; /* Arguments. */
 
     /* Accumulated during AGGREGATE execution. */
     double dbl[3];
@@ -359,7 +366,7 @@
       const struct agr_func *function;
       int func_index;
 
-      union value arg[2];
+      union agr_argument arg[2];
 
       struct variable **src;
       size_t n_src;
@@ -515,7 +522,7 @@
                   || (src[0]->type == ALPHA
                       && str_compare_rpad (arg[0].c, arg[1].c) > 0)))
             {
-              union value t = arg[0];
+              union agr_argument t = arg[0];
               arg[0] = arg[1];
               arg[1] = t;
                   
Index: pspp/src/language/stats/autorecode.c
diff -u pspp/src/language/stats/autorecode.c:1.7 
pspp/src/language/stats/autorecode.c:1.8
--- pspp/src/language/stats/autorecode.c:1.7    Sat May  6 18:01:13 2006
+++ pspp/src/language/stats/autorecode.c        Sat May  6 23:04:05 2006
@@ -40,10 +40,17 @@
 
 /* FIXME: Implement PRINT subcommand. */
 
+/* An AUTORECODE variable's original value. */
+union arc_value 
+  {
+    double f;                   /* Numeric. */
+    char *c;                    /* Short or long string. */
+  };
+
 /* Explains how to recode one value.  `from' must be first element.  */
 struct arc_item
   {
-    union value from;          /* Original value. */
+    union arc_value from;      /* Original value. */
     double to;                 /* Recoded value. */
   };
 
@@ -76,7 +83,7 @@
     struct variable **src_vars;    /* Source variables. */
     char **dst_names;              /* Target variable names. */
     struct variable **dst_vars;    /* Target variables. */
-    struct hsh_table **src_values; /* `union value's of source vars. */
+    struct hsh_table **src_values; /* `union arc_value's of source vars. */
     size_t var_cnt;                /* Number of variables. */
     struct pool *src_values_pool;  /* Pool used by src_values. */
     enum direction direction;      /* Sort order. */
@@ -248,7 +255,7 @@
       for (j = 0; *p; p++, j++)
        {
          struct arc_item *item = pool_alloc (trns->pool, sizeof *item);
-          union value *vp = *p;
+          union arc_value *vp = *p;
           
          if (arc->src_vars[i]->type == NUMERIC)
             item->from.f = vp->f;
@@ -273,7 +280,7 @@
     {
       struct arc_spec *spec = &trns->specs[i];
       struct arc_item *item;
-      union value v;
+      union arc_value v;
 
       if (spec->src->type == NUMERIC)
         v.f = case_num (c, spec->src->fv);
@@ -304,8 +311,8 @@
 static int
 compare_alpha_value (const void *a_, const void *b_, void *v_)
 {
-  const union value *a = a_;
-  const union value *b = b_;
+  const union arc_value *a = a_;
+  const union arc_value *b = b_;
   const struct variable *v = v_;
 
   return memcmp (a->c, b->c, v->width);
@@ -314,7 +321,7 @@
 static unsigned
 hash_alpha_value (const void *a_, void *v_)
 {
-  const union value *a = a_;
+  const union arc_value *a = a_;
   const struct variable *v = v_;
   
   return hsh_hash_bytes (a->c, v->width);
@@ -323,8 +330,8 @@
 static int
 compare_numeric_value (const void *a_, const void *b_, void *foo UNUSED)
 {
-  const union value *a = a_;
-  const union value *b = b_;
+  const union arc_value *a = a_;
+  const union arc_value *b = b_;
 
   return a->f < b->f ? -1 : a->f > b->f;
 }
@@ -332,7 +339,7 @@
 static unsigned
 hash_numeric_value (const void *a_, void *foo UNUSED)
 {
-  const union value *a = a_;
+  const union arc_value *a = a_;
 
   return hsh_hash_double (a->f);
 }
@@ -345,14 +352,14 @@
 
   for (i = 0; i < arc->var_cnt; i++)
     {
-      union value v, *vp, **vpp;
+      union arc_value v, *vp, **vpp;
 
       if (arc->src_vars[i]->type == NUMERIC)
         v.f = case_num (c, arc->src_vars[i]->fv);
       else
         v.c = (char *) case_str (c, arc->src_vars[i]->fv);
 
-      vpp = (union value **) hsh_probe (arc->src_values[i], &v);
+      vpp = (union arc_value **) hsh_probe (arc->src_values[i], &v);
       if (*vpp == NULL)
         {
           vp = pool_alloc (arc->src_values_pool, sizeof *vp);
Index: pspp/src/language/xforms/ChangeLog
diff -u pspp/src/language/xforms/ChangeLog:1.4 
pspp/src/language/xforms/ChangeLog:1.5
--- pspp/src/language/xforms/ChangeLog:1.4      Sat May  6 21:13:08 2006
+++ pspp/src/language/xforms/ChangeLog  Sat May  6 23:04:05 2006
@@ -1,3 +1,13 @@
+Sat May  6 16:02:55 2006  Ben Pfaff  <address@hidden>
+
+       Get rid of `char *c' member in union value, for cleanliness.
+
+       * recode.c: (union recode_value) New union.
+       (struct map_in) Change x, y types to union recode_value.
+       (struct map_out) Change value type to union recode_value.
+       (find_src_string) Wrap data_in() call so it uses a real `union
+       value'.
+
 Sat May  6 14:08:42 2006  Ben Pfaff  <address@hidden>
 
        * select-if.c (cmd_filter): Make FILTER without any further
Index: pspp/src/language/xforms/recode.c
diff -u pspp/src/language/xforms/recode.c:1.6 
pspp/src/language/xforms/recode.c:1.7
--- pspp/src/language/xforms/recode.c:1.6       Fri May  5 04:53:13 2006
+++ pspp/src/language/xforms/recode.c   Sat May  6 23:04:05 2006
@@ -56,18 +56,25 @@
     MAP_CONVERT                        /* "123" => 123. */
   };
 
+/* A value involved in a RECODE mapping. */
+union recode_value 
+  {
+    double f;                   /* Numeric. */
+    char *c;                    /* Short or long string. */
+  };
+
 /* Describes input values to be mapped. */
 struct map_in
   {
     enum map_in_type type;      /* One of MAP_*. */
-    union value x, y;           /* Source values. */
+    union recode_value x, y;    /* Source values. */
   };
 
 /* Describes the value used as output from a mapping. */
 struct map_out 
   {
     bool copy_input;            /* If true, copy input to output. */
-    union value value;          /* If copy_input false, recoded value. */
+    union recode_value value;   /* If copy_input false, recoded value. */
     int width;                  /* If copy_input false, output value width. */ 
   };
 
@@ -585,17 +592,19 @@
           break;
         case MAP_CONVERT:
           {
+            union value uv;
             struct data_in di;
 
             di.s = value;
             di.e = value + width;
-            di.v = &out->value;
+            di.v = &uv;
             di.flags = DI_IGNORE_ERROR;
             di.f1 = di.f2 = 0;
             di.format.type = FMT_F;
             di.format.w = width;
             di.format.d = 0;
             match = data_in (&di);
+            out->value.f = uv.f;
             break;
           }
         default:




reply via email to

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