First step in making struct variable opaque: the boring mechanical
[pspp-builds.git] / src / data / case.c
index 98de9ec6a1eab70fdd6bd1f52d7558e9ffee842a..e41c0e2235945a64a0ff2867827e7baf203913fc 100644 (file)
@@ -161,9 +161,9 @@ case_swap (struct ccase *a, struct ccase *b)
 }
 
 /* Attempts to create C as a new case that holds VALUE_CNT
-   values.  Returns nonzero if successful, zero if memory
+   values.  Returns true if successful, false if memory
    allocation failed. */
-int
+bool
 case_try_create (struct ccase *c, size_t value_cnt) 
 {
   c->case_data = malloc (case_size (value_cnt));
@@ -171,20 +171,20 @@ case_try_create (struct ccase *c, size_t value_cnt)
     {
       c->case_data->value_cnt = value_cnt;
       c->case_data->ref_cnt = 1;
-      return 1;
+      return true;
     }
-  else 
-    return 0;
+  
+  return false;
 }
 
 /* Tries to initialize CLONE as a copy of ORIG.
-   Returns nonzero if successful, zero if memory allocation
+   Returns true if successful, false if memory allocation
    failed. */
-int
+bool
 case_try_clone (struct ccase *clone, const struct ccase *orig) 
 {
   case_clone (clone, orig);
-  return 1;
+  return true;
 }
 
 #ifdef DEBUGGING
@@ -338,10 +338,9 @@ case_compare_2dict (const struct ccase *ca, const struct ccase *cb,
       const struct variable *va = *vap;
       const struct variable *vb = *vbp;
 
-      assert (va->type == vb->type);
-      assert (va->width == vb->width);
+      assert (var_get_width (va) == var_get_width (vb));
       
-      if (va->width == 0) 
+      if (var_get_width (va) == 0) 
         {
           double af = case_num (ca, va->fv);
           double bf = case_num (cb, vb->fv);
@@ -353,7 +352,7 @@ case_compare_2dict (const struct ccase *ca, const struct ccase *cb,
         {
           const char *as = case_str (ca, va->fv);
           const char *bs = case_str (cb, vb->fv);
-          int cmp = memcmp (as, bs, va->width);
+          int cmp = memcmp (as, bs, var_get_width (va));
 
           if (cmp != 0)
             return cmp;