-/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 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 the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <data/case.h>
-#include <data/data-out.h>
-#include <data/procedure.h>
-#include <data/transformations.h>
-#include <data/variable.h>
-#include <language/command.h>
-#include <language/data-io/data-writer.h>
-#include <language/data-io/file-handle.h>
-#include <language/data-io/placement-parser.h>
-#include <language/lexer/format-parser.h>
-#include <language/lexer/lexer.h>
-#include <language/lexer/variable-parser.h>
-#include <libpspp/alloc.h>
-#include <libpspp/assertion.h>
-#include <libpspp/compiler.h>
-#include <libpspp/ll.h>
-#include <libpspp/message.h>
-#include <libpspp/misc.h>
-#include <libpspp/pool.h>
-#include <output/manager.h>
-#include <output/table.h>
+#include "data/case.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"
+#include "language/data-io/data-writer.h"
+#include "language/data-io/file-handle.h"
+#include "language/data-io/placement-parser.h"
+#include "language/lexer/format-parser.h"
+#include "language/lexer/lexer.h"
+#include "language/lexer/variable-parser.h"
+#include "libpspp/assertion.h"
+#include "libpspp/compiler.h"
+#include "libpspp/i18n.h"
+#include "libpspp/ll.h"
+#include "libpspp/message.h"
+#include "libpspp/misc.h"
+#include "libpspp/pool.h"
+#include "output/tab.h"
+#include "output/text-item.h"
+
+#include "gl/xalloc.h"
struct pool *pool; /* Stores related data. */
bool eject; /* Eject page before printing? */
bool include_prefix; /* Prefix lines with space? */
struct pool *pool; /* Stores related data. */
bool eject; /* Eject page before printing? */
bool include_prefix; /* Prefix lines with space? */
struct dfm_writer *writer; /* Output file, NULL=listing file. */
struct ll_list specs; /* List of struct prt_out_specs. */
size_t record_cnt; /* Number of records to write. */
struct dfm_writer *writer; /* Output file, NULL=listing file. */
struct ll_list specs; /* List of struct prt_out_specs. */
size_t record_cnt; /* Number of records to write. */
enum which_formats, bool eject);
static trns_proc_func print_trns_proc;
static trns_free_func print_trns_free;
enum which_formats, bool eject);
static trns_proc_func print_trns_proc;
static trns_free_func print_trns_free;
- lex_match (lexer, '=');
- lex_match (lexer, '(');
+ lex_match (lexer, T_EQUALS);
+ lex_match (lexer, T_LPAREN);
add_transformation (ds, print_trns_proc, print_trns_free, trns);
pool_destroy (tmp_pool);
add_transformation (ds, print_trns_proc, print_trns_free, trns);
pool_destroy (tmp_pool);
return CMD_FAILURE;
}
\f
static bool parse_string_argument (struct lexer *, struct print_trns *,
int record, int *column);
return CMD_FAILURE;
}
\f
static bool parse_string_argument (struct lexer *, struct print_trns *,
int record, int *column);
Returns success. */
static bool
parse_specs (struct lexer *lexer, struct pool *tmp_pool, struct print_trns *trns,
Returns success. */
static bool
parse_specs (struct lexer *lexer, struct pool *tmp_pool, struct print_trns *trns,
ok = parse_string_argument (lexer, trns, record, &column);
else
ok = parse_variable_argument (lexer, dict, trns, tmp_pool, &record, &column,
ok = parse_string_argument (lexer, trns, record, &column);
else
ok = parse_variable_argument (lexer, dict, trns, tmp_pool, &record, &column,
- if (!parse_column_range (lexer, &first_column, &last_column, &range_specified))
- return false;
+ if (!parse_column_range (lexer, 1,
+ &first_column, &last_column, &range_specified))
+ return false;
-
- if (!parse_variables_const_pool (lexer, tmp_pool, dict,
+
+ if (!parse_variables_const_pool (lexer, tmp_pool, dict,
{
if (!parse_var_placements (lexer, tmp_pool, var_cnt, false,
&formats, &format_cnt))
{
if (!parse_var_placements (lexer, tmp_pool, var_cnt, false,
&formats, &format_cnt))
/* This is a completely bizarre twist for compatibility:
WRITE outputs the system-missing value as a field
filled with spaces, instead of using the normal format
/* This is a completely bizarre twist for compatibility:
WRITE outputs the system-missing value as a field
filled with spaces, instead of using the normal format
- t = tab_create (4, spec_cnt + 1, 0);
- tab_columns (t, TAB_COL_DOWN, 1);
+ t = tab_create (4, spec_cnt + 1);
tab_box (t, TAL_1, TAL_1, TAL_0, TAL_1, 0, 0, 3, spec_cnt);
tab_hline (t, TAL_2, 0, 3, 1);
tab_headers (t, 0, 0, 1, 0);
tab_box (t, TAL_1, TAL_1, TAL_0, TAL_1, 0, 0, 3, spec_cnt);
tab_hline (t, TAL_2, 0, 3, 1);
tab_headers (t, 0, 0, 1, 0);
tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Record"));
tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Columns"));
tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Format"));
tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Record"));
tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Columns"));
tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Format"));
- ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
+ ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
- tab_text (t, 0, row, TAB_LEFT | TAB_FIX | TAT_PRINTF, "\"%.*s\"",
- (int) ds_length (&spec->string), ds_data (&spec->string));
+ tab_text_format (t, 0, row, TAB_LEFT | TAB_FIX, "`%.*s'",
+ (int) ds_length (&spec->string),
+ ds_data (&spec->string));
- tab_text (t, 1, row, TAT_PRINTF, "%d", spec->record);
- tab_text (t, 2, row, TAT_PRINTF, "%3d-%3d",
- spec->first_column, spec->first_column + width - 1);
+ tab_text_format (t, 1, row, 0, "%d", spec->record);
+ tab_text_format (t, 2, row, 0, "%3d-%3d",
+ spec->first_column, spec->first_column + width - 1);
- tab_title (t, ngettext ("Writing %d record to %s.",
- "Writing %d records to %s.", trns->record_cnt),
+ tab_title (t, ngettext ("Writing %zu record to %s.",
+ "Writing %zu records to %s.", trns->record_cnt),
- tab_title (t, ngettext ("Writing %d record.",
- "Writing %d records.", trns->record_cnt),
+ tab_title (t, ngettext ("Writing %zu record.",
+ "Writing %zu records.", trns->record_cnt),
- ds_put_char (&trns->line, ' ');
- ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
+ ds_put_byte (&trns->line, ' ');
+ ll_for_each (spec, struct prt_out_spec, ll, &trns->specs)
{
flush_records (trns, spec->record, &eject, &record);
{
flush_records (trns, spec->record, &eject, &record);
- const union value *input = case_data (c, spec->var);
- char *output = ds_put_uninit (&trns->line, spec->format.w);
+ const union value *input = case_data (*c, spec->var);
- data_out (input, &spec->format, output);
+ data_out_recode (input, var_get_encoding (spec->var),
+ &spec->format, &trns->line, trns->encoding);
- ds_put_char (&trns->line, ' ');
+ ds_put_byte (&trns->line, encoded_space);
+ }
+ else
+ {
+ ds_put_substring (&trns->line, ds_ss (&spec->string));
+ if (0 != strcmp (trns->encoding, C_ENCODING))
+ {
+ size_t length = ds_length (&spec->string);
+ char *data = ss_data (ds_tail (&trns->line, length));
+ char *s = recode_string (trns->encoding, C_ENCODING, data, length);
+ memcpy (data, s, length);
+ free (s);
+ }
}
flush_records (trns, trns->record_cnt + 1, &eject, &record);
}
flush_records (trns, trns->record_cnt + 1, &eject, &record);
flush_records (struct print_trns *trns, int target_record,
bool *eject, int *record)
{
flush_records (struct print_trns *trns, int target_record,
bool *eject, int *record)
{