Document and implement "precision record" in portable file format. 20130117030512/pspp 20130118030503/pspp 20130119030502/pspp 20130120030506/pspp
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 17 Jan 2013 07:32:26 +0000 (23:32 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 17 Jan 2013 07:33:54 +0000 (23:33 -0800)
doc/dev/portable-file-format.texi
src/data/por-file-reader.c
src/data/por-file-writer.c

index 31c1ac3a5a65295beb60a3b4430269859e4584ab..d5f27610304ebac6948d99634ecbeaf4e2e5fa1f 100644 (file)
@@ -18,6 +18,7 @@ for portable files formatted in EBCDIC or other character sets.
 * Version and Date Info Record::
 * Identification Records::
 * Variable Count Record::
+* Precision Record::
 * Case Weight Variable Record::
 * Variable Records::
 * Value Label Records::
@@ -350,10 +351,16 @@ additional information on the product that wrote the portable file.
 @node Variable Count Record
 @section Variable Count Record
 
-The variable count record has tag code @samp{4}.  It consists of two
-integer fields.  The first contains the number of variables in the file
-dictionary.  The purpose of the second is unknown; it contains the value
-161 in all portable files examined so far.
+The variable count record has tag code @samp{4}.  It consists of a
+single integer field giving the number of variables in the file
+dictionary.
+
+@node Precision Record
+@section Precision Record
+
+The precision record has tag code @samp{5}.  It consists of a single
+integer field specifying the maximum number of base-30 digits used in
+data in the file.
 
 @node Case Weight Variable Record
 @section Case Weight Variable Record
index e2c06b8be9eab9f108e03615c831e430c605a419..a4d13ec7bc4b927c88cac19a3d9920db08da7ece 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 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
@@ -657,8 +657,8 @@ read_variables (struct pfm_reader *r, struct dictionary *dict)
   if (r->var_cnt <= 0)
     error (r, _("Invalid number of variables %d."), r->var_cnt);
 
-  /* Purpose of this value is unknown.  It is typically 161. */
-  read_int (r);
+  if (match (r, '5'))
+    read_int (r);
 
   if (match (r, '6'))
     {
index 39c763113aad1343d448ab06566857b9d0edcaec..1cd6c6ed7a085eb83c1035c5eb8ecf9c819895d8 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 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
@@ -336,7 +336,9 @@ write_variables (struct pfm_writer *w, struct dictionary *dict)
   
   buf_write (w, "4", 1);
   write_int (w, dict_get_var_cnt (dict));
-  write_int (w, 161);
+
+  buf_write (w, "5", 1);
+  write_int (w, ceil (w->digits * (log (10) / log (30))));
 
   for (i = 0; i < dict_get_var_cnt (dict); i++)
     {