work
[pspp] / utilities / pspp-convert.c
index 1bd2e0a78da94d18fabdf4ae0a78232408edd4cc..0f77998044a06f185a30d2f11357a27d22e389df 100644 (file)
@@ -23,6 +23,7 @@
 #include <unistd.h>
 
 #include "data/any-reader.h"
+#include "data/case-map.h"
 #include "data/casereader.h"
 #include "data/casewriter.h"
 #include "data/csv-file-writer.h"
@@ -80,7 +81,7 @@ parse_variables_option (const char *arg, struct dictionary *dict,
   bool ok = parse_variables (lexer, dict, vars, n_vars, 0);
   if (ok && (lex_token (lexer) != T_STOP && lex_token (lexer) != T_ENDCMD))
     {
-      lex_error (lexer, _("expecting variable name"));
+      lex_error (lexer, _("Syntax error expecting variable name."));
       ok = false;
     }
 
@@ -294,6 +295,7 @@ main (int argc, char *argv[])
   if (reader == NULL)
     goto error;
 
+  struct case_map_stage *stage = case_map_stage_create (dict);
   if (keep)
     {
       struct variable **keep_vars;
@@ -302,7 +304,7 @@ main (int argc, char *argv[])
         goto error;
       dict_reorder_vars (dict, keep_vars, n_keep_vars);
       dict_delete_consecutive_vars (dict, n_keep_vars,
-                                    dict_get_var_cnt (dict) - n_keep_vars);
+                                    dict_get_n_vars (dict) - n_keep_vars);
       free (keep_vars);
     }
 
@@ -316,6 +318,9 @@ main (int argc, char *argv[])
       free (drop_vars);
     }
 
+  reader = case_map_create_input_translator (
+    case_map_stage_to_case_map (stage), reader);
+
   if (!strcmp (output_format, "csv") || !strcmp (output_format, "txt"))
     {
       if (!csv_opts.delimiter)