Fixed warnings generated by gcc 4.1.2
[pspp-builds.git] / src / data / procedure.c
index 16dcd745929f9962d489fd58f66bcd4110fcfc13..1843852a64f7b635b1a4d08ede407c43c6692e58 100644 (file)
@@ -28,6 +28,7 @@
 #include <data/case-sink.h>
 #include <data/case.h>
 #include <data/casefile.h>
+#include <data/fastfile.h>
 #include <data/dictionary.h>
 #include <data/file-handle-def.h>
 #include <data/procedure.h>
@@ -47,7 +48,7 @@ struct write_case_data
 
     struct ccase trns_case;     /* Case used for transformations. */
     struct ccase sink_case;     /* Case written to sink, if
-                                   compaction is necessary. */
+                                   compacting is necessary. */
     size_t cases_written;       /* Cases output so far. */
   };
 
@@ -168,7 +169,7 @@ multipass_procedure (bool (*proc_func) (const struct casefile *, void *aux),
   struct multipass_aux_data aux_data;
   bool ok;
 
-  aux_data.casefile = casefile_create (dict_get_next_value_idx (default_dict));
+  aux_data.casefile = fastfile_create (dict_get_next_value_idx (default_dict));
   aux_data.proc_func = proc_func;
   aux_data.aux = aux;
 
@@ -219,7 +220,8 @@ internal_procedure (bool (*case_func) (const struct ccase *, void *),
   wc_data.case_func = case_func;
   wc_data.aux = aux;
   create_trns_case (&wc_data.trns_case, default_dict);
-  case_create (&wc_data.sink_case, dict_get_next_value_idx (default_dict));
+  case_create (&wc_data.sink_case,
+               dict_get_compacted_value_cnt (default_dict));
   wc_data.cases_written = 0;
 
   ok = proc_source->class->read (proc_source,
@@ -281,8 +283,8 @@ open_active_file (void)
   if (permanent_dict == NULL)
     permanent_dict = default_dict;
 
-  /* Figure out compaction. */
-  compactor = (dict_needs_compaction (permanent_dict)
+  /* Figure out whether to compact. */
+  compactor = (dict_compacting_would_shrink (permanent_dict)
                ? dict_make_compactor (permanent_dict)
                : NULL);
 
@@ -411,7 +413,7 @@ close_active_file (void)
   /* Dictionary from before TEMPORARY becomes permanent. */
   proc_cancel_temporary_transformations ();
 
-  /* Finish compaction. */
+  /* Finish compacting. */
   if (compactor != NULL) 
     {
       dict_compactor_destroy (compactor);
@@ -458,7 +460,6 @@ lagged_case (int n_before)
 /* Represents auxiliary data for handling SPLIT FILE. */
 struct split_aux_data 
   {
-    size_t case_count;          /* Number of cases so far. */
     struct ccase prev_case;     /* Data in previous case. */
 
     /* Callback functions. */
@@ -498,7 +499,6 @@ procedure_with_splits (void (*begin_func) (const struct ccase *, void *aux),
   struct split_aux_data split_aux;
   bool ok;
 
-  split_aux.case_count = 0;
   case_nullify (&split_aux.prev_case);
   split_aux.begin_func = begin_func;
   split_aux.proc_func = proc_func;
@@ -520,10 +520,10 @@ split_procedure_case_func (const struct ccase *c, void *split_aux_)
   struct split_aux_data *split_aux = split_aux_;
 
   /* Start a new series if needed. */
-  if (split_aux->case_count == 0
+  if (case_is_null (&split_aux->prev_case)
       || !equal_splits (c, &split_aux->prev_case))
     {
-      if (split_aux->case_count > 0 && split_aux->end_func != NULL)
+      if (!case_is_null (&split_aux->prev_case) && split_aux->end_func != NULL)
         split_aux->end_func (split_aux->func_aux);
 
       case_destroy (&split_aux->prev_case);
@@ -533,7 +533,6 @@ split_procedure_case_func (const struct ccase *c, void *split_aux_)
        split_aux->begin_func (&split_aux->prev_case, split_aux->func_aux);
     }
 
-  split_aux->case_count++;
   return (split_aux->proc_func == NULL
           || split_aux->proc_func (c, split_aux->func_aux));
 }
@@ -544,7 +543,7 @@ split_procedure_end_func (void *split_aux_)
 {
   struct split_aux_data *split_aux = split_aux_;
 
-  if (split_aux->case_count > 0 && split_aux->end_func != NULL)
+  if (!case_is_null (&split_aux->prev_case) && split_aux->end_func != NULL)
     split_aux->end_func (split_aux->func_aux);
   return true;
 }
@@ -620,7 +619,7 @@ multipass_split_case_func (const struct ccase *c, void *aux_)
         ok = multipass_split_output (aux);
 
       /* Start a new casefile. */
-      aux->casefile = casefile_create (dict_get_next_value_idx (default_dict));
+      aux->casefile = fastfile_create (dict_get_next_value_idx (default_dict));
     }
 
   return casefile_append (aux->casefile, c) && ok;
@@ -802,6 +801,7 @@ void
 proc_done (void)
 {
   discard_variables ();
+  dict_destroy (default_dict);
 }
 
 /* Sets SINK as the destination for procedure output from the
@@ -875,12 +875,12 @@ add_case_limit_trns (void)
    *CASES_REMAINING. */
 static int
 case_limit_trns_proc (void *cases_remaining_,
-                      struct ccase *c UNUSED, int case_nr UNUSED) 
+                      struct ccase *c UNUSED, casenum_t case_nr UNUSED) 
 {
   size_t *cases_remaining = cases_remaining_;
   if (*cases_remaining > 0) 
     {
-      *cases_remaining--;
+      (*cases_remaining)--;
       return TRNS_CONTINUE;
     }
   else
@@ -914,7 +914,7 @@ add_filter_trns (void)
 /* FILTER transformation. */
 static int
 filter_trns_proc (void *filter_var_,
-                  struct ccase *c UNUSED, int case_nr UNUSED) 
+                  struct ccase *c UNUSED, casenum_t case_nr UNUSED) 
   
 {
   struct variable *filter_var = filter_var_;