Skip to content

Commit

Permalink
SAS reader: Improved support for RLE decompression
Browse files Browse the repository at this point in the history
Fixes #245
Fixes #253
  • Loading branch information
evanmiller committed Jan 15, 2023
1 parent 4827d6d commit c286728
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sas/readstat_sas_rle.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ typedef SSIZE_T ssize_t;
#include "readstat_sas_rle.h"

#define SAS_RLE_COMMAND_COPY64 0
#define SAS_RLE_COMMAND_COPY64_PLUS_4096 1
#define SAS_RLE_COMMAND_COPY96 2
#define SAS_RLE_COMMAND_INSERT_BYTE18 4
#define SAS_RLE_COMMAND_INSERT_AT17 5
#define SAS_RLE_COMMAND_INSERT_BLANK17 6
Expand All @@ -29,6 +31,7 @@ typedef SSIZE_T ssize_t;

static size_t command_lengths[16] = {
[SAS_RLE_COMMAND_COPY64] = 1,
[SAS_RLE_COMMAND_COPY64_PLUS_4096] = 1,
[SAS_RLE_COMMAND_INSERT_BYTE18] = 2,
[SAS_RLE_COMMAND_INSERT_AT17] = 1,
[SAS_RLE_COMMAND_INSERT_BLANK17] = 1,
Expand Down Expand Up @@ -62,6 +65,10 @@ ssize_t sas_rle_decompress(void *output_buf, size_t output_len,
case SAS_RLE_COMMAND_COPY64:
copy_len = (*input++) + 64 + length * 256;
break;
case SAS_RLE_COMMAND_COPY64_PLUS_4096:
copy_len = (*input++) + 64 + length * 256 + 4096;
break;
case SAS_RLE_COMMAND_COPY96: copy_len = length + 96; break;
case SAS_RLE_COMMAND_INSERT_BYTE18:
insert_len = (*input++) + 18 + length * 256;
insert_byte = *input++;
Expand Down

0 comments on commit c286728

Please sign in to comment.