Fix EXPORT problem with string variables. From Andreas Streichardt
[pspp-builds.git] / src / tab.c
index 3a8fef01d59e2574eed559a17a2f01d78ad71e84..fbb292fdbb84b6639a844b26a1d689df87e1fc31 100644 (file)
--- a/src/tab.c
+++ b/src/tab.c
@@ -570,7 +570,6 @@ tab_value (struct tab_table *table, int c, int r, unsigned char opt,
           const union value *v, const struct fmt_spec *f)
 {
   char *contents;
-  union value temp_val;
 
   assert (table != NULL && v != NULL && f != NULL);
 #if GLOBAL_DEBUGGING
@@ -591,11 +590,6 @@ tab_value (struct tab_table *table, int c, int r, unsigned char opt,
   ls_init (&table->cc[c + r * table->cf], contents, f->w);
   table->ct[c + r * table->cf] = opt;
   
-  if (formats[f->type].cat & FCAT_STRING)
-    {
-      temp_val.c = (char *) v->s;
-      v = &temp_val;
-    }
   data_out (contents, f, v);
 }
 
@@ -609,9 +603,15 @@ tab_float (struct tab_table *table, int c, int r, unsigned char opt,
   char buf[40], *cp;
   
   struct fmt_spec f;
+  union value double_value;
 
   assert (table != NULL && w <= 40);
   
+  assert (c >= 0);
+  assert (c < table->nc);
+  assert (r >= 0);
+  assert (r < table->nr);
+
   f.type = FMT_F;
   f.w = w;
   f.d = d;
@@ -630,7 +630,9 @@ tab_float (struct tab_table *table, int c, int r, unsigned char opt,
     }
 #endif
 
-  data_out (buf, &f, (union value *) &val);
+  double_value.f = val;
+  data_out (buf, &f, &double_value);
+
   cp = buf;
   while (isspace ((unsigned char) *cp) && cp < &buf[w])
     cp++;
@@ -1258,7 +1260,7 @@ struct som_table_class tab_table_class =
 
    FIXME: Doesn't use r1?  Huh?  */
 static int
-render_strip (int x, int y, int r, int c1, int c2, int r1 unused, int r2)
+render_strip (int x, int y, int r, int c1, int c2, int r1 UNUSED, int r2)
 {
   int x_origin = x;
 
@@ -1340,8 +1342,7 @@ render_strip (int x, int y, int r, int c1, int c2, int r1 unused, int r2)
                    {
                      j->hit = tab_hit;
 
-                     if (j->x1 == c / 2 && j->y1 == r / 2
-                         && j->x2 <= c2 && j->y2 <= r2)
+                     if (j->x1 == c / 2 && j->y1 == r / 2)
                        {
                          struct outp_text text;
 
@@ -1355,15 +1356,15 @@ render_strip (int x, int y, int r, int c1, int c2, int r1 unused, int r2)
                            int c;
 
                            for (c = j->x1, text.h = -t->wrv[j->x2];
-                                c < j->x2; c++)
-                             text.h += t->w[c] + t->wrv[c + 1];
+                                c < j->x2 && c < c2 / 2; c++) 
+                                text.h += t->w[c] + t->wrv[c + 1]; 
                          }
                          
                          {
                            int r;
 
                            for (r = j->y1, text.v = -t->hrh[j->y2];
-                                r < j->y2; r++)
+                                r < j->y2 && r < r2 / 2; r++)
                              text.v += t->h[r] + t->hrh[r + 1];
                          }
                          d->class->text_draw (d, &text);