work on data list
[pspp] / src / language / data-io / print.c
index c52a59cf521fb1cdacef984392bf8be90f2e11a3..cffa3bd49fdd29f480798c311ba796ae791ff1da 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -19,9 +19,9 @@
 #include <stdlib.h>
 
 #include "data/case.h"
+#include "data/dataset.h"
 #include "data/data-out.h"
 #include "data/format.h"
-#include "data/procedure.h"
 #include "data/transformations.h"
 #include "data/variable.h"
 #include "language/command.h"
@@ -136,6 +136,7 @@ internal_cmd_print (struct lexer *lexer, struct dataset *ds,
   bool print_table = 0;
   struct print_trns *trns;
   struct file_handle *fh = NULL;
+  char *encoding = NULL;
   struct pool *tmp_pool;
 
   /* Fill in prt to facilitate error-handling. */
@@ -156,10 +157,21 @@ internal_cmd_print (struct lexer *lexer, struct dataset *ds,
        {
          lex_match (lexer, T_EQUALS);
 
-         fh = fh_parse (lexer, FH_REF_FILE);
+         fh = fh_parse (lexer, FH_REF_FILE, NULL);
          if (fh == NULL)
            goto error;
        }
+      else if (lex_match_id (lexer, "ENCODING"))
+       {
+         lex_match (lexer, T_EQUALS);
+         if (!lex_force_string (lexer))
+           goto error;
+
+          free (encoding);
+          encoding = ss_xstrdup (lex_tokss (lexer));
+
+         lex_get (lexer);
+       }
       else if (lex_match_id (lexer, "RECORDS"))
        {
          lex_match (lexer, T_EQUALS);
@@ -194,10 +206,10 @@ internal_cmd_print (struct lexer *lexer, struct dataset *ds,
 
   if (fh != NULL)
     {
-      trns->writer = dfm_open_writer (fh);
+      trns->writer = dfm_open_writer (fh, encoding);
       if (trns->writer == NULL)
         goto error;
-      trns->encoding = dfm_writer_get_legacy_encoding (trns->writer);
+      trns->encoding = dfm_writer_get_encoding (trns->writer);
     }
   else
     trns->encoding = UTF8;
@@ -325,7 +337,7 @@ parse_variable_argument (struct lexer *lexer, const struct dictionary *dict,
 
   if (lex_is_number (lexer) || lex_token (lexer) == T_LPAREN)
     {
-      if (!parse_var_placements (lexer, tmp_pool, var_cnt, false,
+      if (!parse_var_placements (lexer, tmp_pool, var_cnt, FMT_FOR_OUTPUT,
                                  &formats, &format_cnt))
         return false;
       add_space = false;