From: Ben Pfaff Date: Thu, 17 Jan 2013 07:32:26 +0000 (-0800) Subject: Document and implement "precision record" in portable file format. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e6da3d9bf62cd8d9be435d28ddc9d8ef6868268;p=pspp Document and implement "precision record" in portable file format. --- diff --git a/doc/dev/portable-file-format.texi b/doc/dev/portable-file-format.texi index 31c1ac3a5a..d5f2761030 100644 --- a/doc/dev/portable-file-format.texi +++ b/doc/dev/portable-file-format.texi @@ -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 diff --git a/src/data/por-file-reader.c b/src/data/por-file-reader.c index e2c06b8be9..a4d13ec7bc 100644 --- a/src/data/por-file-reader.c +++ b/src/data/por-file-reader.c @@ -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')) { diff --git a/src/data/por-file-writer.c b/src/data/por-file-writer.c index 39c763113a..1cd6c6ed7a 100644 --- a/src/data/por-file-writer.c +++ b/src/data/por-file-writer.c @@ -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++) {