Thread: [R-gregmisc-users] SF.net SVN: r-gregmisc:[1653] trunk/SASxport/src
Brought to you by:
warnes
From: <wa...@us...> - 2013-05-11 20:10:15
|
Revision: 1653 http://sourceforge.net/p/r-gregmisc/code/1653 Author: warnes Date: 2013-05-11 20:10:12 +0000 (Sat, 11 May 2013) Log Message: ----------- Carry bug fix forward to handle loading xport data when a dataset ends on exactly 80 byte block boundry. Modified Paths: -------------- trunk/SASxport/src/SASxport.c trunk/SASxport/src/SASxport.h Added Paths: ----------- trunk/SASxport/src/foreign.h Modified: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c 2013-05-11 20:06:55 UTC (rev 1652) +++ trunk/SASxport/src/SASxport.c 2013-05-11 20:10:12 UTC (rev 1653) @@ -25,20 +25,9 @@ #include <string.h> #include <R.h> #include <Rinternals.h> -//#include "foreign.h" +#include "foreign.h" #include "SASxport.h" - -#ifdef ENABLE_NLS -#include <libintl.h> -#define _(String) dgettext ("foreign", String) -#define gettext_noop(String) (String) -#else -#define _(String) (String) -#define gettext_noop(String) (String) -#endif - - #define HEADER_BEG "HEADER RECORD*******" #define HEADER_TYPE_LIBRARY "LIBRARY " #define HEADER_TYPE_MEMBER "MEMBER " @@ -153,9 +142,9 @@ int n; n = GET_RECORD(record, fp, 80); - if(n == 80 && strncmp(LIB_HEADER, record, 80) != 0) + if(n != 80 || strncmp(LIB_HEADER, record, 80) != 0) error(_("file not in SAS transfer format")); - + n = GET_RECORD(record, fp, 80); if(n != 80) return 0; @@ -230,8 +219,9 @@ Free(lib_head); n = GET_RECORD(record, fp, 80); - if(n != 80 || strncmp(MEM_HEADER, record, 75) != 0 || - strncmp(" ", record+78, 2) != 0) + if(n != 80 || + strncmp(MEM_HEADER, record, 75) != 0 || + strncmp(" ", record+78, 2) != 0 ) error(_("file not in SAS transfer format")); record[78] = '\0'; sscanf(record+75, "%d", &namestr_length); @@ -297,7 +287,7 @@ { char *tmp; char record[81]; - int i, n, nbytes, totwidth, nlength, restOfCard; + int i, n, totwidth, nlength, restOfCard; struct SAS_XPORT_namestr *nam_head; nam_head = Calloc(nvars, struct SAS_XPORT_namestr); @@ -394,7 +384,6 @@ for(i = 0; i < nvars; i++) totwidth += nlng[i]; - nbytes = 0; nlength = 0; tmp = Calloc(totwidth <= 80 ? 81 : (totwidth+1), char); restOfCard = 0; @@ -433,6 +422,18 @@ break; } } + else /* beware that the previous member can end on card + * boundary with no padding */ + if (restOfCard == 80 && n == 80 && + strncmp(MEM_HEADER, tmp, 75) == 0 && + strncmp(" ", tmp+78, 2) == 0) { + strncpy(record, tmp, 80); + *tailpad = 0; + record[78] = '\0'; + sscanf(record+75, "%d", &namestr_length); + break; + } + if (fsetpos(fp, ¤tPos)) { error(_("problem accessing SAS XPORT file")); } @@ -555,7 +556,7 @@ error(_("first argument must be a file name")); fp = fopen(R_ExpandFileName(CHAR(STRING_ELT(xportFile, 0))), "rb"); if (!fp) - error(_("unable to open file")); + error(_("unable to open file: '%s'"), strerror(errno)); namestrLength = init_xport_info(fp); ansLength = 0; @@ -659,7 +660,7 @@ error(_("first argument must be a file name")); fp = fopen(R_ExpandFileName(CHAR(STRING_ELT(xportFile, 0))), "rb"); if (!fp) - error(_("unable to open file")); + error(_("unable to open file: '%s'"), strerror(errno)); if (fseek(fp, 240, SEEK_SET) != 0) error(_("problem reading SAS XPORT file '%s'"), CHAR(STRING_ELT(xportFile, 0))); Modified: trunk/SASxport/src/SASxport.h =================================================================== --- trunk/SASxport/src/SASxport.h 2013-05-11 20:06:55 UTC (rev 1652) +++ trunk/SASxport/src/SASxport.h 2013-05-11 20:10:12 UTC (rev 1653) @@ -13,11 +13,11 @@ * along with this program; if not, a copy is available at * http://www.r-project.org/Licenses/ */ - + /* * This file is derived from code in the SAS Technical Support * document TS-140 "The Record Layout of a Data Set in SAS Transport - * (XPORT) Format" available as + * (XPORT) Format" available as * http://ftp.sas.com/techsup/download/technote/ts140.html */ @@ -25,13 +25,15 @@ #define SASEXPORT_H #include <string.h> /* for memcpy and memset */ +#include "foreign.h" #include "swap_bytes.h" +#include <errno.h> /* double cnxptiee(double from, int fromtype, int totype); */ -struct SAS_XPORT_header { +struct SAS_XPORT_header { char sas_symbol[2][8]; /* should be "SAS " */ char saslib[8]; /* should be "SASLIB " */ char sasver[8]; @@ -40,11 +42,11 @@ char sas_mod[16]; }; -struct SAS_XPORT_member { +struct SAS_XPORT_member { char sas_symbol[8]; char sas_dsname[8]; char sasdata[8]; - char sasver[8]; + char sasver[8]; char sas_osname[8]; char sas_create[16]; char sas_mod[16]; Added: trunk/SASxport/src/foreign.h =================================================================== --- trunk/SASxport/src/foreign.h (rev 0) +++ trunk/SASxport/src/foreign.h 2013-05-11 20:10:12 UTC (rev 1653) @@ -0,0 +1,77 @@ +/* + * + * Common header file for the foreign package for R + * + * Copyright 2000-2000 Saikat DebRoy <sa...@st...> + * Douglas M. Bates <ba...@st...>, + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + */ + +#ifndef FOREIGN_H +#define FOREIGN_H + +#include <R.h> +#include <Rinternals.h> + +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(String) dgettext ("foreign", String) +#define gettext_noop(String) (String) +#else +#define _(String) (String) +#define gettext_noop(String) (String) +#endif + +#define CN_TYPE_BIG 1 +#define CN_TYPE_LITTLE 2 +#define CN_TYPE_XPORT 3 +#define CN_TYPE_IEEEB CN_TYPE_BIG +#define CN_TYPE_IEEEL CN_TYPE_LITTLE + +#define BIG 4321 +#define LITTLE 1234 +#define UNKNOWN 0000 + +#ifdef WORDS_BIGENDIAN +# define CN_TYPE_NATIVE CN_TYPE_IEEEB +# define endian BIG +#else +# define CN_TYPE_NATIVE CN_TYPE_IEEEL +# define endian LITTLE +#endif /* not WORDS_BIGENDIAN */ + +typedef int R_int32; +/* typedef short int16; unused */ + +typedef double R_flt64; +/* typedef float flt32; unused */ + +#define FPREP_IEEE754 754 +#define FPREP FPREP_IEEE754 + +#ifdef max +# undef max +#endif +#ifdef min +# undef min +#endif +#define max(a,b) ((a) >= (b) ? (a) : (b)) +#define min(a,b) ((a) <= (b) ? (a) : (b)) + +#endif /* FOREIGN_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-18 17:04:10
|
Revision: 1839 http://sourceforge.net/p/r-gregmisc/code/1839 Author: warnes Date: 2014-07-18 17:04:07 +0000 (Fri, 18 Jul 2014) Log Message: ----------- minor code formatting changes Modified Paths: -------------- trunk/SASxport/src/SASxport.c trunk/SASxport/src/ibm2ieee.c trunk/SASxport/src/writeSAS.c Modified: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c 2014-07-18 17:03:46 UTC (rev 1838) +++ trunk/SASxport/src/SASxport.c 2014-07-18 17:04:07 UTC (rev 1839) @@ -62,7 +62,7 @@ static double get_IBM_double(char* c, size_t len) { - /* Conversion from IBM 360 format to double */ +/* Conversion from IBM 360 format to double */ /* * IBM format: * 6 5 0 @@ -77,14 +77,14 @@ * the high order hex fraction digit. */ unsigned int i, upper, lower; - /* exponent is expressed here as - excess 70 (=64+6) to accomodate - integer conversion of c[1] to c[4] */ + /* exponent is expressed here as + excess 70 (=64+6) to accomodate + integer conversion of c[1] to c[4] */ char negative = c[0] & 0x80, exponent = (c[0] & 0x7f) - 70, buf[4]; - double value; + double value; char ibuf[8]; - if (len < 2 || len > 8) + if (len < 2 || len > 8) error(_("invalid field length in numeric variable")); /* this effectively zero-pads c: */ @@ -169,7 +169,7 @@ return 0; return 1; } - + static int get_mem_header(FILE *fp, struct SAS_XPORT_member *member) { @@ -179,7 +179,7 @@ n = GET_RECORD(record, fp, 80); if(n != 80 || strncmp(DSC_HEADER, record, 80) != 0) error(_("file not in SAS transfer format")); - + n = GET_RECORD(record, fp, 80); if(n != 80) return 0; @@ -224,7 +224,7 @@ Free(lib_head); n = GET_RECORD(record, fp, 80); - if(n != 80 || + if(n != 80 || strncmp(MEM_HEADER, record, 75) != 0 || strncmp(" ", record+78, 2) != 0 ) error(_("file not in SAS transfer format")); @@ -290,20 +290,20 @@ } static int -next_xport_info(FILE *fp, int namestr_length, int nvars, +next_xport_info(FILE *fp, int namestr_length, int nvars, int *headpad, - int *tailpad, - int *length, - int *ntype, + int *tailpad, + int *length, + int *ntype, int *nlng, - int *nvar0, - SEXP nname, - SEXP nlabel, - SEXP nform, - int *nfl, - int *nfd, - SEXP niform, - int *nifl, + int *nvar0, + SEXP nname, + SEXP nlabel, + SEXP nform, + int *nfl, + int *nfd, + SEXP niform, + int *nifl, int *nifd, int *npos) { @@ -331,13 +331,13 @@ } (*headpad) += i; } - + n = GET_RECORD(record, fp, 80); if(n != 80 || strncmp(OBS_HEADER, record, 80) != 0) { Free(nam_head); error(_("file not in SAS transfer format")); } - + for(i = 0; i < nvars; i++) { int nname_len = 0, nlabel_len = 0, nform_len = 0, niform_len=0; char tmpname[41]; @@ -455,7 +455,7 @@ sscanf(record+75, "%d", &namestr_length); break; } - + if (fsetpos(fp, ¤tPos)) { error(_("problem accessing SAS XPORT file")); } @@ -663,14 +663,14 @@ SET_STRING_ELT(ansNames , ansLength, mkChar(dsname )); SET_VECTOR_ELT(ans, ansLength, varInfo); ansLength++; - + UNPROTECT(7); PROTECT(ans); PROTECT(ansNames); } - setAttrib(ans, R_NamesSymbol, ansNames); + setAttrib(ans, R_NamesSymbol, ansNames); UNPROTECT(5); fclose(fp); return ans; @@ -736,7 +736,7 @@ for(k = nvar-1; k >= 0; k--) { tmpchar = record + dataPosition[k]; if(dataType[k] == REALSXP) { - REAL(VECTOR_ELT(data, k))[j] = + REAL(VECTOR_ELT(data, k))[j] = get_IBM_double(tmpchar, dataWidth[k]); } else { tmpchar[dataWidth[k]] = '\0'; @@ -753,7 +753,7 @@ } fseek(fp, dataTailPad, SEEK_CUR); - + Free(record); } UNPROTECT(1); Modified: trunk/SASxport/src/ibm2ieee.c =================================================================== --- trunk/SASxport/src/ibm2ieee.c 2014-07-18 17:03:46 UTC (rev 1838) +++ trunk/SASxport/src/ibm2ieee.c 2014-07-18 17:04:07 UTC (rev 1839) @@ -30,7 +30,7 @@ * * Convert an array of IBM/360 format double precision values of at *in * of length 'count' to BIG-ENDIAN IEEE double precision value at *out. - * + * * This code was extracted from the "ntohd" function, original author * Michael John Muuss * @@ -63,7 +63,9 @@ continue; } \ -void ibm2ieee(register unsigned char *out, register const unsigned char *in, int count) +void ibm2ieee(register unsigned char *out, + register const unsigned char *in, + int count) { /* * IBM Format. @@ -75,11 +77,11 @@ register unsigned int left, right, signbit; register int exp; - left = ( (unsigned int) in[0]<<24) | - ( (unsigned int) in[1]<<16) | - ( (unsigned int) in[2]<<8) | + left = ( (unsigned int) in[0]<<24) | + ( (unsigned int) in[1]<<16) | + ( (unsigned int) in[2]<<8) | in[3]; - right = ( (unsigned int) in[4]<<24) | + right = ( (unsigned int) in[4]<<24) | ( (unsigned int) in[5]<<16) | ( (unsigned int) in[6]<<8) | in[7]; Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2014-07-18 17:03:46 UTC (rev 1838) +++ trunk/SASxport/src/writeSAS.c 2014-07-18 17:04:07 UTC (rev 1839) @@ -5,7 +5,7 @@ * Author: Gregory R. Warnes <gr...@wa...> * * Copyright (C) 2007-2013 Gregory R. Warnes <gr...@wa...> - * + * * 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 * the Free Software Foundation; either version 2 of the License, or @@ -40,7 +40,7 @@ { int i; - for(i=0; i<(len); i++) + for(i=0; i<(len); i++) target[i]=' '; } @@ -64,7 +64,7 @@ { int i; - for(i=0; i<(len); i++) + for(i=0; i<(len); i++) target[i]=0; } @@ -90,7 +90,7 @@ * This function is used to retreive the filled buffer as an R 'raw' * object. This is necessary because the buffer legitimately contains * embedded nulls and R currently does not permit raw buffers to be - * passed via .C . + * passed via .C . */ #define MYBUFSIZE 1024 /* plenty big */ @@ -113,7 +113,7 @@ -void fill_file_header( +void fill_file_header( char **cDate, /* creation date */ char **mdate, /* modification date */ char **sasVer, /* SAS version number */ @@ -127,7 +127,7 @@ /* Line 2*/ blankCopy( file_header.sas_symbol1, 8, "SAS "); - blankCopy( file_header.sas_symbol2, 8, "SAS "); + blankCopy( file_header.sas_symbol2, 8, "SAS "); blankCopy( file_header.saslib, 8, "SASLIB "); blankCopy( file_header.sasver, 8, sasVer[0] ); zeroCopy ( file_header.sas_os, 8, osType[0] ); @@ -148,7 +148,7 @@ } -void fill_member_header( +void fill_member_header( char **dfName, /* Name of data set */ char **sasVer, /* SAS version number */ char **osType, /* Operating System */ @@ -220,19 +220,19 @@ int *nvar0, /* VARNUM */ char **nname, /* NAME OF VARIABLE */ char **nlabel, /* LABEL OF VARIABLE */ - + char **nform, /* NAME OF FORMAT */ int *nfl, /* FORMAT FIELD LENGTH OR 0 */ int *nfd, /* FORMAT NUMBER OF DECIMALS */ int *nfj, /* 0=LEFT JUSTIFICATION, 1=RIGHT JUST */ - + // char nfill[2], /* (UNUSED, FOR ALIGNMENT AND FUTURE) */ - + char **niform, /* NAME OF INPUT FORMAT */ int *nifl, /* INFORMAT LENGTH ATTRIBUTE */ int *nifd, /* INFORMAT NUMBER OF DECIMALS */ int *npos /* POSITION OF VALUE IN OBSERVATION */ - + // char rest[52], /* remaining fields are irrelevant */ ) { @@ -250,19 +250,19 @@ namestr_record.nfd = (short) *nfd; /* FORMAT NUMBER OF DECIMALS */ namestr_record.nfj = (short) *nfj; /* 0=LEFT JUSTIFICATION, 1=RIGHT JUST */ - zeroFill(namestr_record.nfill, 2); /* (UNUSED, FOR ALIGNMENT AND FUTURE) */ + zeroFill(namestr_record.nfill, 2); /* (UNUSED, FOR ALIGNMENT AND FUTURE) */ 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 = (int) *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 INTREV(a) REVERSE( &a, sizeof(int) ) +#define INTREV(a) REVERSE( &a, sizeof(int) ) SHORTREV( namestr_record.ntype ); SHORTREV( namestr_record.nhfun ); @@ -274,7 +274,7 @@ SHORTREV( namestr_record.nifl ); SHORTREV( namestr_record.nifd ); - INTREV ( namestr_record.npos ); + INTREV ( namestr_record.npos ); /* copy filled struct to return area */ memcpy( raw_buffer, &namestr_record, sizeof(namestr_record) ); @@ -284,13 +284,13 @@ return; } - - + + void fill_obs_header() { struct OBS_HEADER obs_header; - blankCopy( obs_header.l1, 80, + blankCopy( obs_header.l1, 80, "HEADER RECORD*******OBS HEADER RECORD!!!!!!!000000000000000000000000000000 "); /* copy filled struct to return area */ @@ -305,10 +305,10 @@ void fill_numeric_field( double *value /* single numeric value */ - ) + ) { /* convert to IBM floating point */ - + reverse( (unsigned char*) value, sizeof(double) ); ieee2ibm( (unsigned char *) raw_buffer, (unsigned char *) value, 1); @@ -320,11 +320,11 @@ return; } - + void fill_character_field( char **value, /* single character string */ int *width /* field width */ - ) + ) { /* copy to buffer */ blankCopy(raw_buffer, *width, value[0]); @@ -344,7 +344,7 @@ return; } - + void fill_space( int *type, /* 0 --> zero fill, 1 --> space fill */ int *width This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-18 20:41:07
|
Revision: 1842 http://sourceforge.net/p/r-gregmisc/code/1842 Author: warnes Date: 2014-07-18 20:40:57 +0000 (Fri, 18 Jul 2014) Log Message: ----------- - Rename function and file 'reverse' to 'host_to_be' (short for host-endian to big-endian') to clarify purpose of the function. - Remove pre-processeor definition of REVERSE, and add definitions of HTOBE_SHORT, HTOBE_INT, and HTOBE_DOUBLE. Modified Paths: -------------- trunk/SASxport/src/writeSAS.c trunk/SASxport/src/writeSAS.h Added Paths: ----------- trunk/SASxport/src/host_to_be.c Removed Paths: ------------- trunk/SASxport/src/reverse.c Copied: trunk/SASxport/src/host_to_be.c (from rev 1825, trunk/SASxport/src/reverse.c) =================================================================== --- trunk/SASxport/src/host_to_be.c (rev 0) +++ trunk/SASxport/src/host_to_be.c 2014-07-18 20:40:57 UTC (rev 1842) @@ -0,0 +1,75 @@ +#include "writeSAS.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> +#include <sys/types.h> + +/* host_to_be: convert current host byte order to big endian */ +void host_to_be( unsigned char *intp, size_t size) +{ + static unsigned char endianTest[2] = {0x01,0x00}; + size_t i; + unsigned char tmp; + + /* Test if we are on a big endian or little endian platform */ + if( (short) *endianTest != 1 ) + { + /* The native byte order is big endian, so do nothing */ + //printf("Big Endian Machine!\n"); + return; + } + + /* If native byte order is little endian, we need to swap bytes */ + for(i=0; i < size/2; i++) + { + tmp = (unsigned char) intp[i]; + intp[i] = intp[size-i-1]; + intp[size-i-1] = tmp; + } + + return; +} + +/* test code */ +void test_host_to_be() +{ + unsigned char byte_pattern[1] = { 0x00 }; + unsigned char byte_value = 0x00; + + unsigned char short_pattern[2] = { 0x01, 0x00 }; /* NB: big endian byte pattern */ + short short_value = 0x0100; /* NB: hex is also written big endian */ + + unsigned char int_pattern[4] = { 0x03, 0x02, 0x01, 0x00 }; + int int_value = 0x03020100; + + unsigned char long_pattern[4] = { 0x03, 0x02, 0x01, 0x00 }; + long long_value = 0x03020100; + + /* Do the host_to_be, then test */ + + /* byte */ + host_to_be( &byte_value, sizeof(unsigned char) ); + ASSERT( (unsigned char) *byte_pattern == byte_value ); + + /* short */ + host_to_be( (unsigned char*) &short_value, sizeof(short) ); + ASSERT( *((short *) short_pattern) == short_value ); + + /* int */ + host_to_be( (unsigned char*) &int_value, sizeof(int) ); + ASSERT( *((int *) int_pattern) == int_value ); + + /* long */ + host_to_be( (unsigned char*) &long_value, sizeof(long) ); + ASSERT( *((long*) long_pattern) == long_value ); + +} + +#ifdef DO_TEST +int main(int argc, char *argv) +{ + test_host_to_be(); +} +#endif Deleted: trunk/SASxport/src/reverse.c =================================================================== --- trunk/SASxport/src/reverse.c 2014-07-18 18:37:51 UTC (rev 1841) +++ trunk/SASxport/src/reverse.c 2014-07-18 20:40:57 UTC (rev 1842) @@ -1,77 +0,0 @@ -#include "writeSAS.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <assert.h> -#include <sys/types.h> - -/* reverse: convert current byte order to big endian */ -void reverse( unsigned char *intp, size_t size) -{ - static unsigned char endianTest[2] = {0x01,0x00}; - size_t i; - unsigned char tmp; - -#if !defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN) - /* Test if we are on a big endian or little endian platform */ - if( (short) *endianTest != 1 ) - { - /* The native byte order is big endian, so do nothing */ - //printf("Big Endian Machine!\n"); - return; - } -#endif - - /* If native byte order is little endian, we need to swap bytes */ - for(i=0; i < size/2; i++) - { - tmp = (unsigned char) intp[i]; - intp[i] = intp[size-i-1]; - intp[size-i-1] = tmp; - } - - return; -} - -/* test code */ -void test_reverse() -{ - unsigned char byte_pattern[1] = { 0x00 }; - unsigned char byte_value = 0x00; - - unsigned char short_pattern[2] = { 0x01, 0x00 }; /* NB: big endian byte pattern */ - short short_value = 0x0100; /* NB: hex is also written big endian */ - - unsigned char int_pattern[4] = { 0x03, 0x02, 0x01, 0x00 }; - int int_value = 0x03020100; - - unsigned char long_pattern[4] = { 0x03, 0x02, 0x01, 0x00 }; - long long_value = 0x03020100; - - /* Do the reverse, then test */ - - /* byte */ - reverse( &byte_value, sizeof(unsigned char) ); - ASSERT( (unsigned char) *byte_pattern == byte_value ); - - /* short */ - reverse( (unsigned char*) &short_value, sizeof(short) ); - ASSERT( *((short *) short_pattern) == short_value ); - - /* int */ - reverse( (unsigned char*) &int_value, sizeof(int) ); - ASSERT( *((int *) int_pattern) == int_value ); - - /* long */ - reverse( (unsigned char*) &long_value, sizeof(long) ); - 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 2014-07-18 18:37:51 UTC (rev 1841) +++ trunk/SASxport/src/writeSAS.c 2014-07-18 20:40:57 UTC (rev 1842) @@ -260,22 +260,18 @@ zeroFill(namestr_record.rest, 52); /* remaining fields are irrelevant */ - /* Flip byte order if necessary */ -#define SHORTREV(a) REVERSE( &a, sizeof(short) ) -#define INTREV(a) REVERSE( &a, sizeof(int) ) + HTOBE_SHORT( namestr_record.ntype ); + HTOBE_SHORT( namestr_record.nhfun ); + HTOBE_SHORT( namestr_record.nlng ); + HTOBE_SHORT( namestr_record.nvar0 ); + HTOBE_SHORT( namestr_record.nfl ); + HTOBE_SHORT( namestr_record.nfd ); + HTOBE_SHORT( namestr_record.nfj ); + HTOBE_SHORT( namestr_record.nifl ); + HTOBE_SHORT( namestr_record.nifd ); - SHORTREV( namestr_record.ntype ); - SHORTREV( namestr_record.nhfun ); - SHORTREV( namestr_record.nlng ); - SHORTREV( namestr_record.nvar0 ); - SHORTREV( namestr_record.nfl ); - SHORTREV( namestr_record.nfd ); - SHORTREV( namestr_record.nfj ); - SHORTREV( namestr_record.nifl ); - SHORTREV( namestr_record.nifd ); + HTOBE_INT ( namestr_record.npos ); - INTREV ( namestr_record.npos ); - /* copy filled struct to return area */ memcpy( raw_buffer, &namestr_record, sizeof(namestr_record) ); @@ -309,7 +305,10 @@ { /* convert to IBM floating point */ - reverse( (unsigned char*) value, sizeof(double) ); + /* first convert to big-endian layout */ + HTOBE_DOUBLE( value ); + + /* now convert to ibm flaoting point format */ ieee2ibm( (unsigned char *) raw_buffer, (unsigned char *) value, 1); //cnxptiee( (char *) value, 0, raw_buffer , 1 ); Modified: trunk/SASxport/src/writeSAS.h =================================================================== --- trunk/SASxport/src/writeSAS.h 2014-07-18 18:37:51 UTC (rev 1841) +++ trunk/SASxport/src/writeSAS.h 2014-07-18 20:40:57 UTC (rev 1842) @@ -39,17 +39,6 @@ #define MISSING 0x2e000000 /* Standard SAS missing value: '.' */ /***** - REVERSE macro, used as a wrapper for the reverse() function to avoid - compiling/calling it on big-endian, where it is a NOOP. - *****/ - -#if ( defined(BIG_ENDIAN) && BIG_ENDIAN ) || ( defined(LITTLE_ENDIAN) && !LITTLE_ENDIAN ) -# define REVERSE(a,b) ( a ) -#else -# define REVERSE(a,b) reverse( (unsigned char*) a, (size_t) b ) -#endif - -/***** * Useful macro functions *****/ @@ -60,7 +49,15 @@ #define ASSERT(x) if(!(x)) error("Assertion failed: x") #endif +/* Convert (if necessary) to Big-Endian */ +# define HTOBE_SHORT(a) host_to_be( (unsigned char*) &a, sizeof(short) ) +# define HTOBE_INT(a) host_to_be( (unsigned char*) &a, sizeof(int) ) +# define HTOBE_DOUBLE(a) host_to_be( (unsigned char*) value, sizeof(double) ); +/* Alternative definition using system functions: */ +/* #define HTOBE_SHORT(a) (a) = htons( a ) */ +/* #define HTOBE_INT(a) (a) = htonl( a ) */ + /***** * File Record Structures *****/ @@ -175,7 +172,7 @@ void doTest(); -void reverse( unsigned char *intp, size_t size); +void host_to_be( unsigned char *intp, size_t size); void ieee2ibm(register unsigned char *out, register const unsigned char *in, int count); #endif /* FIELDS_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-20 02:01:43
|
Revision: 1847 http://sourceforge.net/p/r-gregmisc/code/1847 Author: warnes Date: 2014-07-20 02:01:34 +0000 (Sun, 20 Jul 2014) Log Message: ----------- Rename 'host_to_be' to 'to_bigend' to be more transparent about purpose Added Paths: ----------- trunk/SASxport/src/to_bigend.c trunk/SASxport/src/to_bigend.h Removed Paths: ------------- trunk/SASxport/src/host_to_be.c Deleted: trunk/SASxport/src/host_to_be.c =================================================================== --- trunk/SASxport/src/host_to_be.c 2014-07-19 03:37:50 UTC (rev 1846) +++ trunk/SASxport/src/host_to_be.c 2014-07-20 02:01:34 UTC (rev 1847) @@ -1,80 +0,0 @@ -#include "writeSAS.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <assert.h> -#include <sys/types.h> - -/* host_to_be: convert current host byte order to big endian */ -void host_to_be( unsigned char *intp, size_t size) -{ - size_t i; - unsigned char tmp; - - short twobytes = 0x0001; - char onebyte = *(char*) &twobytes; - - /* Test if we are on a big endian or little endian platform */ - if (onebyte == 1) - { - /* Native byte order is little endian, so swap bytes */ - /* printf("Little Endian Machine!\n"); */ - - for(i=0; i < size/2; i++) - { - tmp = (unsigned char) intp[i]; - intp[i] = intp[size-i-1]; - intp[size-i-1] = tmp; - } - } - else - { - /* The native byte order is big endian, so do nothing */ - /* printf("Big Endian Machine!\n"); */ - } - - return; -} - -/* test code */ -void test_host_to_be() -{ - unsigned char byte_pattern[1] = { 0x00 }; - unsigned char byte_value = 0x00; - - unsigned char short_pattern[2] = { 0x01, 0x00 }; /* NB: big endian byte pattern */ - short short_value = 0x0100; /* NB: hex is also written big endian */ - - unsigned char int_pattern[4] = { 0x03, 0x02, 0x01, 0x00 }; - int int_value = 0x03020100; - - unsigned char long_pattern[4] = { 0x03, 0x02, 0x01, 0x00 }; - long long_value = 0x03020100; - - /* Do the host_to_be, then test */ - - /* byte */ - host_to_be( &byte_value, sizeof(unsigned char) ); - ASSERT( (unsigned char) *byte_pattern == byte_value ); - - /* short */ - host_to_be( (unsigned char*) &short_value, sizeof(short) ); - ASSERT( *((short *) short_pattern) == short_value ); - - /* int */ - host_to_be( (unsigned char*) &int_value, sizeof(int) ); - ASSERT( *((int *) int_pattern) == int_value ); - - /* long */ - host_to_be( (unsigned char*) &long_value, sizeof(long) ); - ASSERT( *((long*) long_pattern) == long_value ); - -} - -#ifdef DO_TEST -int main(int argc, char *argv) -{ - test_host_to_be(); -} -#endif Copied: trunk/SASxport/src/to_bigend.c (from rev 1846, trunk/SASxport/src/host_to_be.c) =================================================================== --- trunk/SASxport/src/to_bigend.c (rev 0) +++ trunk/SASxport/src/to_bigend.c 2014-07-20 02:01:34 UTC (rev 1847) @@ -0,0 +1,80 @@ +#include "writeSAS.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> +#include <sys/types.h> + +/* to_bigend: convert current host byte order to big endian */ +void to_bigend( unsigned char *intp, size_t size) +{ + size_t i; + unsigned char tmp; + + short twobytes = 0x0001; + char onebyte = *(char*) &twobytes; + + /* Test if we are on a big endian or little endian platform */ + if (onebyte == 1) + { + /* Native byte order is little endian, so swap bytes */ + /* printf("Little Endian Machine!\n"); */ + + for(i=0; i < size/2; i++) + { + tmp = (unsigned char) intp[i]; + intp[i] = intp[size-i-1]; + intp[size-i-1] = tmp; + } + } + else + { + /* The native byte order is big endian, so do nothing */ + /* printf("Big Endian Machine!\n"); */ + } + + return; +} + +/* test code */ +void test_to_bigend() +{ + unsigned char byte_pattern[1] = { 0x00 }; + unsigned char byte_value = 0x00; + + unsigned char short_pattern[2] = { 0x01, 0x00 }; /* NB: big endian byte pattern */ + short short_value = 0x0100; /* NB: hex is also written big endian */ + + unsigned char int_pattern[4] = { 0x03, 0x02, 0x01, 0x00 }; + int int_value = 0x03020100; + + unsigned char long_pattern[4] = { 0x03, 0x02, 0x01, 0x00 }; + long long_value = 0x03020100; + + /* Do the to_bigend, then test */ + + /* byte */ + to_bigend( &byte_value, sizeof(unsigned char) ); + ASSERT( (unsigned char) *byte_pattern == byte_value ); + + /* short */ + to_bigend( (unsigned char*) &short_value, sizeof(short) ); + ASSERT( *((short *) short_pattern) == short_value ); + + /* int */ + to_bigend( (unsigned char*) &int_value, sizeof(int) ); + ASSERT( *((int *) int_pattern) == int_value ); + + /* long */ + to_bigend( (unsigned char*) &long_value, sizeof(long) ); + ASSERT( *((long*) long_pattern) == long_value ); + +} + +#ifdef DO_TEST +int main(int argc, char **argv) +{ + test_to_bigend(); +} +#endif Added: trunk/SASxport/src/to_bigend.h =================================================================== --- trunk/SASxport/src/to_bigend.h (rev 0) +++ trunk/SASxport/src/to_bigend.h 2014-07-20 02:01:34 UTC (rev 1847) @@ -0,0 +1,26 @@ +/* + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, a copy is available at + * http://www.r-project.org/Licenses/ + */ +#ifndef TO_BIGEND_H +#define TO_BIGEND_H + +void to_bigend( unsigned char *intp, size_t size); + +/* Convert (if necessary) to Big-Endian */ +#define TO_BIGEND_SHORT(a) to_bigend( (unsigned char*) &a, sizeof(short) ) +#define TO_BIGEND_INT(a) to_bigend( (unsigned char*) &a, sizeof(int) ) +#define TO_BIGEND_DOUBLE(a) to_bigend( (unsigned char*) &a, sizeof(double) ) + +#endif /* TO_BIGEND_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-20 02:05:41
|
Revision: 1848 http://sourceforge.net/p/r-gregmisc/code/1848 Author: warnes Date: 2014-07-20 02:05:33 +0000 (Sun, 20 Jul 2014) Log Message: ----------- Rename 'host_to_be' to 'to_bigend' to be more transparent about purpose Modified Paths: -------------- trunk/SASxport/src/SASxport.c trunk/SASxport/src/SASxport.h trunk/SASxport/src/ibm2ieee.c trunk/SASxport/src/ieee2ibm.c Added Paths: ----------- trunk/SASxport/src/ibm2ieee.h Modified: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c 2014-07-20 02:01:34 UTC (rev 1847) +++ trunk/SASxport/src/SASxport.c 2014-07-20 02:05:33 UTC (rev 1848) @@ -48,7 +48,7 @@ #define BLANK24 " " #define GET_RECORD(rec, fp, len) \ - fread((rec), sizeof(char), (size_t) (len), (fp)) + (int) fread((rec), sizeof(char), (size_t) (len), (fp)) #define IS_SASNA_CHAR(c) ((c) == 0x5f || (c) == 0x2e || \ (0x41 <= (c) && (c) <= 0x5a)) @@ -80,9 +80,11 @@ /* exponent is expressed here as excess 70 (=64+6) to accomodate integer conversion of c[1] to c[4] */ - char negative = c[0] & 0x80, exponent = (c[0] & 0x7f) - 70, buf[4]; + char negative = c[0] & 0x80; + // needs to be signed: char is not on Raspbian + signed char exponent = (c[0] & 0x7f) - 70; double value; - char ibuf[8]; + char buf[4], ibuf[8]; if (len < 2 || len > 8) error(_("invalid field length in numeric variable")); @@ -258,9 +260,8 @@ record[58] = '\0'; sscanf(record+54, "%d", &length); - /* Extract data set name */ tmp = strchr(mem_head->sas_dsname, ' '); - n = tmp - mem_head->sas_dsname; + n = (int)(tmp - mem_head->sas_dsname); if(n > 0) { if (n > 8) n = 8; @@ -290,7 +291,9 @@ } static int -next_xport_info(FILE *fp, int namestr_length, int nvars, +next_xport_info(FILE *fp, + int namestr_length, + int nvars, int *headpad, int *tailpad, int *length, @@ -586,7 +589,7 @@ ansLength = 0; PROTECT(ans = allocVector(VECSXP, 0)); - PROTECT(ansNames = allocVector(STRSXP, 0)); + PROTECT(ansNames = allocVector(STRSXP, 0)); while(!feof(fp)) { @@ -689,6 +692,7 @@ char *record, *tmpchar, *c; FILE *fp; SEXP ans, names, data, dataInfo, dataName; + double dbl; ansLength = LENGTH(xportInfo); PROTECT(ans = allocVector(VECSXP, ansLength)); @@ -736,8 +740,19 @@ for(k = nvar-1; k >= 0; k--) { tmpchar = record + dataPosition[k]; if(dataType[k] == REALSXP) { - REAL(VECTOR_ELT(data, k))[j] = - get_IBM_double(tmpchar, dataWidth[k]); + + /* REAL(VECTOR_ELT(data, k))[j] = */ + /* get_IBM_double(tmpchar, dataWidth[k]); */ + + ibm2ieee( (unsigned char*) &dbl, + (unsigned char*) tmpchar, + 1 ); + + /* convert from big-endian layout */ + to_bigend( (unsigned char*) &dbl, sizeof(double) ); + + REAL(VECTOR_ELT(data, k))[j] = dbl; + } else { tmpchar[dataWidth[k]] = '\0'; /* strip trailing blanks */ Modified: trunk/SASxport/src/SASxport.h =================================================================== --- trunk/SASxport/src/SASxport.h 2014-07-20 02:01:34 UTC (rev 1847) +++ trunk/SASxport/src/SASxport.h 2014-07-20 02:05:33 UTC (rev 1848) @@ -28,6 +28,8 @@ #include "foreign.h" #include "swap_bytes.h" #include <errno.h> +#include "to_bigend.h" +#include "ibm2ieee.h" /* double cnxptiee(double from, int fromtype, int totype); */ Modified: trunk/SASxport/src/ibm2ieee.c =================================================================== --- trunk/SASxport/src/ibm2ieee.c 2014-07-20 02:01:34 UTC (rev 1847) +++ trunk/SASxport/src/ibm2ieee.c 2014-07-20 02:05:33 UTC (rev 1848) @@ -22,8 +22,8 @@ * information. */ -#include "writeSAS.h" #include <stdio.h> +#include "ibm2ieee.h" /**************************** * ibm2ieee @@ -40,29 +40,6 @@ * ***************************/ -#define OUT_IEEE_ZERO { \ - *out++ = 0; \ - *out++ = 0; \ - *out++ = 0; \ - *out++ = 0; \ - *out++ = 0; \ - *out++ = 0; \ - *out++ = 0; \ - *out++ = 0; \ - continue; } \ - -#define OUT_IEEE_NAN { /* Signaling NAN */ \ - *out++ = 0xFF; \ - *out++ = 0xF0; \ - *out++ = 0x0B; \ - *out++ = 0xAD; \ - *out++ = 0x0B; \ - *out++ = 0xAD; \ - *out++ = 0x0B; \ - *out++ = 0xAD; \ - continue; } \ - - void ibm2ieee(register unsigned char *out, register const unsigned char *in, int count) Added: trunk/SASxport/src/ibm2ieee.h =================================================================== --- trunk/SASxport/src/ibm2ieee.h (rev 0) +++ trunk/SASxport/src/ibm2ieee.h 2014-07-20 02:05:33 UTC (rev 1848) @@ -0,0 +1,62 @@ +/* + * File: SASxport/src/ibm2ieee.h + * + * Originally from BRL-CAD file /brlcad/src/libbu/htond.c + * + * Copyright (c) 2004-2007 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * * Minor changes (c) 2007 by Gregory R. Warnes <gr...@wa...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +#ifndef IBM2IEEE_H +#define IBM2IEEE_H + +#include <R.h> +#include <Rinternals.h> + +#define OUT_IEEE_ZERO { \ + *out++ = 0; \ + *out++ = 0; \ + *out++ = 0; \ + *out++ = 0; \ + *out++ = 0; \ + *out++ = 0; \ + *out++ = 0; \ + *out++ = 0; \ + continue; } \ + +#define OUT_IEEE_NAN { /* Signaling NAN */ \ + *out++ = 0xFF; \ + *out++ = 0xF0; \ + *out++ = 0x0B; \ + *out++ = 0xAD; \ + *out++ = 0x0B; \ + *out++ = 0xAD; \ + *out++ = 0x0B; \ + *out++ = 0xAD; \ + continue; } \ + + +void ieee2ibm(register unsigned char *out, + register const unsigned char *in, + int count); + +void ibm2ieee(register unsigned char *out, + register const unsigned char *in, + int count); + + +#endif /* IBM2IEEE_H */ Modified: trunk/SASxport/src/ieee2ibm.c =================================================================== --- trunk/SASxport/src/ieee2ibm.c 2014-07-20 02:01:34 UTC (rev 1847) +++ trunk/SASxport/src/ieee2ibm.c 2014-07-20 02:05:33 UTC (rev 1848) @@ -22,8 +22,8 @@ * information. */ -#include "writeSAS.h" #include <stdio.h> +#include "ibm2ieee.h" /**************************** * ieee2ibm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-20 02:17:28
|
Revision: 1850 http://sourceforge.net/p/r-gregmisc/code/1850 Author: warnes Date: 2014-07-20 02:17:21 +0000 (Sun, 20 Jul 2014) Log Message: ----------- Finish rename of 'HTOBE' to 'TO_BIGEND' Modified Paths: -------------- trunk/SASxport/src/writeSAS.c trunk/SASxport/src/writeSAS.h Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2014-07-20 02:15:13 UTC (rev 1849) +++ trunk/SASxport/src/writeSAS.c 2014-07-20 02:17:21 UTC (rev 1850) @@ -32,9 +32,6 @@ #include "writeSAS.h" - - - /* Fill <target> buffer with <len> blanks without any terminating nulls */ void blankFill(char *target, int len) { @@ -198,7 +195,6 @@ ) { struct NAMESTR_HEADER namestr_header; - char tmpBuf[5]; blankCopy( namestr_header.l1, 54, "HEADER RECORD*******NAMESTR HEADER RECORD!!!!!!!000000"); blankCopy( namestr_header.nvar, 4, nvar[0] ); @@ -260,17 +256,17 @@ zeroFill(namestr_record.rest, 52); /* remaining fields are irrelevant */ - HTOBE_SHORT( namestr_record.ntype ); - HTOBE_SHORT( namestr_record.nhfun ); - HTOBE_SHORT( namestr_record.nlng ); - HTOBE_SHORT( namestr_record.nvar0 ); - HTOBE_SHORT( namestr_record.nfl ); - HTOBE_SHORT( namestr_record.nfd ); - HTOBE_SHORT( namestr_record.nfj ); - HTOBE_SHORT( namestr_record.nifl ); - HTOBE_SHORT( namestr_record.nifd ); + TO_BIGEND_SHORT( namestr_record.ntype ); + TO_BIGEND_SHORT( namestr_record.nhfun ); + TO_BIGEND_SHORT( namestr_record.nlng ); + TO_BIGEND_SHORT( namestr_record.nvar0 ); + TO_BIGEND_SHORT( namestr_record.nfl ); + TO_BIGEND_SHORT( namestr_record.nfd ); + TO_BIGEND_SHORT( namestr_record.nfj ); + TO_BIGEND_SHORT( namestr_record.nifl ); + TO_BIGEND_SHORT( namestr_record.nifd ); - HTOBE_INT ( namestr_record.npos ); + TO_BIGEND_INT ( namestr_record.npos ); /* copy filled struct to return area */ memcpy( raw_buffer, &namestr_record, sizeof(namestr_record) ); @@ -306,7 +302,7 @@ /* convert to IBM floating point */ /* first convert to big-endian layout */ - HTOBE_DOUBLE( value ); + TO_BIGEND_DOUBLE( value ); /* now convert to ibm flaoting point format */ ieee2ibm( (unsigned char *) raw_buffer, (unsigned char *) value, 1); Modified: trunk/SASxport/src/writeSAS.h =================================================================== --- trunk/SASxport/src/writeSAS.h 2014-07-20 02:15:13 UTC (rev 1849) +++ trunk/SASxport/src/writeSAS.h 2014-07-20 02:17:21 UTC (rev 1850) @@ -30,6 +30,8 @@ #include <R.h> #include <Rinternals.h> #include <sys/types.h> +#include "to_bigend.h" +#include "ibm2ieee.h" /***** @@ -49,14 +51,9 @@ #define ASSERT(x) if(!(x)) error("Assertion failed: x") #endif -/* Convert (if necessary) to Big-Endian */ -#define HTOBE_SHORT(a) host_to_be( (unsigned char*) &a, sizeof(short) ) -#define HTOBE_INT(a) host_to_be( (unsigned char*) &a, sizeof(int) ) -#define HTOBE_DOUBLE(a) host_to_be( (unsigned char*) &a, sizeof(double) ) - /* Alternative definition using system functions: */ -/* #define HTOBE_SHORT(a) (a) = htons( a ) */ -/* #define HTOBE_INT(a) (a) = htonl( a ) */ +/* #define TO_BIGEND_SHORT(a) (a) = htons( a ) */ +/* #define TO_BIGEND_INT(a) (a) = htonl( a ) */ /***** * File Record Structures @@ -172,7 +169,6 @@ void doTest(); -void host_to_be( unsigned char *intp, size_t size); void ieee2ibm(register unsigned char *out, register const unsigned char *in, int count); -#endif /* FIELDS_H */ +#endif /* WRITESAS_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-21 16:23:32
|
Revision: 1863 http://sourceforge.net/p/r-gregmisc/code/1863 Author: warnes Date: 2014-07-21 16:23:28 +0000 (Mon, 21 Jul 2014) Log Message: ----------- Remove never-used conditional code and un-needed #include statements Modified Paths: -------------- trunk/SASxport/src/SASxport.c trunk/SASxport/src/SASxport.h Modified: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c 2014-07-21 14:51:44 UTC (rev 1862) +++ trunk/SASxport/src/SASxport.c 2014-07-21 16:23:28 UTC (rev 1863) @@ -741,10 +741,6 @@ tmpchar = record + dataPosition[k]; if(dataType[k] == REALSXP) { -#ifdef BIGENDIAN - reverse_double(tmpchar); -#endif - REAL(VECTOR_ELT(data, k))[j] = get_IBM_double(tmpchar, dataWidth[k]); } Modified: trunk/SASxport/src/SASxport.h =================================================================== --- trunk/SASxport/src/SASxport.h 2014-07-21 14:51:44 UTC (rev 1862) +++ trunk/SASxport/src/SASxport.h 2014-07-21 16:23:28 UTC (rev 1863) @@ -28,8 +28,6 @@ #include "foreign.h" #include "swap_bytes.h" #include <errno.h> -#include "to_bigend.h" -#include "ibm2ieee.h" /* double cnxptiee(double from, int fromtype, int totype); */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |