--- /dev/null
+#******************************************************************************
+# @file Makefile.wat
+#******************************************************************************
+SRCDIR ?= $(CURDIR)
+VPATH := $(SRCDIR)
+
+CSRC := libxz/xz_crc32.c libxz/xz_crc64.c libxz/xz_dec_lzma2.c libxz/xz_dec_stream.c lib.c report.c unxz.c
+COBJ := $(subst /,\,$(CSRC:.c=.obj))
+
+INCDIR := $(subst /,\,$(SRCDIR))
+
+all: unxz.exe
+
+unxz.exe: $(COBJ)
+
+ wcl -fe=$@ $^
+
+%.obj: %.c
+
+ wcc -I$(INCDIR)\\include -fo=$@ $^
+
+clean:
+
+ for /r %%f in (*.obj) do ( if exist %%f ( del /q %%f ) )
+ if exist unxz.exe ( del /q unxz.exe )
#define RC_SHIFT_BITS 8
#define RC_MOVE_BITS 5
-#define RC_TOP_VALUE (1 << RC_TOP_BITS)
-#define RC_BIT_MODEL_TOTAL (1 << RC_BIT_MODEL_TOTAL_BITS)
+#define RC_BIT_MODEL_TOTAL (1LU << RC_BIT_MODEL_TOTAL_BITS)
+#define RC_TOP_VALUE (1LU << RC_TOP_BITS)
/*
* Maximum number of position states. A position state is the lowest pb
*/
#define REPS 4
-#endif /* _XZ_LZMA2_H */
\ No newline at end of file
+#endif /* _XZ_LZMA2_H */
/* Get pointer to literal coder probability array. */
static uint16_t *lzma_literal_probs (struct xz_dec_lzma2 *s) {
- uint32_t prev_byte = dict_get(&s->dict, 0);
+ uint32_t prev_byte = dict_get (&s->dict, 0);
uint32_t low = prev_byte >> (8 - s->lzma.lc);
uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc;
if (s->rc.in_pos < s->temp.size) {
s->temp.size -= s->rc.in_pos;
-
- memmove (s->temp.buf, s->temp.buf + s->rc.in_pos,
- s->temp.size);
-
+
+ memmove (s->temp.buf, s->temp.buf + s->rc.in_pos, s->temp.size);
return 1;
}
}
memcpy (s->temp.buf, b->in + b->in_pos, in_avail);
- s->temp.size = in_avail;
+ s->temp.size = in_avail;
b->in_pos += in_avail;
}
}
memzero (s, sizeof (*s));
-
+
s->dict.mode = mode;
s->dict.size_max = dict_max;
}
- memzero (s->dict.buf, sizeof (dict_max));
+ memzero (s->dict.buf, dict_max);
} else if (DEC_IS_DYNALLOC (mode)) {
enum xz_ret xz_dec_lzma2_reset (struct xz_dec_lzma2 *s, uint8_t props) {
- /* This limits dictionary size to 3 GiB to keep parsing simpler. */
+#if defined (__WATCOMC__)
+ if (props > 18) {
+#else
if (props > 39) {
+#endif
return XZ_OPTIONS_ERROR;
}
}
- memzero (s->dict.buf, sizeof (s->dict.size));
+ memzero (s->dict.buf, s->dict.size);
}
if (DEC_IS_MULTI (s->dict.mode)) {
free (s->dict.buf);
}
-
+
free (s);
}
/* Uncompressed Size */
if (s->temp.buf[1] & 0x80) {
- if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size) != XZ_STREAM_END) {
+ if (dec_vli (s, s->temp.buf, &s->temp.pos, s->temp.size) != XZ_STREAM_END) {
return XZ_DATA_ERROR;
}
s->block_header.uncompressed = (uint64_t) -1;
}
-#ifdef XZ_DEC_BCJ
- /* If there are two filters, the first one must be a BCJ filter. */
- s->bcj_active = s->temp.buf[1] & 0x01;
- if (s->bcj_active) {
- if (s->temp.size - s->temp.pos < 2)
- return XZ_OPTIONS_ERROR;
-
- ret = xz_dec_bcj_reset(s->bcj, s->temp.buf[s->temp.pos++]);
- if (ret != XZ_OK)
- return ret;
-
- /*
- * We don't support custom start offset,
- * so Size of Properties must be zero.
- */
- if (s->temp.buf[s->temp.pos++] != 0x00)
- return XZ_OPTIONS_ERROR;
- }
-#endif
-
/* Valid Filter Flags always take at least two bytes. */
if (s->temp.size - s->temp.pos < 2) {
return XZ_DATA_ERROR;
memzero (s, sizeof (*s));
s->mode = mode;
-#ifdef XZ_DEC_BCJ
- s->bcj = xz_dec_bcj_create(DEC_IS_SINGLE(mode));
- if (s->bcj == NULL)
- goto error_bcj;
-#endif
-
if (!(s->lzma2 = xz_dec_lzma2_create (mode, dict_max))) {
goto error_lzma2;
}