mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-31 03:50:49 -07:00
Don't crash on empty files with -f gcc.
This commit is contained in:
parent
40ce949a56
commit
6b84b35ec0
1 changed files with 6 additions and 1 deletions
|
@ -237,7 +237,12 @@ makeNonVirtual comments contents =
|
||||||
map fix comments
|
map fix comments
|
||||||
where
|
where
|
||||||
ls = lines contents
|
ls = lines contents
|
||||||
fix c = c { scColumn = real (ls !! (scLine c - 1)) 0 0 (scColumn c) }
|
fix c = c {
|
||||||
|
scColumn =
|
||||||
|
if scLine c > 0 && scLine c <= length ls
|
||||||
|
then real (ls !! (scLine c - 1)) 0 0 (scColumn c)
|
||||||
|
else scColumn c
|
||||||
|
}
|
||||||
real _ r v target | target <= v = r
|
real _ r v target | target <= v = r
|
||||||
real [] r v _ = r -- should never happen
|
real [] r v _ = r -- should never happen
|
||||||
real ('\t':rest) r v target =
|
real ('\t':rest) r v target =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue