--- ./src/data/por-file-writer.c	2012-02-01 17:31:15.939771417 +0100
+++ ./src/data/por-file-writer.c	2012-02-01 17:47:49.368771559 +0100
@@ -396,7 +396,7 @@
 static void
 write_value_labels (struct pfm_writer *w, const struct dictionary *dict)
 {
+  int i,j;
-  int i;
 
   for (i = 0; i < dict_get_var_cnt (dict); i++)
     {
@@ -415,9 +415,9 @@
 
       n_labels = val_labs_count (val_labs);
       labels = val_labs_sorted (val_labs);
+      for (j = 0; j < n_labels; j++)
-      for (i = 0; i < n_labels; i++)
         {
+          const struct val_lab *vl = labels[j];
-          const struct val_lab *vl = labels[i];
           write_value (w, val_lab_get_value (vl), var_get_width (v));
           write_string (w, val_lab_get_escaped_label (vl));
         }


--- ./src/language/data-io/data-list.c    2012-02-04 04:11:32.000000000 +0100
+++ ./src/language/data-io/data-list.c      2012-02-15 09:23:28.562711080 +0100
@@ -241,9 +241,14 @@
     }
   type = data_parser_get_type (parser);
 
-  if (! ds_is_empty (&encoding) && NULL == fh)
-    msg (MW, _("Encoding should not be specified for inline data. It will be "
-               "ignored."));
+  if (! ds_is_empty (&encoding)) {
+    if (NULL == fh) {
+      msg (MW, _("Encoding should not be specified for inline data. It will be "
+                 "ignored."));
+    } else {
+      fh_set_encoding (fh, encoding.ss.string);
+    }
+  }
 
   if (fh == NULL)
     fh = fh_inline_file ();
@@ -294,7 +299,7 @@
     data_parser_make_active_file (parser, ds, reader, dict);
 
   fh_unref (fh);
-  ds_destroy (&encoding);
+  //ds_destroy (&encoding);
 
   return CMD_SUCCESS;
 
--- ./src/data/file-handle-def.h  2012-02-04 04:11:32.000000000 +0100
+++ ./src/data/file-handle-def.h    2012-02-14 17:48:09.714711277 +0100
@@ -91,6 +91,7 @@
 size_t fh_get_record_width (const struct file_handle *);
 size_t fh_get_tab_width (const struct file_handle *);
 const char *fh_get_legacy_encoding (const struct file_handle *);
+void fh_set_encoding (struct file_handle *, const char *);
 
 /* Properties of FH_REF_DATASET file handles. */
 struct dataset *fh_get_dataset (const struct file_handle *);
--- ./src/data/file-handle-def.c  2012-02-04 04:11:32.000000000 +0100
+++ ./src/data/file-handle-def.c    2012-02-14 17:47:55.050711281 +0100
@@ -339,6 +339,14 @@
   return (handle->referent == FH_REF_FILE ? handle->encoding : C_ENCODING);
 }
 
+/* Sets the encoding of characters read from HANDLE. */
+void 
+fh_set_encoding (struct file_handle *handle, const char *encoding)
+{
+  assert (handle->referent & (FH_REF_FILE | FH_REF_INLINE));
+  handle->encoding = encoding;
+}
+
 /* Returns the dataset handle associated with HANDLE.
    Applicable to only FH_REF_DATASET files. */
 struct dataset *
--- ./src/libpspp/str.c   2012-02-04 04:11:32.000000000 +0100
+++ ./src/libpspp/str.c     2012-02-15 12:35:09.741709465 +0100
@@ -872,7 +872,7 @@
 ds_init_substring (struct string *st, struct substring ss)
 {
   st->capacity = MAX (8, ss.length * 2);
-  st->ss.string = xmalloc (st->capacity + 1);
+  st->ss.string = xzalloc (st->capacity + 1);
   memcpy (st->ss.string, ss.string, ss.length);
   st->ss.length = ss.length;
 }
