Delete trailing whitespace at end of lines.
[pspp-builds.git] / src / data / case.c
index cd559c0fc25a0612019174b2cb0fa9af69765c9a..578f8b6acbe66c8774ff667a46beed34f362f6f9 100644 (file)
@@ -41,7 +41,7 @@ struct case_data
 
 /* Ensures that C does not share data with any other case. */
 static void
-case_unshare (struct ccase *c) 
+case_unshare (struct ccase *c)
 {
   if (c->case_data->ref_cnt > 1)
     {
@@ -49,14 +49,14 @@ case_unshare (struct ccase *c)
       cd->ref_cnt--;
       case_create (c, cd->value_cnt);
       memcpy (c->case_data->values, cd->values,
-              sizeof *cd->values * cd->value_cnt); 
+              sizeof *cd->values * cd->value_cnt);
     }
 }
 
 /* Returns the number of bytes needed by a case with VALUE_CNT
    values. */
 static size_t
-case_size (size_t value_cnt) 
+case_size (size_t value_cnt)
 {
   return (offsetof (struct case_data, values)
           + value_cnt * sizeof (union value));
@@ -64,14 +64,14 @@ case_size (size_t value_cnt)
 
 /* Initializes C as a null case. */
 void
-case_nullify (struct ccase *c) 
+case_nullify (struct ccase *c)
 {
   c->case_data = NULL;
 }
 
 /* Returns true iff C is a null case. */
 bool
-case_is_null (const struct ccase *c) 
+case_is_null (const struct ccase *c)
 {
   return c->case_data == NULL;
 }
@@ -80,7 +80,7 @@ case_is_null (const struct ccase *c)
    The values have indeterminate contents until explicitly
    written. */
 void
-case_create (struct ccase *c, size_t value_cnt) 
+case_create (struct ccase *c, size_t value_cnt)
 {
   if (!case_try_create (c, value_cnt))
     xalloc_die ();
@@ -92,7 +92,7 @@ case_clone (struct ccase *clone, const struct ccase *orig)
 {
   assert (orig->case_data->ref_cnt > 0);
 
-  if (clone != orig) 
+  if (clone != orig)
     *clone = *orig;
   orig->case_data->ref_cnt++;
 #ifdef DEBUGGING
@@ -103,42 +103,42 @@ case_clone (struct ccase *clone, const struct ccase *orig)
 /* Replaces DST by SRC and nullifies SRC.
    DST and SRC must be initialized cases at entry. */
 void
-case_move (struct ccase *dst, struct ccase *src) 
+case_move (struct ccase *dst, struct ccase *src)
 {
   assert (src->case_data->ref_cnt > 0);
-  
-  if (dst != src) 
+
+  if (dst != src)
     {
       *dst = *src;
-      case_nullify (src); 
+      case_nullify (src);
     }
 }
 
 /* Destroys case C. */
 void
-case_destroy (struct ccase *c) 
+case_destroy (struct ccase *c)
 {
   struct case_data *cd;
-  
+
   cd = c->case_data;
-  if (cd != NULL && --cd->ref_cnt == 0) 
+  if (cd != NULL && --cd->ref_cnt == 0)
     {
       memset (cd->values, 0xcc, sizeof *cd->values * cd->value_cnt);
       cd->value_cnt = 0xdeadbeef;
-      free (cd); 
+      free (cd);
     }
 }
 
 /* Returns the number of union values in C. */
 size_t
-case_get_value_cnt (const struct ccase *c) 
+case_get_value_cnt (const struct ccase *c)
 {
   return c->case_data->value_cnt;
 }
 
 /* Resizes case C to NEW_CNT union values. */
 void
-case_resize (struct ccase *c, size_t new_cnt) 
+case_resize (struct ccase *c, size_t new_cnt)
 {
   size_t old_cnt = case_get_value_cnt (c);
   if (old_cnt != new_cnt)
@@ -154,7 +154,7 @@ case_resize (struct ccase *c, size_t new_cnt)
 
 /* Swaps cases A and B. */
 void
-case_swap (struct ccase *a, struct ccase *b) 
+case_swap (struct ccase *a, struct ccase *b)
 {
   struct case_data *t = a->case_data;
   a->case_data = b->case_data;
@@ -165,16 +165,16 @@ case_swap (struct ccase *a, struct ccase *b)
    values.  Returns true if successful, false if memory
    allocation failed. */
 bool
-case_try_create (struct ccase *c, size_t value_cnt) 
+case_try_create (struct ccase *c, size_t value_cnt)
 {
   c->case_data = malloc (case_size (value_cnt));
-  if (c->case_data != NULL) 
+  if (c->case_data != NULL)
     {
       c->case_data->value_cnt = value_cnt;
       c->case_data->ref_cnt = 1;
       return true;
     }
-  
+
   return false;
 }
 
@@ -182,7 +182,7 @@ case_try_create (struct ccase *c, size_t value_cnt)
    Returns true if successful, false if memory allocation
    failed. */
 bool
-case_try_clone (struct ccase *clone, const struct ccase *orig) 
+case_try_clone (struct ccase *clone, const struct ccase *orig)
 {
   case_clone (clone, orig);
   return true;
@@ -201,12 +201,12 @@ case_copy (struct ccase *dst, size_t dst_idx,
   assert (src->case_data->ref_cnt > 0);
   assert (src_idx + value_cnt <= src->case_data->value_cnt);
 
-  if (dst->case_data != src->case_data || dst_idx != src_idx) 
+  if (dst->case_data != src->case_data || dst_idx != src_idx)
     {
       case_unshare (dst);
       memmove (dst->case_data->values + dst_idx,
                src->case_data->values + src_idx,
-               sizeof *dst->case_data->values * value_cnt); 
+               sizeof *dst->case_data->values * value_cnt);
     }
 }
 
@@ -214,7 +214,7 @@ case_copy (struct ccase *dst, size_t dst_idx,
    the given START_IDX. */
 void
 case_copy_out (const struct ccase *c,
-               size_t start_idx, union value *values, size_t value_cnt) 
+               size_t start_idx, union value *values, size_t value_cnt)
 {
   assert (c->case_data->ref_cnt > 0);
   assert (value_cnt <= c->case_data->value_cnt);
@@ -228,7 +228,7 @@ case_copy_out (const struct ccase *c,
    the given START_IDX. */
 void
 case_copy_in (struct ccase *c,
-              size_t start_idx, const union value *values, size_t value_cnt) 
+              size_t start_idx, const union value *values, size_t value_cnt)
 {
   assert (c->case_data->ref_cnt > 0);
   assert (value_cnt <= c->case_data->value_cnt);
@@ -253,7 +253,7 @@ case_data (const struct ccase *c, const struct variable *v)
    variable V.
    Case C must be drawn from V's dictionary. */
 double
-case_num (const struct ccase *c, const struct variable *v) 
+case_num (const struct ccase *c, const struct variable *v)
 {
   return case_num_idx (c, var_get_case_index (v));
 }
@@ -264,17 +264,17 @@ case_num (const struct ccase *c, const struct variable *v)
    (Note that the value is not null-terminated.)
    The caller must not modify the return value. */
 const char *
-case_str (const struct ccase *c, const struct variable *v) 
+case_str (const struct ccase *c, const struct variable *v)
 {
   return case_str_idx (c, var_get_case_index (v));
 }
 
 /* Returns a pointer to the `union value' used for the
    element of C for variable V.
-   Case C must be drawn from V's dictionary.   
+   Case C must be drawn from V's dictionary.
    The caller is allowed to modify the returned data. */
 union value *
-case_data_rw (struct ccase *c, const struct variable *v) 
+case_data_rw (struct ccase *c, const struct variable *v)
 {
   return case_data_rw_idx (c, var_get_case_index (v));
 }
@@ -283,7 +283,7 @@ case_data_rw (struct ccase *c, const struct variable *v)
    element of C numbered IDX.
    The caller must not modify the returned data. */
 const union value *
-case_data_idx (const struct ccase *c, size_t idx) 
+case_data_idx (const struct ccase *c, size_t idx)
 {
   assert (c->case_data->ref_cnt > 0);
   assert (idx < c->case_data->value_cnt);
@@ -294,7 +294,7 @@ case_data_idx (const struct ccase *c, size_t idx)
 /* Returns the numeric value of the `union value' in C numbered
    IDX. */
 double
-case_num_idx (const struct ccase *c, size_t idx) 
+case_num_idx (const struct ccase *c, size_t idx)
 {
   assert (c->case_data->ref_cnt > 0);
   assert (idx < c->case_data->value_cnt);
@@ -307,7 +307,7 @@ case_num_idx (const struct ccase *c, size_t idx)
    (Note that the value is not null-terminated.)
    The caller must not modify the return value. */
 const char *
-case_str_idx (const struct ccase *c, size_t idx) 
+case_str_idx (const struct ccase *c, size_t idx)
 {
   assert (c->case_data->ref_cnt > 0);
   assert (idx < c->case_data->value_cnt);
@@ -319,7 +319,7 @@ case_str_idx (const struct ccase *c, size_t idx)
    element of C numbered IDX.
    The caller is allowed to modify the returned data. */
 union value *
-case_data_rw_idx (struct ccase *c, size_t idx) 
+case_data_rw_idx (struct ccase *c, size_t idx)
 {
   assert (c->case_data->ref_cnt > 0);
   assert (idx < c->case_data->value_cnt);
@@ -342,26 +342,26 @@ case_compare (const struct ccase *a, const struct ccase *b,
    and returns a strcmp()-type result. */
 int
 case_compare_2dict (const struct ccase *ca, const struct ccase *cb,
-                    const struct variable *const *vap, 
+                    const struct variable *const *vap,
                const struct variable *const *vbp,
-                    size_t var_cnt) 
+                    size_t var_cnt)
 {
-  for (; var_cnt-- > 0; vap++, vbp++) 
+  for (; var_cnt-- > 0; vap++, vbp++)
     {
       const struct variable *va = *vap;
       const struct variable *vb = *vbp;
 
       assert (var_get_width (va) == var_get_width (vb));
-      
-      if (var_get_width (va) == 0) 
+
+      if (var_get_width (va) == 0)
         {
           double af = case_num (ca, va);
           double bf = case_num (cb, vb);
 
-          if (af != bf) 
+          if (af != bf)
             return af > bf ? 1 : -1;
         }
-      else 
+      else
         {
           const char *as = case_str (ca, va);
           const char *bs = case_str (cb, vb);
@@ -380,7 +380,7 @@ case_compare_2dict (const struct ccase *ca, const struct ccase *cb,
    NOTE: This function breaks the case abstraction.  It should
    *not* be used often.  Prefer the other case functions. */
 const union value *
-case_data_all (const struct ccase *c) 
+case_data_all (const struct ccase *c)
 {
   assert (c->case_data->ref_cnt > 0);
 
@@ -393,7 +393,7 @@ case_data_all (const struct ccase *c)
    NOTE: This function breaks the case abstraction.  It should
    *not* be used often.  Prefer the other case functions. */
 union value *
-case_data_all_rw (struct ccase *c) 
+case_data_all_rw (struct ccase *c)
 {
   assert (c->case_data->ref_cnt > 0);