Adopt use of gnulib for portability.
[pspp-builds.git] / src / vfm.c
index 344f94b9a80224625fdfed08e9ed84fcb7dc9645..0414234c01d2be666208fb4c7db1e67c5b315974 100644 (file)
--- a/src/vfm.c
+++ b/src/vfm.c
@@ -14,8 +14,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA. */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
 
 #include <config.h>
 #include "vfm.h"
@@ -42,6 +42,9 @@
 #include "var.h"
 #include "value-labels.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
 /*
    Virtual File Manager (vfm):
 
@@ -259,7 +262,8 @@ write_case (struct write_case_data *wc_data)
     {
       if (compaction_necessary) 
         {
-          dict_compact_case (temp_dict, &wc_data->sink_case, &wc_data->trns_case);
+          dict_compact_case (temp_dict, &wc_data->sink_case,
+                             &wc_data->trns_case);
           vfm_sink->class->write (vfm_sink, &wc_data->sink_case);
         }
       else
@@ -405,11 +409,8 @@ close_active_file (void)
     dict_compact_values (default_dict);
     
   /* Free data source. */
-  if (vfm_source != NULL) 
-    {
-      free_case_source (vfm_source);
-      vfm_source = NULL;
-    }
+  free_case_source (vfm_source);
+  vfm_source = NULL;
 
   /* Old data sink becomes new data source. */
   if (vfm_sink->class->make_source != NULL)
@@ -584,7 +585,9 @@ const struct case_sink_class null_sink_class =
 struct ccase *
 lagged_case (int n_before)
 {
-  assert (n_before >= 1 && n_before <= n_lag);
+  assert (n_before >= 1 );
+  assert (n_before <= n_lag);
+
   if (n_before <= lag_count)
     {
       int index = lag_head - n_before;
@@ -624,7 +627,7 @@ cancel_transformations (void)
     }
   n_trns = f_trns = 0;
   free (t_trns);
-  t_trns=NULL;
+  t_trns = NULL;
   m_trns = 0;
 }
 \f
@@ -782,32 +785,9 @@ procedure_with_splits_callback (struct ccase *c, void *split_aux_)
 static int
 equal_splits (const struct ccase *a, const struct ccase *b) 
 {
-  struct variable *const *split;
-  size_t split_cnt;
-  size_t i;
-    
-  split = dict_get_split_vars (default_dict);
-  split_cnt = dict_get_split_cnt (default_dict);
-  for (i = 0; i < split_cnt; i++)
-    {
-      struct variable *v = split[i];
-      
-      switch (v->type)
-       {
-       case NUMERIC:
-         if (case_num (a, v->fv) != case_num (b, v->fv))
-            return 0;
-         break;
-       case ALPHA:
-         if (memcmp (case_str (a, v->fv), case_str (b, v->fv), v->width))
-            return 0;
-         break;
-       default:
-         assert (0);
-       }
-    }
-
-  return 1;
+  return case_compare (a, b,
+                       dict_get_split_vars (default_dict),
+                       dict_get_split_cnt (default_dict)) == 0;
 }
 
 /* Dumps out the values of all the split variables for the case C. */