From: John Darrington Date: Sun, 29 Mar 2009 05:19:59 +0000 (+0800) Subject: Write encoding to system files. X-Git-Tag: sav-api~694 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04392b01071b71ae1b37bb67346c9878d4824da6;p=pspp Write encoding to system files. Write the encoding to record 7(20) when saving. --- diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index 393be4e126..292ec9c5d0 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -103,6 +103,9 @@ static void write_float_info_record (struct sfm_writer *); 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); @@ -246,6 +249,8 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d, 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); @@ -660,6 +665,24 @@ write_vls_length_table (struct sfm_writer *w, 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) @@ -1019,7 +1042,7 @@ write_value (struct sfm_writer *w, const union value *value, int width) } /* 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)