Merge commit 'origin/stable'
[pspp-builds.git] / src / language / data-io / combine-files.c
index ccbe7679d15a6331c93c7f4054ac168cae9f3c00..39ecedd133eec1c7aa54475df35ee2b5efb3cde1 100644 (file)
@@ -488,12 +488,32 @@ merge_dictionary (struct dictionary *const m, struct comb_file *f)
   struct dictionary *d = f->dict;
   const char *d_docs, *m_docs;
   int i;
+  const char *file_encoding;
 
   if (dict_get_label (m) == NULL)
     dict_set_label (m, dict_get_label (d));
 
   d_docs = dict_get_documents (d);
   m_docs = dict_get_documents (m);
+
+
+  /* FIXME: If the input files have different encodings, then
+     the result is undefined.
+     The correct thing to do would be to convert to an encoding
+     which can cope with all the input files (eg UTF-8).
+   */
+  file_encoding = dict_get_encoding (f->dict);
+  if ( file_encoding != NULL)
+    {
+      if ( dict_get_encoding (m) == NULL)
+       dict_set_encoding (m, file_encoding);
+      else if ( 0 != strcmp (file_encoding, dict_get_encoding (m)))
+       {
+         msg (MW,
+              _("Combining files with incompatible encodings. String data may not be represented correctly."));
+       }
+    }
+
   if (d_docs != NULL)
     {
       if (m_docs == NULL)