[Rd] spss endianness bugfix

Kurt Van Dijck kurt.van.dijck at skynet.be
Thu Jul 17 22:06:03 CEST 2008


Hi,

We just upgraded the MacOSX R with foreign package 0.8.27 with
CRAN to have SPSS long variable names. Script tests/spss.R runs
fine. Thanks for importing the spss long labels patch & having
this available for MacOSX!
The first real-life datafile
does not get loaded with "Unexpected end of file".

The SPSS file was saved on a P4 linux, R running on MacOSX (ppc).
SPSS on MacOSX could read the file. Saving in SPSS there brings the 
same problem when reading on P4 linux. Testing proved that the problem
existed with earlier versions of the foreign package too.

I found the problem in src/sfm-read.c, read_document(). The n_lines
variable does not get byte-swapped.

This patch solves the problem.

Kind regards,
Kurt Van Dijck & Ilse Laurijssen

Index: src/sfm-read.c
===================================================================
--- src/sfm-read.c	(revision 5177)
+++ src/sfm-read.c	(working copy)
@@ -1336,6 +1336,8 @@
 	   h->fn));
 
   assertive_bufread(h, &n_lines, sizeof n_lines, 0);
+  if (ext->reverse_endian)
+    bswap_int32 (&n_lines);
   dict->n_documents = n_lines;
   if (dict->n_documents <= 0)
     lose ((_("%s: Number of document lines (%d) must be greater than 0"),



More information about the R-devel mailing list