summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/mspack/lzssd.c
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2020-06-08 21:44:02 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-08-07 22:18:41 +0200
commit729b6e4f33419489415a6111bb98e5d95221a338 (patch)
tree87e83604959f7d848e80287aa799900cd0a9f989 /rbutil/rbutilqt/mspack/lzssd.c
parentb0f22620a2dbfb991b10a8e1e8b0c8db5e3ee117 (diff)
downloadrockbox-729b6e4f33.tar.gz
rockbox-729b6e4f33.tar.bz2
rockbox-729b6e4f33.zip
rbutil: Update libmspack to 0.10.1alpha.
Update to the most recent release. Fix name / include clashes, as has been done before. Change-Id: Ia712bb2b5f4b9018b65a46b8bdd04ba42363be8b
Diffstat (limited to 'rbutil/rbutilqt/mspack/lzssd.c')
-rw-r--r--rbutil/rbutilqt/mspack/lzssd.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/rbutil/rbutilqt/mspack/lzssd.c b/rbutil/rbutilqt/mspack/lzssd.c
index f1a47c7a01..63716d414a 100644
--- a/rbutil/rbutilqt/mspack/lzssd.c
+++ b/rbutil/rbutilqt/mspack/lzssd.c
@@ -14,31 +14,31 @@
#include "system-mspack.h"
#include "lzss.h"
-#define ENSURE_BYTES do { \
- if (i_ptr >= i_end) { \
- read = system->read(input, &inbuf[0], \
- input_buffer_size); \
- if (read <= 0) { \
- system->free(window); \
- return (read < 0) ? MSPACK_ERR_READ \
- : MSPACK_ERR_OK; \
- } \
- i_ptr = &inbuf[0]; i_end = &inbuf[read]; \
- } \
+#define ENSURE_BYTES do { \
+ if (i_ptr >= i_end) { \
+ read = system->read(input, &inbuf[0], \
+ input_buffer_size); \
+ if (read <= 0) { \
+ system->free(window); \
+ return (read < 0) ? MSPACK_ERR_READ \
+ : MSPACK_ERR_OK; \
+ } \
+ i_ptr = &inbuf[0]; i_end = &inbuf[read]; \
+ } \
} while (0)
-#define WRITE_BYTE do { \
- if (system->write(output, &window[pos], 1) != 1) { \
- system->free(window); \
- return MSPACK_ERR_WRITE; \
- } \
+#define WRITE_BYTE do { \
+ if (system->write(output, &window[pos], 1) != 1) { \
+ system->free(window); \
+ return MSPACK_ERR_WRITE; \
+ } \
} while (0)
int lzss_decompress(struct mspack_system *system,
- struct mspack_file *input,
- struct mspack_file *output,
- int input_buffer_size,
- int mode)
+ struct mspack_file *input,
+ struct mspack_file *output,
+ int input_buffer_size,
+ int mode)
{
unsigned char *window, *inbuf, *i_ptr, *i_end;
unsigned int pos, i, c, invert, mpos, len;
@@ -48,7 +48,7 @@ int lzss_decompress(struct mspack_system *system,
if (!system || input_buffer_size < 1 || (mode != LZSS_MODE_EXPAND &&
mode != LZSS_MODE_MSHELP && mode != LZSS_MODE_QBASIC))
{
- return MSPACK_ERR_ARGS;
+ return MSPACK_ERR_ARGS;
}
/* allocate memory */
@@ -64,27 +64,27 @@ int lzss_decompress(struct mspack_system *system,
/* loop forever; exit condition is in ENSURE_BYTES macro */
for (;;) {
- ENSURE_BYTES; c = *i_ptr++ ^ invert;
- for (i = 0x01; i & 0xFF; i <<= 1) {
- if (c & i) {
- /* literal */
- ENSURE_BYTES; window[pos] = *i_ptr++;
- WRITE_BYTE;
- pos++; pos &= LZSS_WINDOW_SIZE - 1;
- }
- else {
- /* match */
- ENSURE_BYTES; mpos = *i_ptr++;
- ENSURE_BYTES; mpos |= (*i_ptr & 0xF0) << 4;
- len = (*i_ptr++ & 0x0F) + 3;
- while (len--) {
- window[pos] = window[mpos];
- WRITE_BYTE;
- pos++; pos &= LZSS_WINDOW_SIZE - 1;
- mpos++; mpos &= LZSS_WINDOW_SIZE - 1;
- }
- }
- }
+ ENSURE_BYTES; c = *i_ptr++ ^ invert;
+ for (i = 0x01; i & 0xFF; i <<= 1) {
+ if (c & i) {
+ /* literal */
+ ENSURE_BYTES; window[pos] = *i_ptr++;
+ WRITE_BYTE;
+ pos++; pos &= LZSS_WINDOW_SIZE - 1;
+ }
+ else {
+ /* match */
+ ENSURE_BYTES; mpos = *i_ptr++;
+ ENSURE_BYTES; mpos |= (*i_ptr & 0xF0) << 4;
+ len = (*i_ptr++ & 0x0F) + 3;
+ while (len--) {
+ window[pos] = window[mpos];
+ WRITE_BYTE;
+ pos++; pos &= LZSS_WINDOW_SIZE - 1;
+ mpos++; mpos &= LZSS_WINDOW_SIZE - 1;
+ }
+ }
+ }
}
/* not reached */