diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-03-01 13:51:17 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-03-01 13:51:17 +0100 |
commit | 0da55392b876cef55845157c4bfb8244d84c6450 (patch) | |
tree | a050eef10e2790e286b94dcfeae1aacc657b025b /tex/context/base/mkiv/util-sac.lua | |
parent | a616b343d8dfe81008c9e8aee253cf31f088f35b (diff) | |
download | context-0da55392b876cef55845157c4bfb8244d84c6450.tar.gz |
2017-03-01 13:47:00
Diffstat (limited to 'tex/context/base/mkiv/util-sac.lua')
-rw-r--r-- | tex/context/base/mkiv/util-sac.lua | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tex/context/base/mkiv/util-sac.lua b/tex/context/base/mkiv/util-sac.lua index 5d16be3ec..1a52bfc58 100644 --- a/tex/context/base/mkiv/util-sac.lua +++ b/tex/context/base/mkiv/util-sac.lua @@ -82,6 +82,13 @@ function streams.readbytes(f,n) return byte(f[1],i,j-1) end +function streams.readbytetable(f,n) + local i = f[2] + local j = i + n + f[2] = j + return { byte(f[1],i,j-1) } +end + function streams.skipbytes(f,n) f[2] = f[2] + n end @@ -104,7 +111,8 @@ function streams.readinteger1(f) -- one byte f[2] = i + 1 local n = byte(f[1],i) if n >= 0x80 then - return n - 0xFF - 1 + -- return n - 0xFF - 1 + return n - 0x100 else return n end @@ -129,7 +137,8 @@ function streams.readinteger2(f) local a, b = byte(f[1],i,j) local n = 0x100 * a + b if n >= 0x8000 then - return n - 0xFFFF - 1 + -- return n - 0xFFFF - 1 + return n - 0x10000 else return n end @@ -158,7 +167,8 @@ function streams.readinteger4(f) local a, b, c, d = byte(f[1],i,j) local n = 0x1000000 * a + 0x10000 * b + 0x100 * c + d if n >= 0x8000000 then - return n - 0xFFFFFFFF - 1 + -- return n - 0xFFFFFFFF - 1 + return n - 0x100000000 else return n end @@ -171,7 +181,8 @@ function streams.readfixed4(f) local a, b, c, d = byte(f[1],i,j) local n = 0x100 * a + b if n >= 0x8000 then - return n - 0xFFFF - 1 + (0x100 * c + d)/0xFFFF + -- return n - 0xFFFF - 1 + (0x100 * c + d)/0xFFFF + return n - 0x10000 + (0x100 * c + d)/0xFFFF else return n + (0x100 * c + d)/0xFFFF end |