/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007, 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
#include "libpspp/message.h"
#include "libpspp/misc.h"
#include "libpspp/str.h"
+#include "libpspp/string-array.h"
#include "libpspp/version.h"
#include "gl/xmemdup0.h"
idx += sfm_width_to_octs (var_get_width (v));
}
- if (dict_get_documents (d) != NULL)
+ if (dict_get_document_line_cnt (d) > 0)
write_documents (w, d);
write_integer_info_record (w);
for (i = 0; i < n_labels; i++)
{
const struct val_lab *vl = labels[i];
- char *label = recode_string (var_get_encoding (v), UTF8, val_lab_get_label (vl), -1);
+ char *label = recode_string (var_get_encoding (v), UTF8,
+ val_lab_get_escaped_label (vl), -1);
uint8_t len = MIN (strlen (label), 255);
write_value (w, val_lab_get_value (vl), var_get_width (v));
static void
write_documents (struct sfm_writer *w, const struct dictionary *d)
{
- size_t line_cnt = dict_get_document_line_cnt (d);
+ const struct string_array *docs = dict_get_documents (d);
+ const char *enc = dict_get_encoding (d);
+ size_t i;
write_int (w, 6); /* Record type. */
- write_int (w, line_cnt);
- write_bytes (w, dict_get_documents (d), line_cnt * DOC_LINE_LENGTH);
+ write_int (w, docs->n);
+ for (i = 0; i < docs->n; i++)
+ {
+ char *s = recode_string (enc, "UTF-8", docs->strings[i], -1);
+ size_t s_len = strlen (s);
+ size_t write_len = MIN (s_len, DOC_LINE_LENGTH);
+
+ write_bytes (w, s, write_len);
+ write_spaces (w, DOC_LINE_LENGTH - write_len);
+ free (s);
+ }
}
static void
ds_put_format (&s, " %s", var_get_short_name (mrset->vars[j], 0));
ds_put_byte (&s, '\n');
}
- write_attribute_record (w, &s, 7);
+ write_attribute_record (w, &s, pre_v14 ? 7 : 19);
ds_destroy (&s);
}
size += 12 + strlen (var_get_name (var));
for (val_lab = val_labs_first (val_labs); val_lab != NULL;
val_lab = val_labs_next (val_labs, val_lab))
- size += 8 + width + strlen (val_lab_get_label (val_lab));
+ size += 8 + width + strlen (val_lab_get_escaped_label (val_lab));
}
if (size == 0)
return;
for (val_lab = val_labs_first (val_labs); val_lab != NULL;
val_lab = val_labs_next (val_labs, val_lab))
{
- const char *label = val_lab_get_label (val_lab);
+ const char *label = val_lab_get_escaped_label (val_lab);
size_t label_length = strlen (label);
write_int (w, width);