Skip to content

Commit 4aeb7bd

Browse files
committed
Handle \r when reading cache
Caches are read and written in binary mode (no \r even on Windows). However, depending on git settings cache samples may use it anyway. Fixes remaining tests for Windows.
1 parent e305521 commit 4aeb7bd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/luacheck/cache.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ local function load_cached(cached)
184184
end
185185

186186
local function check_version_header(fh)
187-
return fh:read() == "" and tonumber(fh:read()) == cache.format_version
187+
local first_line = fh:read()
188+
189+
return (first_line == "" or first_line == "\r") and tonumber(fh:read()) == cache.format_version
188190
end
189191

190192
local function write_version_header(fh)
@@ -217,6 +219,10 @@ function cache.load(cache_filename, filenames, mtimes)
217219
return result
218220
end
219221

222+
if filename:sub(-1) == "\r" then
223+
filename = filename:sub(1, -2)
224+
end
225+
220226
local mtime = fh:read()
221227
local cached = fh:read()
222228

0 commit comments

Comments
 (0)