Commit 70b50778 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot
Browse files

SysTools: Ensure that error parser can handle absolute paths on Windows

This fixes #17786, where the error parser fails to correctly handle the
drive name in absolute Windows paths.

Unfortunately I couldn't find a satisfactory way to test this.
parent 5b627813
...@@ -344,10 +344,21 @@ parseError s0 = case breakColon s0 of ...@@ -344,10 +344,21 @@ parseError s0 = case breakColon s0 of
Nothing -> Nothing Nothing -> Nothing
Nothing -> Nothing Nothing -> Nothing
-- | Break a line of an error message into a filename and the rest of the line,
-- taking care to ignore colons in Windows drive letters (as noted in #17786).
-- For instance,
--
-- * @"hi.c: ABCD"@ is mapped to @Just ("hi.c", "ABCD")@
-- * @"C:\hi.c: ABCD"@ is mapped to @Just ("C:\hi.c", "ABCD")@
breakColon :: String -> Maybe (String, String) breakColon :: String -> Maybe (String, String)
breakColon xs = case break (':' ==) xs of breakColon = go []
(ys, _:zs) -> Just (ys, zs) where
_ -> Nothing -- Don't break on Windows drive letters (e.g. @C:\@ or @C:/@)
go accum (':':'\\':rest) = go ('\\':':':accum) rest
go accum (':':'/':rest) = go ('/':':':accum) rest
go accum (':':rest) = Just (reverse accum, rest)
go accum (c:rest) = go (c:accum) rest
go _accum [] = Nothing
breakIntColon :: String -> Maybe (Int, String) breakIntColon :: String -> Maybe (Int, String)
breakIntColon xs = case break (':' ==) xs of breakIntColon xs = case break (':' ==) xs of
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment