summaryrefslogtreecommitdiff
path: root/user/readstat/big-endian.patch
diff options
context:
space:
mode:
Diffstat (limited to 'user/readstat/big-endian.patch')
-rw-r--r--user/readstat/big-endian.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/user/readstat/big-endian.patch b/user/readstat/big-endian.patch
new file mode 100644
index 000000000..71f1db133
--- /dev/null
+++ b/user/readstat/big-endian.patch
@@ -0,0 +1,76 @@
+From 0034c8ee693563cbecae8fa8a24d3e8d5dcc6ab1 Mon Sep 17 00:00:00 2001
+From: Evan Miller <emmiller@gmail.com>
+Date: Sat, 4 May 2024 08:50:28 -0400
+Subject: [PATCH] [SAS7BCAT writer] big-endian architecture fix
+
+Closes #302
+---
+ src/sas/readstat_sas7bcat_write.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/sas/readstat_sas7bcat_write.c b/src/sas/readstat_sas7bcat_write.c
+index 6544798c..9642fdad 100644
+--- a/src/sas/readstat_sas7bcat_write.c
++++ b/src/sas/readstat_sas7bcat_write.c
+@@ -63,7 +63,8 @@ static sas7bcat_block_t *sas7bcat_block_for_label_set(readstat_label_set_t *r_la
+
+ for (j=0; j<r_label_set->value_labels_count; j++) {
+ readstat_value_label_t *value_label = readstat_get_value_label(r_label_set, j);
+- lbp1[2] = 24; // size - 6
++ int16_t value_entry_len = 24; // size - 6
++ memcpy(&lbp1[2], &value_entry_len, sizeof(int16_t));
+ int32_t index = j;
+ memcpy(&lbp1[10], &index, sizeof(int32_t));
+ if (r_label_set->type == READSTAT_TYPE_STRING) {
+@@ -86,7 +87,7 @@ static sas7bcat_block_t *sas7bcat_block_for_label_set(readstat_label_set_t *r_la
+ memcpy(&lbp2[8], &label_len, sizeof(int16_t));
+ memcpy(&lbp2[10], value_label->label, label_len);
+
+- lbp1 += 30;
++ lbp1 += 6 + value_entry_len;
+ lbp2 += 8 + 2 + value_label->label_len + 1;
+ }
+
+From 29aac3db79a5da20d1d1dcbb54a587c5ba51e7b3 Mon Sep 17 00:00:00 2001
+From: Evan Miller <emmiller@gmail.com>
+Date: Sat, 4 May 2024 10:35:27 -0400
+Subject: [PATCH] [SAS7BCAT writer] more big-endian fixes
+
+---
+ src/sas/readstat_sas7bcat_write.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/sas/readstat_sas7bcat_write.c b/src/sas/readstat_sas7bcat_write.c
+index 9642fda..c25fec0 100644
+--- a/src/sas/readstat_sas7bcat_write.c
++++ b/src/sas/readstat_sas7bcat_write.c
+@@ -46,7 +46,8 @@ static sas7bcat_block_t *sas7bcat_block_for_label_set(readstat_label_set_t *r_la
+ memcpy(&block->data[38], &count, sizeof(int32_t));
+ memcpy(&block->data[42], &count, sizeof(int32_t));
+ if (name_len > 8) {
+- block->data[2] = (char)0x80;
++ int16_t flags = 0x80;
++ memcpy(&block->data[2], &flags, sizeof(int16_t));
+ memcpy(&block->data[8], name, 8);
+
+ memset(&block->data[106], ' ', 32);
+@@ -139,16 +140,15 @@ static readstat_error_t sas7bcat_begin_data(void *writer_ctx) {
+
+ // Page 1
+ char *xlsr = &page[856];
+- int16_t block_idx, block_off;
+- block_idx = 4;
+- block_off = 16;
++ int32_t block_idx = 4;
++ int16_t block_off = 16;
+ for (i=0; i<writer->label_sets_count; i++) {
+ if (xlsr + 212 > page + hinfo->page_size)
+ break;
+
+ memcpy(&xlsr[0], "XLSR", 4);
+
+- memcpy(&xlsr[4], &block_idx, sizeof(int16_t));
++ memcpy(&xlsr[4], &block_idx, sizeof(int32_t));
+ memcpy(&xlsr[8], &block_off, sizeof(int16_t));
+
+ xlsr[50] = 'O';