Skip to content

Commit

Permalink
Test CI build with master version
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Jun 13, 2024
1 parent ec778f5 commit 430b30f
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 292 deletions.
10 changes: 1 addition & 9 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,7 @@ AS_CASE([$host],
AC_SUBST([EXTRA_LDFLAGS])

AS_CASE([$host],
[*mingw*],
[
#There is no real way to determine whether UCRT is used vs normal MINGW but one way is by checking a define in <windows.h>
#If we are in UCRT we do not want to set the spawnv define because it breaks the build
IS_UCRT=`echo '#include <windows.h>'| gcc -E -dM - | grep -i _UCRT | xargs`
AS_IF([test "$IS_UCRT" == ""], [
CFLAGS="$CFLAGS -D_spawnv=spawnv"
])
],
[*mingw*], [CFLAGS="$CFLAGS -D_spawnv=spawnv"],
[CFLAGS="$CFLAGS"])

AC_ARG_VAR([LIB_FUZZING_ENGINE], [Location of prebuilt fuzzing engine library])
Expand Down
4 changes: 2 additions & 2 deletions src/bin/read_csv/json_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "../../readstat.h"
#include "../util/file_format.h"

/* Function realloc_it() is a wrapper function for standard realloc()
/* Function realloc_it() is a wrapper function for standart realloc()
* with one difference - it frees old memory pointer in case of realloc
* failure. Thus, DO NOT use old data pointer in anyway after call to
* realloc_it(). If your code has some kind of fallback algorithm if
* memory can't be re-allocated - use standard realloc() instead.
* memory can't be re-allocated - use standart realloc() instead.
*/
static inline void *realloc_it(void *ptrmem, size_t size) {
void *p = realloc(ptrmem, size);
Expand Down
9 changes: 3 additions & 6 deletions src/bin/readstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ readstat_error_t parse_file(readstat_parser_t *parser, const char *input_filenam
return error;
}

static void print_version(void) {
static void print_version() {
fprintf(stdout, "ReadStat version " READSTAT_VERSION "\n");
}

Expand Down Expand Up @@ -397,21 +397,18 @@ static int convert_file(const char *input_filename, const char *catalog_filename
module->finish(rs_ctx->module_ctx);
}

free(rs_ctx);

if (error != READSTAT_OK) {
if (file_exists) {
fprintf(stderr, "Error opening %s: File exists (Use -f to overwrite)\n", output_filename);
} else {
fprintf(stderr, "Error processing %s: %s\n", rs_ctx->error_filename, readstat_error_message(error));
unlink(output_filename);
}

free(rs_ctx);

return 1;
}

free(rs_ctx);

return 0;
}

Expand Down
17 changes: 1 addition & 16 deletions src/readstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,11 @@ typedef enum readstat_error_e {
READSTAT_ERROR_TOO_FEW_COLUMNS,
READSTAT_ERROR_TOO_MANY_COLUMNS,
READSTAT_ERROR_NAME_IS_ZERO_LENGTH,
READSTAT_ERROR_BAD_TIMESTAMP_VALUE,
READSTAT_ERROR_BAD_MR_STRING
READSTAT_ERROR_BAD_TIMESTAMP_VALUE
} readstat_error_t;

const char *readstat_error_message(readstat_error_t error_code);

typedef struct mr_set_s {
char type;
char *name;
char *label;
int is_dichotomy;
int counted_value;
char **subvariables;
int num_subvars;
} mr_set_t;

typedef struct readstat_metadata_s {
int64_t row_count;
int64_t var_count;
Expand All @@ -132,8 +121,6 @@ typedef struct readstat_metadata_s {
const char *file_label;
const char *file_encoding;
unsigned int is64bit:1;
size_t multiple_response_sets_length;
mr_set_t *mr_sets;
} readstat_metadata_t;

/* If the row count is unknown (e.g. it's an XPORT or POR file, or an SAV
Expand All @@ -151,8 +138,6 @@ readstat_endian_t readstat_get_endianness(readstat_metadata_t *metadata);
const char *readstat_get_table_name(readstat_metadata_t *metadata);
const char *readstat_get_file_label(readstat_metadata_t *metadata);
const char *readstat_get_file_encoding(readstat_metadata_t *metadata);
const mr_set_t *readstat_get_mr_sets(readstat_metadata_t *metadata);
size_t readstat_get_multiple_response_sets_length(readstat_metadata_t *metadata);

typedef struct readstat_value_s {
union {
Expand Down
2 changes: 1 addition & 1 deletion src/readstat_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "readstat_bits.h"

int machine_is_little_endian(void) {
int machine_is_little_endian() {
int test_byte_order = 1;
return ((char *)&test_byte_order)[0];
}
Expand Down
8 changes: 0 additions & 8 deletions src/readstat_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,3 @@ const char *readstat_get_file_encoding(readstat_metadata_t *metadata) {
const char *readstat_get_table_name(readstat_metadata_t *metadata) {
return metadata->table_name;
}

size_t readstat_get_multiple_response_sets_length(readstat_metadata_t *metadata) {
return metadata->multiple_response_sets_length;
}

const mr_set_t *readstat_get_mr_sets(readstat_metadata_t *metadata) {
return metadata->mr_sets;
}
2 changes: 1 addition & 1 deletion src/readstat_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "readstat.h"
#include "readstat_io_unistd.h"

readstat_parser_t *readstat_parser_init(void) {
readstat_parser_t *readstat_parser_init() {
readstat_parser_t *parser = calloc(1, sizeof(readstat_parser_t));
parser->io = calloc(1, sizeof(readstat_io_t));
if (unistd_io_init(parser) != READSTAT_OK) {
Expand Down
2 changes: 1 addition & 1 deletion src/readstat_variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
static readstat_value_t make_blank_value(void);
static readstat_value_t make_double_value(double dval);

static readstat_value_t make_blank_value(void) {
static readstat_value_t make_blank_value() {
readstat_value_t value = { .is_system_missing = 1, .v = { .double_value = NAN }, .type = READSTAT_TYPE_DOUBLE };
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/readstat_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ readstat_string_ref_t *readstat_string_ref_init(const char *string) {
return ref;
}

readstat_writer_t *readstat_writer_init(void) {
readstat_writer_t *readstat_writer_init() {
readstat_writer_t *writer = calloc(1, sizeof(readstat_writer_t));

writer->variables = calloc(VARIABLES_INITIAL_CAPACITY, sizeof(readstat_variable_t *));
Expand Down
10 changes: 5 additions & 5 deletions src/sas/ieee.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int cnxptiee(const void *from_bytes, int fromtype, void *to_bytes, int totype)
return(0);
}

int get_native(void) {
int get_native() {
static unsigned char float_reps[][8] = {
{0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00},
{0x3f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00},
Expand Down Expand Up @@ -366,7 +366,7 @@ void ieee2xpt(unsigned char *ieee, unsigned char *xport) {
shift = (int)
(ieee_exp = (int)(((ieee1 >> 16) & 0x7ff0) >> 4) - 1023)
& 3;
/* the ieee format has an implied "1" immediately to the left */
/* the ieee format has an implied "1" immdeiately to the left */
/* of the binary point. Show it in here. */
xport1 |= 0x00100000;
if (shift)
Expand All @@ -377,7 +377,7 @@ void ieee2xpt(unsigned char *ieee, unsigned char *xport) {
/* from the lower half that would have been shifted in (if */
/* we could shift a double). The shift count can never */
/* exceed 3, so all we care about are the high order 3 */
/* bits. We don't want sign extension so make sure it's an */
/* bits. We don't want sign extention so make sure it's an */
/* unsigned char. We'll shift either5, 6, or 7 places to */
/* keep 3, 2, or 1 bits. After that, shift the second half */
/* of the number the right number of places. We always get */
Expand All @@ -391,9 +391,9 @@ void ieee2xpt(unsigned char *ieee, unsigned char *xport) {

/* Now set the ibm exponent and the sign of the fraction. The */
/* power of 2 ieee exponent must be divided by 4 and made */
/* excess 64 (we add 65 here because of the position of the */
/* excess 64 (we add 65 here because of the poisition of the */
/* fraction bits, essentially 4 positions lower than they */
/* should be so we increment the ibm exponent). */
/* should be so we incrment the ibm exponent). */

xport1 |=

Expand Down
26 changes: 8 additions & 18 deletions src/sas/readstat_sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,11 @@ static readstat_charset_entry_t _charset_table[] = {
{ .code = 248, .name = "SHIFT_JISX0213" },
};

static time_t sas_epoch(void) {
static time_t sas_epoch() {
return - 3653 * 86400; // seconds between 01-01-1960 and 01-01-1970
}

static time_t sas_convert_time(double time, double time_diff, time_t epoch) {
time -= time_diff;
static time_t sas_convert_time(double time, time_t epoch) {
time += epoch;
if (isnan(time))
return 0;
Expand Down Expand Up @@ -213,7 +212,7 @@ readstat_error_t sas_read_header(readstat_io_t *io, sas_header_info_t *hinfo,
goto cleanup;
}

double creation_time, modification_time, creation_time_diff, modification_time_diff;
double creation_time, modification_time;

if (io->read(&creation_time, sizeof(double), io->io_ctx) < sizeof(double)) {
retval = READSTAT_ERROR_READ;
Expand All @@ -229,22 +228,13 @@ readstat_error_t sas_read_header(readstat_io_t *io, sas_header_info_t *hinfo,
if (bswap)
modification_time = byteswap_double(modification_time);

if (io->read(&creation_time_diff, sizeof(double), io->io_ctx) < sizeof(double)) {
retval = READSTAT_ERROR_READ;
goto cleanup;
}
if (bswap)
creation_time_diff = byteswap_double(creation_time_diff);

if (io->read(&modification_time_diff, sizeof(double), io->io_ctx) < sizeof(double)) {
retval = READSTAT_ERROR_READ;
hinfo->creation_time = sas_convert_time(creation_time, epoch);
hinfo->modification_time = sas_convert_time(modification_time, epoch);

if (io->seek(16, READSTAT_SEEK_CUR, io->io_ctx) == -1) {
retval = READSTAT_ERROR_SEEK;
goto cleanup;
}
if (bswap)
modification_time_diff = byteswap_double(modification_time_diff);

hinfo->creation_time = sas_convert_time(creation_time, creation_time_diff, epoch);
hinfo->modification_time = sas_convert_time(modification_time, modification_time_diff, epoch);

uint32_t header_size, page_size;

Expand Down
2 changes: 1 addition & 1 deletion src/sas/readstat_xport_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static readstat_error_t xport_update_progress(xport_ctx_t *ctx) {
return io->update(ctx->file_size, ctx->handle.progress, ctx->user_ctx, io->io_ctx);
}

static xport_ctx_t *xport_ctx_init(void) {
static xport_ctx_t *xport_ctx_init() {
xport_ctx_t *ctx = calloc(1, sizeof(xport_ctx_t));
return ctx;
}
Expand Down
4 changes: 2 additions & 2 deletions src/sas/readstat_xport_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "readstat_xport_parse_format.h"
#include "ieee.h"

#define XPORT_DEFAULT_VERSION 8
#define XPORT_DEFAULT_VERISON 8
#define RECORD_LEN 80

#if defined _MSC_VER
Expand Down Expand Up @@ -531,7 +531,7 @@ static readstat_error_t xport_metadata_ok(void *writer_ctx) {
readstat_error_t readstat_begin_writing_xport(readstat_writer_t *writer, void *user_ctx, long row_count) {

if (writer->version == 0)
writer->version = XPORT_DEFAULT_VERSION;
writer->version = XPORT_DEFAULT_VERISON;

writer->callbacks.metadata_ok = &xport_metadata_ok;
writer->callbacks.write_int8 = &xport_write_int8;
Expand Down
2 changes: 1 addition & 1 deletion src/spss/readstat_por.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ uint16_t por_unicode_lookup[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0 };

por_ctx_t *por_ctx_init(void) {
por_ctx_t *por_ctx_init() {
por_ctx_t *ctx = calloc(1, sizeof(por_ctx_t));

ctx->space = ' ';
Expand Down
2 changes: 1 addition & 1 deletion src/spss/readstat_por_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static readstat_error_t por_write_string_field(readstat_writer_t *writer, por_wr
return por_write_string_field_n(writer, ctx, string, strlen(string));
}

static por_write_ctx_t *por_write_ctx_init(void) {
static por_write_ctx_t *por_write_ctx_init() {
por_write_ctx_t *ctx = calloc(1, sizeof(por_write_ctx_t));
uint16_t max_unicode = 0;
int i;
Expand Down
5 changes: 0 additions & 5 deletions src/spss/readstat_sav.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//

#include "readstat_spss.h"
#include "../readstat.h"

#pragma pack(push, 1)

Expand Down Expand Up @@ -101,9 +100,6 @@ typedef struct sav_ctx_s {
uint64_t lowest_double;
uint64_t highest_double;

size_t multiple_response_sets_length;
mr_set_t *mr_sets;

double bias;
int format_version;

Expand All @@ -121,7 +117,6 @@ typedef struct sav_ctx_s {

#define SAV_RECORD_SUBTYPE_INTEGER_INFO 3
#define SAV_RECORD_SUBTYPE_FP_INFO 4
#define SAV_RECORD_SUBTYPE_MULTIPLE_RESPONSE_SETS 7
#define SAV_RECORD_SUBTYPE_PRODUCT_INFO 10
#define SAV_RECORD_SUBTYPE_VAR_DISPLAY 11
#define SAV_RECORD_SUBTYPE_LONG_VAR_NAME 13
Expand Down
Loading

0 comments on commit 430b30f

Please sign in to comment.