sys-file-reader: Improve diagnostics for unexpected special values.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 3 Aug 2013 18:59:07 +0000 (11:59 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 3 Aug 2013 22:12:30 +0000 (15:12 -0700)
SPSS 21 schanged the value that it reports for "lowest" in the machine
float info record, but the existing diagnostics made it hard to tell
exactly what changed.  Adding hexadecimal float output makes it obvious.

src/data/sys-file-reader.c
tests/data/sys-file-reader.at
utilities/pspp-dump-sav.c

index 35f40d3dbc4755f3365b8549fd2966f121f1f259..c9d49129732062db02de437568f42cd27fdb0cfc 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-2000, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-2000, 2006-2007, 2009-2013 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
@@ -1258,16 +1258,22 @@ parse_machine_float_info (struct sfm_reader *r,
   double lowest = parse_float (r, record->data, 16);
 
   if (sysmis != SYSMIS)
-    sys_warn (r, record->pos, _("File specifies unexpected value %g as %s."),
-              sysmis, "SYSMIS");
+    sys_warn (r, record->pos,
+              _("File specifies unexpected value %g (%a) as %s, "
+                "instead of %g (%a)."),
+              sysmis, sysmis, "SYSMIS", SYSMIS, SYSMIS);
 
   if (highest != HIGHEST)
-    sys_warn (r, record->pos, _("File specifies unexpected value %g as %s."),
-              highest, "HIGHEST");
+    sys_warn (r, record->pos,
+              _("File specifies unexpected value %g (%a) as %s, "
+                "instead of %g (%a)."),
+              highest, highest, "HIGHEST", HIGHEST, HIGHEST);
 
   if (lowest != LOWEST)
-    sys_warn (r, record->pos, _("File specifies unexpected value %g as %s."),
-              lowest, "LOWEST");
+    sys_warn (r, record->pos,
+              _("File specifies unexpected value %g (%a) as %s, "
+                "instead of %g (%a)."),
+              lowest, lowest, "LOWEST", LOWEST, LOWEST);
 }
 
 /* Parses record type 7, subtype 7 or 19. */
index c5699b136a282045c1a70314fe32447e4943e4ea..35281f22e3e5d911afa8ae29315662402c48edfa 100644 (file)
@@ -2044,12 +2044,12 @@ do
 ])
   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
 ])
-  AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
-warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 0 as SYSMIS.
+  AT_CHECK([pspp -O format=csv sys-file.sps | sed 's/ [(].*/.../'], [0], [dnl
+"warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 0...
 
-warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 1 as HIGHEST.
+"warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 1...
 
-warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 2 as LOWEST.
+"warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 2...
 ])
 done
 AT_CLEANUP
index 98cb6f3b22ed7ae6673081365fce531c52984069..a6ed8d15674eef3fb033ce9af2dba749bf7fcbba 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 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
@@ -663,20 +663,20 @@ read_machine_float_info (struct sfm_reader *r, size_t size, size_t count)
     sys_error (r, "Bad size (%zu) or count (%zu) on extension 4.",
                size, count);
 
-  printf ("\tsysmis: %g\n", sysmis);
+  printf ("\tsysmis: %g (%a)\n", sysmis, sysmis);
   if (sysmis != SYSMIS)
-    sys_warn (r, "File specifies unexpected value %g as %s.",
-              sysmis, "SYSMIS");
+    sys_warn (r, "File specifies unexpected value %g (%a) as %s.",
+              sysmis, sysmis, "SYSMIS");
 
-  printf ("\thighest: %g\n", highest);
+  printf ("\thighest: %g (%a)\n", highest, highest);
   if (highest != HIGHEST)
-    sys_warn (r, "File specifies unexpected value %g as %s.",
-              highest, "HIGHEST");
+    sys_warn (r, "File specifies unexpected value %g (%a) as %s.",
+              highest, highest, "HIGHEST");
 
-  printf ("\tlowest: %g\n", lowest);
-  if (lowest != LOWEST)
-    sys_warn (r, "File specifies unexpected value %g as %s.",
-              lowest, "LOWEST");
+  printf ("\tlowest: %g (%a)\n", lowest, lowest);
+  if (lowest != LOWEST && lowest != SYSMIS)
+    sys_warn (r, "File specifies unexpected value %g (%a) as %s.",
+              lowest, lowest, "LOWEST");
 }
 
 /* Read record type 7, subtype 7. */