script: Fix script scanner endianness

The script interpreter was reading the length of compressed data as
an host-endian uint32_t, thus making cairo-script able to correctly
read traces that were produced on the same endianness as the one they
ran upon, but unsuitable for portabile cairo-scripts.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Andrea Canciani 2010-02-05 22:30:05 +01:00
parent 4f617eaf77
commit 55ce0b7748

View file

@ -43,6 +43,20 @@
#define DEBUG_SCAN 0
#if WORDS_BIGENDIAN
#define le16(x) bswap_16 (x)
#define le32(x) bswap_32 (x)
#define be16(x) x
#define be32(x) x
#define to_be32(x) x
#else
#define le16(x) x
#define le32(x) x
#define be16(x) bswap_16 (x)
#define be32(x) bswap_32 (x)
#define to_be32(x) bswap_32 (x)
#endif
/*
* whitespace:
* 0 - nul
@ -639,7 +653,7 @@ base85_end (csi_t *ctx, csi_scanner_t *scan, cairo_bool_t deflate)
}
if (deflate) {
uLongf len = *(uint32_t *) scan->buffer.base;
uLongf len = be32 (*(uint32_t *) scan->buffer.base);
Bytef *source = (Bytef *) (scan->buffer.base + sizeof (uint32_t));
status = csi_string_deflate_new (ctx, &obj,
@ -766,20 +780,6 @@ scan_read (csi_scanner_t *scan, csi_file_t *src, void *ptr, int len)
} while (_csi_unlikely (len));
}
#if WORDS_BIGENDIAN
#define le16(x) bswap_16 (x)
#define le32(x) bswap_32 (x)
#define be16(x) x
#define be32(x) x
#define to_be32(x) x
#else
#define le16(x) x
#define le32(x) x
#define be16(x) bswap_16 (x)
#define be32(x) bswap_32 (x)
#define to_be32(x) bswap_32 (x)
#endif
static void
string_read (csi_t *ctx,
csi_scanner_t *scan,