Merge commit 'origin/stable' fc11-i386-build58 fc11-x64-build55 lenny-x64-build79 sid-i386-build125
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 16 Dec 2009 20:09:55 +0000 (21:09 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 16 Dec 2009 20:09:55 +0000 (21:09 +0100)
Conflicts:

NEWS
configure.ac
po/nl.po
src/ui/gui/dict-display.c

NEWS
doc/dev/system-file-format.texi
src/data/sys-file-reader.c

diff --git a/NEWS b/NEWS
index 1aac688c8736a3b66322cf993fbc0f195ee9920f..149d1deadbad2b44269d9a6b787ac9ed9ed10c80 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,5 @@
 PSPP NEWS -- history of user-visible changes.
-Time-stamp: <2009-09-08 21:08:29 blp>
+Time-stamp: <2009-10-06 20:46:21 blp>
 Copyright (C) 1996-9, 2000, 2008, 2009 Free Software Foundation, Inc.
 See the end for copying conditions.
 
@@ -54,8 +54,7 @@ Changes from 0.6.2-pre6 to 0.7.0:
 
   * A tutorial chapter has been added to the user manual.
 
-
-Changes from 0.6.1 to 0.6.2-pre6:
+Changes from 0.6.1 to 0.6.2
 
   * New translations:
 
@@ -77,6 +76,8 @@ Changes from 0.6.1 to 0.6.2-pre6:
 
   * Build fixes and changes:
 
+    - Fix build with GTK+ 2.17.4 and later.
+
     - Make running "make" after running "configure" with different
       settings reliably rebuild version.c.
 
@@ -100,6 +101,9 @@ Changes from 0.6.1 to 0.6.2-pre6:
 
     - Fix writing corrupted .sav files on Windows.
 
+    - Fix writing variable labels longer than 252 bytes to save files.
+      Thanks to Robert Westlund for reporting this bug.
+
     - Fix writing corrupted .por files (bug #26034).
 
     - Fix reading .por files whose initial lines are not padded out
index a404d0d6ce3961eed3ca1ec134a2ff9f6140adac..c1d1e42129a02c5e7fb7dfbf9f6daa528c2550dc 100644 (file)
@@ -1093,6 +1093,9 @@ value @var{code} - @var{bias}, where
 variable @code{bias} from the file header.  For example,
 code 105 with bias 100.0 (the normal value) indicates a numeric variable
 of value 5.
+One file has been seen written by SPSS 14 that contained such a code
+in a @emph{string} field with the value 0 (after the bias is
+subtracted) as a way of encoding null bytes.
 
 @item 252
 End of file.  This code may or may not appear at the end of the data
index b024e4f0ef81532d51f7024a9b2ea352efba84f6..f63a122fe83b96776b632cef57b51e49c83c4bd1 100644 (file)
@@ -88,6 +88,7 @@ struct sfm_reader
     double bias;               /* Compression bias, usually 100.0. */
     uint8_t opcodes[8];         /* Current block of opcodes. */
     size_t opcode_idx;          /* Next opcode to interpret, 8 if none left. */
+    bool corruption_warning;    /* Warned about possible corruption? */
   };
 
 static const struct casereader_class sys_file_casereader_class;
@@ -270,6 +271,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict,
   r->oct_cnt = 0;
   r->has_long_var_names = false;
   r->opcode_idx = sizeof r->opcodes;
+  r->corruption_warning = false;
 
   /* TRANSLATORS: this fragment will be interpolated into
      messages in fh_lock() that identify types of files. */
@@ -1710,7 +1712,14 @@ read_compressed_number (struct sfm_reader *r, double *d)
       break;
 
     case 254:
-      sys_error (r, _("Compressed data is corrupt."));
+      float_convert (r->float_format, "        ", FLOAT_NATIVE_DOUBLE, d);
+      if (!r->corruption_warning)
+        {
+          r->corruption_warning = true;
+          sys_warn (r, _("Possible compressed data corruption: "
+                         "compressed spaces appear in numeric field."));
+        }
+      break;
 
     case 255:
       *d = SYSMIS;
@@ -1731,7 +1740,8 @@ read_compressed_number (struct sfm_reader *r, double *d)
 static bool
 read_compressed_string (struct sfm_reader *r, uint8_t *dst)
 {
-  switch (read_opcode (r))
+  int opcode = read_opcode (r);
+  switch (opcode)
     {
     case -1:
     case 252:
@@ -1746,7 +1756,25 @@ read_compressed_string (struct sfm_reader *r, uint8_t *dst)
       break;
 
     default:
-      sys_error (r, _("Compressed data is corrupt."));
+      {
+        double value = opcode - r->bias;
+        float_convert (FLOAT_NATIVE_DOUBLE, &value, r->float_format, dst);
+        if (value == 0.0)
+          {
+            /* This has actually been seen "in the wild".  The submitter of the
+               file that showed that the contents decoded as spaces, but they
+               were at the end of the field so it's possible that the null
+               bytes just acted as null terminators. */
+          }
+        else if (!r->corruption_warning)
+          {
+            r->corruption_warning = true;
+            sys_warn (r, _("Possible compressed data corruption: "
+                           "string contains compressed integer (opcode %d)"),
+                      opcode);
+          }
+      }
+      break;
     }
 
   return true;