Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/sas/readstat_xport_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,10 @@ static readstat_error_t xport_metadata_ok(void *writer_ctx) {
return READSTAT_OK;
}

static readstat_error_t xport_v5_validate_variable(const readstat_variable_t *variable) {
return sas_validate_name(readstat_variable_get_name(variable), 8);
}

readstat_error_t readstat_begin_writing_xport(readstat_writer_t *writer, void *user_ctx, long row_count) {

if (writer->version == 0)
Expand All @@ -555,7 +559,11 @@ readstat_error_t readstat_begin_writing_xport(readstat_writer_t *writer, void *u
writer->callbacks.write_missing_tagged = &xport_write_missing_tagged;

writer->callbacks.variable_width = &xport_variable_width;
writer->callbacks.variable_ok = &sas_validate_variable;
if (writer->version == 5) {
writer->callbacks.variable_ok = &xport_v5_validate_variable;
} else {
writer->callbacks.variable_ok = &sas_validate_variable;
}

writer->callbacks.begin_data = &xport_begin_data;
writer->callbacks.end_data = &xport_end_data;
Expand Down
11 changes: 11 additions & 0 deletions src/test/test_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,17 @@ static rt_test_group_t _test_groups[] = {
}
}
},
{
.label = "XPORT v5 column name is too long",
.write_error = READSTAT_ERROR_NAME_IS_TOO_LONG,
.test_formats = RT_FORMAT_XPORT_5,
.columns = {
{
.name = "VAR123456",
.type = READSTAT_TYPE_DOUBLE
}
}
},
{
.label = "POR column name is too long",
.write_error = READSTAT_ERROR_NAME_IS_TOO_LONG,
Expand Down
Loading