From f4fdc32a242f73c4b579457650c7430ae2fd5489 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 3 Aug 2013 11:59:07 -0700 Subject: [PATCH] sys-file-reader: Improve diagnostics for unexpected special values. 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 | 20 +++++++++++++------- tests/data/sys-file-reader.at | 8 ++++---- utilities/pspp-dump-sav.c | 22 +++++++++++----------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 35f40d3dbc..c9d4912973 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -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. */ diff --git a/tests/data/sys-file-reader.at b/tests/data/sys-file-reader.at index c5699b136a..35281f22e3 100644 --- a/tests/data/sys-file-reader.at +++ b/tests/data/sys-file-reader.at @@ -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 diff --git a/utilities/pspp-dump-sav.c b/utilities/pspp-dump-sav.c index 98cb6f3b22..a6ed8d1567 100644 --- a/utilities/pspp-dump-sav.c +++ b/utilities/pspp-dump-sav.c @@ -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. */ -- 2.30.2