@@ -169,15 +169,15 @@ static readstat_error_t sav_skip_variable_record(sav_ctx_t *ctx) {
169169 retval = READSTAT_ERROR_READ ;
170170 goto cleanup ;
171171 }
172- label_len = ctx -> machine_needs_byte_swap ? byteswap4 (label_len ) : label_len ;
172+ label_len = ctx -> bswap ? byteswap4 (label_len ) : label_len ;
173173 int32_t label_capacity = (label_len + 3 ) / 4 * 4 ;
174174 if (io -> seek (label_capacity , READSTAT_SEEK_CUR , io -> io_ctx ) == -1 ) {
175175 retval = READSTAT_ERROR_SEEK ;
176176 goto cleanup ;
177177 }
178178 }
179179 if (variable .n_missing_values ) {
180- int n_missing_values = ctx -> machine_needs_byte_swap ? byteswap4 (variable .n_missing_values ) : variable .n_missing_values ;
180+ int n_missing_values = ctx -> bswap ? byteswap4 (variable .n_missing_values ) : variable .n_missing_values ;
181181 if (io -> seek (abs (n_missing_values ) * sizeof (double ), READSTAT_SEEK_CUR , io -> io_ctx ) == -1 ) {
182182 retval = READSTAT_ERROR_SEEK ;
183183 goto cleanup ;
@@ -201,11 +201,11 @@ static readstat_error_t sav_read_variable_record(sav_ctx_t *ctx) {
201201 retval = READSTAT_ERROR_READ ;
202202 goto cleanup ;
203203 }
204- variable .print = ctx -> machine_needs_byte_swap ? byteswap4 (variable .print ) : variable .print ;
205- variable .write = ctx -> machine_needs_byte_swap ? byteswap4 (variable .write ) : variable .write ;
204+ variable .print = ctx -> bswap ? byteswap4 (variable .print ) : variable .print ;
205+ variable .write = ctx -> bswap ? byteswap4 (variable .write ) : variable .write ;
206206
207207 readstat_type_t dta_type = READSTAT_TYPE_DOUBLE ;
208- int32_t type = ctx -> machine_needs_byte_swap ? byteswap4 (variable .type ) : variable .type ;
208+ int32_t type = ctx -> bswap ? byteswap4 (variable .type ) : variable .type ;
209209 int i ;
210210 if (type < 0 ) {
211211 if (ctx -> var_index == 0 ) {
@@ -252,7 +252,7 @@ static readstat_error_t sav_read_variable_record(sav_ctx_t *ctx) {
252252 retval = READSTAT_ERROR_READ ;
253253 goto cleanup ;
254254 }
255- label_len = ctx -> machine_needs_byte_swap ? byteswap4 (label_len ) : label_len ;
255+ label_len = ctx -> bswap ? byteswap4 (label_len ) : label_len ;
256256 int32_t label_capacity = (label_len + 3 ) / 4 * 4 ;
257257 char * label_buf = malloc (label_capacity );
258258 size_t out_label_len = label_len * 4 + 1 ;
@@ -277,7 +277,7 @@ static readstat_error_t sav_read_variable_record(sav_ctx_t *ctx) {
277277 ctx -> varinfo [ctx -> var_index ].labels_index = -1 ;
278278
279279 if (variable .n_missing_values ) {
280- info -> n_missing_values = ctx -> machine_needs_byte_swap ? byteswap4 (variable .n_missing_values ) : variable .n_missing_values ;
280+ info -> n_missing_values = ctx -> bswap ? byteswap4 (variable .n_missing_values ) : variable .n_missing_values ;
281281 if (info -> n_missing_values < 0 ) {
282282 info -> missing_range = 1 ;
283283 info -> n_missing_values = abs (info -> n_missing_values );
@@ -293,7 +293,7 @@ static readstat_error_t sav_read_variable_record(sav_ctx_t *ctx) {
293293 goto cleanup ;
294294 }
295295 for (i = 0 ; i < info -> n_missing_values ; i ++ ) {
296- if (ctx -> machine_needs_byte_swap ) {
296+ if (ctx -> bswap ) {
297297 info -> missing_values [i ] = byteswap_double (info -> missing_values [i ]);
298298 }
299299
@@ -328,7 +328,7 @@ static readstat_error_t sav_skip_value_label_record(sav_ctx_t *ctx) {
328328 retval = READSTAT_ERROR_READ ;
329329 goto cleanup ;
330330 }
331- if (ctx -> machine_needs_byte_swap )
331+ if (ctx -> bswap )
332332 label_count = byteswap4 (label_count );
333333 int i ;
334334 for (i = 0 ; i < label_count ; i ++ ) {
@@ -348,7 +348,7 @@ static readstat_error_t sav_skip_value_label_record(sav_ctx_t *ctx) {
348348 retval = READSTAT_ERROR_READ ;
349349 goto cleanup ;
350350 }
351- if (ctx -> machine_needs_byte_swap )
351+ if (ctx -> bswap )
352352 rec_type = byteswap4 (rec_type );
353353
354354 if (rec_type != 4 ) {
@@ -359,7 +359,7 @@ static readstat_error_t sav_skip_value_label_record(sav_ctx_t *ctx) {
359359 retval = READSTAT_ERROR_READ ;
360360 goto cleanup ;
361361 }
362- if (ctx -> machine_needs_byte_swap )
362+ if (ctx -> bswap )
363363 var_count = byteswap4 (var_count );
364364
365365 if (io -> seek (var_count * sizeof (int32_t ), READSTAT_SEEK_CUR , io -> io_ctx ) == -1 ) {
@@ -385,7 +385,7 @@ static readstat_error_t sav_submit_value_labels(value_label_t *value_labels, int
385385 if (value_type == READSTAT_TYPE_DOUBLE ) {
386386 double val_d = 0.0 ;
387387 memcpy (& val_d , vlabel -> value , 8 );
388- if (ctx -> machine_needs_byte_swap )
388+ if (ctx -> bswap )
389389 val_d = byteswap_double (val_d );
390390
391391 value .v .double_value = val_d ;
@@ -419,7 +419,7 @@ static readstat_error_t sav_read_value_label_record(sav_ctx_t *ctx) {
419419 retval = READSTAT_ERROR_READ ;
420420 goto cleanup ;
421421 }
422- if (ctx -> machine_needs_byte_swap )
422+ if (ctx -> bswap )
423423 label_count = byteswap4 (label_count );
424424
425425 if ((value_labels = malloc (label_count * sizeof (value_label_t ))) == NULL ) {
@@ -448,7 +448,7 @@ static readstat_error_t sav_read_value_label_record(sav_ctx_t *ctx) {
448448 retval = READSTAT_ERROR_READ ;
449449 goto cleanup ;
450450 }
451- if (ctx -> machine_needs_byte_swap )
451+ if (ctx -> bswap )
452452 rec_type = byteswap4 (rec_type );
453453
454454 if (rec_type != 4 ) {
@@ -459,7 +459,7 @@ static readstat_error_t sav_read_value_label_record(sav_ctx_t *ctx) {
459459 retval = READSTAT_ERROR_READ ;
460460 goto cleanup ;
461461 }
462- if (ctx -> machine_needs_byte_swap )
462+ if (ctx -> bswap )
463463 var_count = byteswap4 (var_count );
464464
465465 if ((vars = malloc (var_count * sizeof (int32_t ))) == NULL ) {
@@ -472,7 +472,7 @@ static readstat_error_t sav_read_value_label_record(sav_ctx_t *ctx) {
472472 }
473473 for (i = 0 ; i < var_count ; i ++ ) {
474474 int var_offset = vars [i ];
475- if (ctx -> machine_needs_byte_swap )
475+ if (ctx -> bswap )
476476 var_offset = byteswap4 (var_offset );
477477
478478 var_offset -- ; // Why subtract 1????
@@ -506,7 +506,7 @@ static readstat_error_t sav_skip_document_record(sav_ctx_t *ctx) {
506506 retval = READSTAT_ERROR_READ ;
507507 goto cleanup ;
508508 }
509- if (ctx -> machine_needs_byte_swap )
509+ if (ctx -> bswap )
510510 n_lines = byteswap4 (n_lines );
511511 if (io -> seek (n_lines * SPSS_DOC_LINE_SIZE , READSTAT_SEEK_CUR , io -> io_ctx ) == -1 ) {
512512 retval = READSTAT_ERROR_SEEK ;
@@ -528,7 +528,7 @@ static readstat_error_t sav_read_document_record(sav_ctx_t *ctx) {
528528 retval = READSTAT_ERROR_READ ;
529529 goto cleanup ;
530530 }
531- if (ctx -> machine_needs_byte_swap )
531+ if (ctx -> bswap )
532532 n_lines = byteswap4 (n_lines );
533533
534534 char raw_buffer [SPSS_DOC_LINE_SIZE ];
@@ -644,7 +644,7 @@ static readstat_error_t sav_process_row(unsigned char *buffer, size_t buffer_len
644644 }
645645 } else if (var_info -> type == READSTAT_TYPE_DOUBLE ) {
646646 memcpy (& fp_value , & buffer [data_offset ], 8 );
647- if (ctx -> machine_needs_byte_swap ) {
647+ if (ctx -> bswap ) {
648648 fp_value = byteswap_double (fp_value );
649649 }
650650 value .v .double_value = fp_value ;
@@ -706,8 +706,8 @@ static readstat_error_t sav_read_compressed_data(sav_ctx_t *ctx) {
706706 off_t uncompressed_offset = 0 ;
707707 unsigned char * uncompressed_row = malloc (uncompressed_row_len );
708708
709- int machine_needs_byte_swap = ctx -> machine_needs_byte_swap ;
710- ctx -> machine_needs_byte_swap = 0 ;
709+ int bswap = ctx -> bswap ;
710+ ctx -> bswap = 0 ;
711711
712712 while (1 ) {
713713 if (data_offset >= buffer_used ) {
@@ -772,7 +772,7 @@ static readstat_error_t sav_read_compressed_data(sav_ctx_t *ctx) {
772772 if (uncompressed_row )
773773 free (uncompressed_row );
774774
775- ctx -> machine_needs_byte_swap = machine_needs_byte_swap ;
775+ ctx -> bswap = bswap ;
776776
777777 return retval ;
778778}
@@ -785,7 +785,7 @@ static readstat_error_t sav_parse_machine_integer_info_record(const void *data,
785785 const char * dst_charset = ctx -> output_encoding ;
786786 sav_machine_integer_info_record_t record ;
787787 memcpy (& record , data , data_len );
788- if (ctx -> machine_needs_byte_swap ) {
788+ if (ctx -> bswap ) {
789789 record .character_code = byteswap4 (record .character_code );
790790 }
791791 if (ctx -> input_encoding ) {
@@ -823,9 +823,9 @@ static readstat_error_t sav_parse_machine_floating_point_record(const void *data
823823 sav_machine_floating_point_info_record_t fp_info ;
824824 memcpy (& fp_info , data , sizeof (sav_machine_floating_point_info_record_t ));
825825
826- ctx -> missing_double = ctx -> machine_needs_byte_swap ? byteswap8 (fp_info .sysmis ) : fp_info .sysmis ;
827- ctx -> highest_double = ctx -> machine_needs_byte_swap ? byteswap8 (fp_info .highest ) : fp_info .highest ;
828- ctx -> lowest_double = ctx -> machine_needs_byte_swap ? byteswap8 (fp_info .lowest ) : fp_info .lowest ;
826+ ctx -> missing_double = ctx -> bswap ? byteswap8 (fp_info .sysmis ) : fp_info .sysmis ;
827+ ctx -> highest_double = ctx -> bswap ? byteswap8 (fp_info .highest ) : fp_info .highest ;
828+ ctx -> lowest_double = ctx -> bswap ? byteswap8 (fp_info .lowest ) : fp_info .lowest ;
829829
830830 return READSTAT_OK ;
831831}
@@ -842,7 +842,7 @@ static readstat_error_t sav_store_variable_display_parameter_record(const void *
842842
843843 ctx -> variable_display_values_count = count ;
844844 for (i = 0 ; i < count ; i ++ ) {
845- ctx -> variable_display_values [i ] = ctx -> machine_needs_byte_swap ? byteswap4 (data_ptr [i ]) : data_ptr [i ];
845+ ctx -> variable_display_values [i ] = ctx -> bswap ? byteswap4 (data_ptr [i ]) : data_ptr [i ];
846846 }
847847 return READSTAT_OK ;
848848}
@@ -894,7 +894,7 @@ static readstat_error_t sav_parse_long_value_labels_record(const void *data, siz
894894 }
895895
896896 memcpy (& label_name_len , data_ptr , sizeof (int32_t ));
897- if (ctx -> machine_needs_byte_swap )
897+ if (ctx -> bswap )
898898 label_name_len = byteswap4 (label_name_len );
899899
900900 data_ptr += sizeof (int32_t );
@@ -934,7 +934,7 @@ static readstat_error_t sav_parse_long_value_labels_record(const void *data, siz
934934 }
935935
936936 memcpy (& label_count , data_ptr , sizeof (int32_t ));
937- if (ctx -> machine_needs_byte_swap )
937+ if (ctx -> bswap )
938938 label_count = byteswap4 (label_count );
939939
940940 data_ptr += sizeof (int32_t );
@@ -949,7 +949,7 @@ static readstat_error_t sav_parse_long_value_labels_record(const void *data, siz
949949 }
950950
951951 memcpy (& value_len , data_ptr , sizeof (int32_t ));
952- if (ctx -> machine_needs_byte_swap )
952+ if (ctx -> bswap )
953953 value_len = byteswap4 (value_len );
954954
955955 data_ptr += sizeof (int32_t );
@@ -978,7 +978,7 @@ static readstat_error_t sav_parse_long_value_labels_record(const void *data, siz
978978 }
979979
980980 memcpy (& label_len , data_ptr , sizeof (int32_t ));
981- if (ctx -> machine_needs_byte_swap )
981+ if (ctx -> bswap )
982982 label_len = byteswap4 (label_len );
983983
984984 data_ptr += sizeof (int32_t );
@@ -1030,7 +1030,7 @@ static readstat_error_t sav_parse_records_pass1(sav_ctx_t *ctx) {
10301030 goto cleanup ;
10311031 }
10321032
1033- if (ctx -> machine_needs_byte_swap ) {
1033+ if (ctx -> bswap ) {
10341034 rec_type = byteswap4 (rec_type );
10351035 }
10361036
@@ -1058,7 +1058,7 @@ static readstat_error_t sav_parse_records_pass1(sav_ctx_t *ctx) {
10581058 retval = READSTAT_ERROR_READ ;
10591059 goto cleanup ;
10601060 }
1061- if (ctx -> machine_needs_byte_swap ) {
1061+ if (ctx -> bswap ) {
10621062 for (i = 0 ; i < 3 ; i ++ )
10631063 extra_info [i ] = byteswap4 (extra_info [i ]);
10641064 }
@@ -1119,7 +1119,7 @@ static readstat_error_t sav_parse_records_pass2(sav_ctx_t *ctx) {
11191119 goto cleanup ;
11201120 }
11211121
1122- if (ctx -> machine_needs_byte_swap ) {
1122+ if (ctx -> bswap ) {
11231123 rec_type = byteswap4 (rec_type );
11241124 }
11251125
@@ -1150,7 +1150,7 @@ static readstat_error_t sav_parse_records_pass2(sav_ctx_t *ctx) {
11501150 retval = READSTAT_ERROR_READ ;
11511151 goto cleanup ;
11521152 }
1153- if (ctx -> machine_needs_byte_swap ) {
1153+ if (ctx -> bswap ) {
11541154 for (i = 0 ; i < 3 ; i ++ )
11551155 extra_info [i ] = byteswap4 (extra_info [i ]);
11561156 }
0 commit comments