diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-04-08 12:28:54 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-04-08 12:28:54 +0200 |
commit | ea2466fe69bd082d379e95e1567f3de0b76de243 (patch) | |
tree | 70f1bdcf7d402f2ae013caebf5f4cef5f6c2baed /tex/context/base/mkiv/util-fil.lua | |
parent | e32f57c9c5968f0c09130f6e24e28a96d6e1393d (diff) | |
download | context-ea2466fe69bd082d379e95e1567f3de0b76de243.tar.gz |
2017-04-08 12:15:00
Diffstat (limited to 'tex/context/base/mkiv/util-fil.lua')
-rw-r--r-- | tex/context/base/mkiv/util-fil.lua | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/tex/context/base/mkiv/util-fil.lua b/tex/context/base/mkiv/util-fil.lua index cb36db7be..de3c999b7 100644 --- a/tex/context/base/mkiv/util-fil.lua +++ b/tex/context/base/mkiv/util-fil.lua @@ -100,7 +100,6 @@ end function files.readinteger1(f) -- one byte local n = byte(f:read(1)) if n >= 0x80 then - -- return n - 0xFF - 1 return n - 0x100 else return n @@ -133,11 +132,10 @@ end function files.readinteger2le(f) local b, a = byte(f:read(2),1,2) - local n = 0x100 * a + b - if n >= 0x8000 then - return n - 0x10000 + if a >= 0x80 then + return 0x100 * a + b - 0x10000 else - return n + return 0x100 * a + b end end @@ -153,21 +151,19 @@ end function files.readinteger3(f) local a, b, c = byte(f:read(3),1,3) - local n = 0x10000 * a + 0x100 * b + c - if n >= 0x80000 then - return n - 0x1000000 + if a >= 0x80 then + return 0x10000 * a + 0x100 * b + c - 0x1000000 else - return n + return 0x10000 * a + 0x100 * b + c end end function files.readinteger3le(f) local c, b, a = byte(f:read(3),1,3) - local n = 0x10000 * a + 0x100 * b + c - if n >= 0x80000 then - return n - 0x1000000 + if a >= 0x80 then + return 0x10000 * a + 0x100 * b + c - 0x1000000 else - return n + return 0x10000 * a + 0x100 * b + c end end @@ -192,11 +188,10 @@ end function files.readinteger4le(f) local d, c, b, a = byte(f:read(4),1,4) - local n = 0x1000000 * a + 0x10000 * b + 0x100 * c + d - if n >= 0x8000000 then - return n - 0x100000000 + if a >= 0x80 then + return 0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000 else - return n + return 0x1000000 * a + 0x10000 * b + 0x100 * c + d end end |