aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util.lua68
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 {