Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/f78b31a36b5b49afbdea199269319faca261c898

>---------------------------------------------------------------

commit f78b31a36b5b49afbdea199269319faca261c898
Author: Paolo Capriotti <[email protected]>
Date:   Mon Aug 13 12:48:29 2012 +0100

    Fix ambiguous flag resolution (#7138)
    
    Pick longest flag when more than one matches in findArg.
    
    This fixes an issue where -ignore-dot-ghci wasn't honored, because the
    flag was parsed as "-i gnore-dot-ghci".

>---------------------------------------------------------------

 compiler/main/CmdLineParser.hs |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/compiler/main/CmdLineParser.hs b/compiler/main/CmdLineParser.hs
index c6d07ce..f87039a 100644
--- a/compiler/main/CmdLineParser.hs
+++ b/compiler/main/CmdLineParser.hs
@@ -27,6 +27,7 @@ import Panic
 import Bag
 import SrcLoc
 
+import Data.Function
 import Data.List
 
 
@@ -194,11 +195,12 @@ processOneArg opt_kind rest arg args
 
 findArg :: [Flag m] -> String -> Maybe (String, OptKind m)
 findArg spec arg =
-    case [ (removeSpaces rest, optKind)
-         | flag <- spec,
-           let optKind  = flagOptKind flag,
-           Just rest <- [stripPrefix (flagName flag) arg],
-           arg_ok optKind rest arg ]
+    case sortBy (compare `on` (length . fst)) -- prefer longest matching flag
+           [ (removeSpaces rest, optKind)
+           | flag <- spec,
+             let optKind  = flagOptKind flag,
+             Just rest <- [stripPrefix (flagName flag) arg],
+             arg_ok optKind rest arg ]
     of
         []      -> Nothing
         (one:_) -> Just one



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to