Don't crash on empty files with -f gcc.

This commit is contained in:
Vidar Holen 2014-09-23 10:11:15 -07:00
parent 40ce949a56
commit 6b84b35ec0
1 changed files with 6 additions and 1 deletions

View File

@ -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 =