Skip to content

Commit

Permalink
Fixed obscure bug affecting import of spss system files under 32bit W…
Browse files Browse the repository at this point in the history
…indows.
  • Loading branch information
melff committed Nov 18, 2017
1 parent c26b3e6 commit 035aedc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pkg/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: memisc
Type: Package
Title: Management of Survey Data and Presentation of Analysis Results
Version: 0.99.14.5
Date: 2017-11-05
Version: 0.99.14.6
Date: 2017-11-18
Author: Martin Elff (with contributions from Christopher N. Lawrence, Dave Atkins, Jason W. Morgan, Achim Zeileis)
Maintainer: Martin Elff <memisc@elff.eu>
Description: An infrastructure for the management of survey data including
Expand Down
6 changes: 5 additions & 1 deletion pkg/inst/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
2017-11-19:
- Fixed obscure bug affecting import of spss system files under 32bit Windows.
This bug was caused by excessive optimisation of for loops by the C compiler.

2017-11-05:
- Made the display of left-hand sides of model equations optional in the
output of `mtable()` by providing an optional argument "show.eqnames"
and a global option "mtable.show.eqnames".

2017-10-31:
- Fixed (internal) `readChunk` method for fixed-format files with SPSS meta data.

Expand Down
2 changes: 1 addition & 1 deletion pkg/man/percentages.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ percentages(obj, \dots)
are computed.}
\item{se}{a logical value; determines whether standard
errors are computed.}
\item{ci}{a logicla value; determines whether confidence
\item{ci}{a logical value; determines whether confidence
intervals are computed. Note that the confidence intervals
are for infinite (or very large) populations.}
\item{ci.level}{a numerical value, the required confidence level of
Expand Down
22 changes: 14 additions & 8 deletions pkg/src/pspp-system-for-R.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,8 @@ int sys_read_case(sys_file *s){
else{
int j,k = s->byte_pos;
for(j = 0; j < s->case_size; j++){
for(;s->bytes[k]==0 && k < 8; k++){ /* Ignore "0" bytes */
// continue;
#ifdef DEBUG
Rprintf("\n0-byte ignored");
#endif
for(; k < 8; k++){ /* Ignore "0" bytes */
if (s->bytes[k]!=0) break;
}
if(k >= 8) /* Read new command bytes */{
read_len = (int)fread(s->bytes,1,8,s->f);
Expand Down Expand Up @@ -166,6 +163,7 @@ int sys_read_case(sys_file *s){
return j;
}
return 0; /* -Wall */
#undef DEBUG
}


Expand Down Expand Up @@ -872,6 +870,7 @@ SEXP read_sysfile_dict_term (SEXP SysFile){
}

SEXP rewind_sysfile(SEXP SysFile){
int ret;
#ifdef DEBUG
Rprintf("\nrewind_sysfile");
#endif
Expand All @@ -880,12 +879,21 @@ SEXP rewind_sysfile(SEXP SysFile){
Rprintf("\ns address: %x",s);
Rprintf("\nFile: %x",s->f);
Rprintf("\nData pos: %d",s->data_pos);
int a;
ret = fseek(s->f,0,SEEK_SET);
a = getc(s->f);
Rprintf("\nRead num at 0: %d",a);
#endif
int ret = fseek(s->f,s->data_pos,SEEK_SET);
ret = fseek(s->f,s->data_pos,SEEK_SET);
#ifdef DEBUG
Rprintf("\ns address: %x",s);
Rprintf("\nFile after rewind: %x",s->f);
Rprintf("\nFile pos: %d",ftell(s->f));
a = getc(s->f);
Rprintf("\nRead num: %d",a);
a = getc(s->f);
Rprintf("\nRead num: %d",a);
ret = fseek(s->f,s->data_pos,SEEK_SET);
#endif
#undef DEBUG
if(ret) error("error in sys_rewind");
Expand Down Expand Up @@ -1044,8 +1052,6 @@ SEXP count_cases_sysfile (SEXP SysFile){
sys_file *s = get_sys_file(SysFile);
#ifdef DEBUG
Rprintf("\ncount_cases_sysfile");
PrintValue(s_types);
PrintValue(s_vars);
#endif
if(s->case_size == 0) error("case size is zero -- why??");
int ncases = 0;
Expand Down

0 comments on commit 035aedc

Please sign in to comment.