diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-02-17 10:31:56 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-02-17 10:31:56 +0100 |
commit | b14f992ef5f4e868c9959b174278c86516d60dbc (patch) | |
tree | 28587bb46c025ea7b0d27ba93f09c93dcf53c73a /tex/context/base/mkiv/util-fil.lua | |
parent | 95a1799032dc61dbca4a11e495be34b4397c8fec (diff) | |
download | context-b14f992ef5f4e868c9959b174278c86516d60dbc.tar.gz |
2017-02-17 10:23:00
Diffstat (limited to 'tex/context/base/mkiv/util-fil.lua')
-rw-r--r-- | tex/context/base/mkiv/util-fil.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tex/context/base/mkiv/util-fil.lua b/tex/context/base/mkiv/util-fil.lua index 0f9731a26..cf97d9541 100644 --- a/tex/context/base/mkiv/util-fil.lua +++ b/tex/context/base/mkiv/util-fil.lua @@ -93,7 +93,7 @@ end function files.readinteger1(f) -- one byte local n = byte(f:read(1)) - if n >= 0x80 then + if n >= 0x80 then -- return n - 0xFF - 1 return n - 0x100 else @@ -124,6 +124,14 @@ function files.readinteger2(f) return n end end + function files.readinteger2(f) + local a, b = byte(f:read(2),1,2) + if a >= 0x80 then + return 0x100 * a + b - 0x10000 + else + return 0x100 * a + b + end + end function files.readinteger2le(f) local b, a = byte(f:read(2),1,2) local n = 0x100 * a + b @@ -184,6 +192,14 @@ function files.readinteger4(f) return n end end + function files.readinteger4(f) + local a, b, c, d = byte(f:read(4),1,4) + if a >= 0x80 then + return 0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000 + else + return 0x1000000 * a + 0x10000 * b + 0x100 * c + d + end + 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 |