[R-gregmisc-users] SF.net SVN: r-gregmisc: [1223] trunk/SASxport/src
Brought to you by:
warnes
From: <wa...@us...> - 2007-11-07 18:14:59
|
Revision: 1223 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1223&view=rev Author: warnes Date: 2007-11-07 10:14:58 -0800 (Wed, 07 Nov 2007) Log Message: ----------- Apply patches to fix problems on 64 bit platforms, as sumitted by Brian Ripley, and to replace assert() calls with calls a macro that maps to error() unless standalone testing is being done, in which case assert() is used. Modified Paths: -------------- trunk/SASxport/src/ibm2ieee.c trunk/SASxport/src/reverse.c trunk/SASxport/src/writeSAS.c trunk/SASxport/src/writeSAS.h Modified: trunk/SASxport/src/ibm2ieee.c =================================================================== --- trunk/SASxport/src/ibm2ieee.c 2007-11-06 16:24:50 UTC (rev 1222) +++ trunk/SASxport/src/ibm2ieee.c 2007-11-07 18:14:58 UTC (rev 1223) @@ -73,7 +73,7 @@ */ register int i; for( i=count-1; i >= 0; i-- ) { - register unsigned long left, right, signbit; + register unsigned left, right, signbit; register int exp; left = (in[0]<<24) | (in[1]<<16) | (in[2]<<8) | in[3]; Modified: trunk/SASxport/src/reverse.c =================================================================== --- trunk/SASxport/src/reverse.c 2007-11-06 16:24:50 UTC (rev 1222) +++ trunk/SASxport/src/reverse.c 2007-11-07 18:14:58 UTC (rev 1223) @@ -1,4 +1,4 @@ -//#include "writeSAS.h" +#include "writeSAS.h" #include <stdio.h> #include <string.h> @@ -34,7 +34,6 @@ return; } - /* test code */ void test_reverse() { @@ -54,28 +53,25 @@ /* byte */ reverse( &byte_value, sizeof(unsigned char) ); - assert( (unsigned char) *byte_pattern == byte_value ); + ASSERT( (unsigned char) *byte_pattern == byte_value ); /* short */ reverse( (unsigned char*) &short_value, sizeof(short) ); - assert( *((short *) short_pattern) == short_value ); + ASSERT( *((short *) short_pattern) == short_value ); /* int */ reverse( (unsigned char*) &int_value, sizeof(int) ); - assert( *((int *) int_pattern) == int_value ); + ASSERT( *((int *) int_pattern) == int_value ); /* long */ reverse( (unsigned char*) &long_value, sizeof(long) ); - assert( *((long*) long_pattern) == long_value ); + ASSERT( *((long*) long_pattern) == long_value ); } - #ifdef DO_TEST int main(int argc, char *argv) { test_reverse(); } - - #endif Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2007-11-06 16:24:50 UTC (rev 1222) +++ trunk/SASxport/src/writeSAS.c 2007-11-07 18:14:58 UTC (rev 1223) @@ -250,14 +250,14 @@ blankCopy(namestr_record.niform, 8, niform[0]); /* NAME OF INPUT FORMAT */ namestr_record.nifl = (short) *nifl; /* INFORMAT LENGTH ATTRIBUTE */ namestr_record.nifd = (short) *nifd; /* INFORMAT NUMBER OF DECIMALS */ - namestr_record.npos = (long) *npos; /* POSITION OF VALUE IN OBSERVATION */ + namestr_record.npos = (int) *npos; /* POSITION OF VALUE IN OBSERVATION */ zeroFill(namestr_record.rest, 52); /* remaining fields are irrelevant */ /* Flip byte order if necessary */ #define SHORTREV(a) REVERSE( &a, sizeof(short) ) -#define LONGREV(a) REVERSE( &a, sizeof(long) ) +#define INTREV(a) REVERSE( &a, sizeof(int) ) SHORTREV( namestr_record.ntype ); SHORTREV( namestr_record.nhfun ); @@ -269,7 +269,7 @@ SHORTREV( namestr_record.nifl ); SHORTREV( namestr_record.nifd ); - LONGREV ( namestr_record.npos ); + INTREV ( namestr_record.npos ); /* copy filled struct to return area */ memcpy( raw_buffer, &namestr_record, sizeof(namestr_record) ); Modified: trunk/SASxport/src/writeSAS.h =================================================================== --- trunk/SASxport/src/writeSAS.h 2007-11-06 16:24:50 UTC (rev 1222) +++ trunk/SASxport/src/writeSAS.h 2007-11-07 18:14:58 UTC (rev 1223) @@ -56,6 +56,11 @@ *****/ #define MIN(x,y) (x>y?y:x) +#ifdef DO_TEST +#define ASSERT(x) assert(x) +#else +#define ASSERT(x) if(!(x)) error("Assertion failed: x") +#endif /***** @@ -128,7 +133,7 @@ short nifl; /* INFORMAT LENGTH ATTRIBUTE */ short nifd; /* INFORMAT NUMBER OF DECIMALS */ - long npos; /* POSITION OF VALUE IN OBSERVATION */ + int npos; /* POSITION OF VALUE IN OBSERVATION */ char rest[52]; /* remaining fields are irrelevant */ }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |