/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007, 2009 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
static void write_longvar_table (struct sfm_writer *w,
const struct dictionary *dict);
+static void write_encoding_record (struct sfm_writer *w,
+ const struct dictionary *);
+
static void write_vls_length_table (struct sfm_writer *w,
const struct dictionary *dict);
static void write_spaces (struct sfm_writer *, size_t);
static void write_value (struct sfm_writer *, const union value *, int width);
-static void write_case_uncompressed (struct sfm_writer *, struct ccase *);
-static void write_case_compressed (struct sfm_writer *, struct ccase *);
+static void write_case_uncompressed (struct sfm_writer *,
+ const struct ccase *);
+static void write_case_compressed (struct sfm_writer *, const struct ccase *);
static void flush_compressed (struct sfm_writer *);
static void put_cmp_opcode (struct sfm_writer *, uint8_t);
static void put_cmp_number (struct sfm_writer *, double);
write_data_file_attributes (w, d);
write_variable_attributes (w, d);
+ write_encoding_record (w, d);
+
/* Write end-of-headers record. */
write_int (w, 999);
write_int (w, 0);
ds_destroy (&map);
}
+
+static void
+write_encoding_record (struct sfm_writer *w,
+ const struct dictionary *d)
+{
+ const char *enc = dict_get_encoding (d);
+
+ if ( NULL == enc)
+ return;
+
+ write_int (w, 7); /* Record type. */
+ write_int (w, 20); /* Record subtype. */
+ write_int (w, 1); /* Data item (char) size. */
+ write_int (w, strlen (enc)); /* Number of data items. */
+ write_string (w, enc, strlen (enc));
+}
+
+
/* Writes the long variable name table. */
static void
write_longvar_table (struct sfm_writer *w, const struct dictionary *dict)
if (ferror (w->file))
{
casewriter_force_error (writer);
- case_destroy (c);
+ case_unref (c);
return;
}
else
write_case_compressed (w, c);
- case_destroy (c);
+ case_unref (c);
}
/* Destroys system file writer W. */
\f
/* Writes case C to system file W, without compressing it. */
static void
-write_case_uncompressed (struct sfm_writer *w, struct ccase *c)
+write_case_uncompressed (struct sfm_writer *w, const struct ccase *c)
{
size_t i;
/* Writes case C to system file W, with compression. */
static void
-write_case_compressed (struct sfm_writer *w, struct ccase *c)
+write_case_compressed (struct sfm_writer *w, const struct ccase *c)
{
size_t i;
}
/* Writes null-terminated STRING in a field of the given WIDTH to
- W. If WIDTH is longer than WIDTH, it is truncated; if WIDTH
+ W. If STRING is longer than WIDTH, it is truncated; if WIDTH
is narrowed, it is padded on the right with spaces. */
static void
write_string (struct sfm_writer *w, const char *string, size_t width)