X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdata-io%2Fprint.c;h=cffa3bd49fdd29f480798c311ba796ae791ff1da;hb=5c567ded508b12a43f70c5df4733f6fbf4cc6804;hp=7b795f1ade5c8365e5a4bf68e7cd039c6a9a14c6;hpb=fe8dc2171009e90d2335f159d05f7e6660e24780;p=pspp diff --git a/src/language/data-io/print.c b/src/language/data-io/print.c index 7b795f1ade..cffa3bd49f 100644 --- a/src/language/data-io/print.c +++ b/src/language/data-io/print.c @@ -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 @@ -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. */ @@ -160,6 +161,17 @@ internal_cmd_print (struct lexer *lexer, struct dataset *ds, 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;