diff options
author | sinanmohd <sinan@sinanmohd.com> | 2023-12-12 16:53:15 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2023-12-12 16:54:07 +0530 |
commit | 099de205b4bd9fe2081dd82ff19d6ab3b98e3c0d (patch) | |
tree | 74518d9a77732f2c43e1c61c9d4470b598adcda8 | |
parent | 8ccdf66d0179c8e275e20f74699e01686f0b166a (diff) |
lib/util: clean up
-rw-r--r-- | lib/util.lua | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/lib/util.lua b/lib/util.lua index 6263507..5b524bf 100644 --- a/lib/util.lua +++ b/lib/util.lua @@ -143,42 +143,42 @@ local error = function (str) end local opensubtitles_hash = function (fileName) - local fil = io.open(fileName, "rb") + local fil = io.open(fileName, "rb") if not fil then return nil end - local lo,hi = 0,0 - for i = 1,8192 do - local a,b,c,d = fil:read(4):byte(1,4) - lo = lo + a + b*256 + c*65536 + d*16777216 - a,b,c,d = fil:read(4):byte(1,4) - hi = hi + a + b*256 + c*65536 + d*16777216 - while lo >= 4294967296 do - lo = lo - 4294967296 - hi = hi + 1 - end - while hi >= 4294967296 do - hi = hi - 4294967296 - end - end - - local size = fil:seek("end", -65536) + 65536 - for i = 1,8192 do - local a,b,c,d = fil:read(4):byte(1,4) - lo = lo + a + b*256 + c*65536 + d*16777216 - a,b,c,d = fil:read(4):byte(1,4) - hi = hi + a + b*256 + c*65536 + d*16777216 - while lo >= 4294967296 do - lo = lo - 4294967296 - hi = hi + 1 - end - while hi >= 4294967296 do - hi = hi - 4294967296 - end - end - - lo = lo + size + local lo, hi = 0, 0 + for _ = 1, 8192 do + local a, b, c, d = fil:read(4):byte(1, 4) + lo = lo + a + b * 256 + c * 65536 + d * 16777216 + a, b, c, d = fil:read(4):byte(1, 4) + hi = hi + a + b * 256 + c * 65536 + d * 16777216 + while lo >= 4294967296 do + lo = lo - 4294967296 + hi = hi + 1 + end + while hi >= 4294967296 do + hi = hi - 4294967296 + end + end + + local size = fil:seek("end", -65536) + 65536 + for _ = 1, 8192 do + local a, b, c, d = fil:read(4):byte(1, 4) + lo = lo + a + b * 256 + c * 65536 + d * 16777216 + a, b, c, d = fil:read(4):byte(1, 4) + hi = hi + a + b * 256 + c * 65536 + d * 16777216 + while lo >= 4294967296 do + lo = lo - 4294967296 + hi = hi + 1 + end + while hi >= 4294967296 do + hi = hi - 4294967296 + end + end + + lo = lo + size while lo >= 4294967296 do lo = lo - 4294967296 hi = hi + 1 @@ -187,8 +187,8 @@ local opensubtitles_hash = function (fileName) hi = hi - 4294967296 end - fil:close() - return string.format("%08x%08x", hi,lo), size + fil:close() + return string.format("%08x%08x", hi, lo), size end return { |