[project @ 2000-06-20 15:26:34 by simonmar]
authorsimonmar <unknown>
Tue, 20 Jun 2000 15:26:34 +0000 (15:26 +0000)
committersimonmar <unknown>
Tue, 20 Jun 2000 15:26:34 +0000 (15:26 +0000)
remove duplicates from the list of ways, so that eg. ghc -prof -prof
is legal.

ghc/driver/Main.hs

index ca58366..d065d2d 100644 (file)
@@ -1629,13 +1629,13 @@ opts =
   ,  ( "no-recomp"     , NoArg (writeIORef recomp False) )
 
        ------- ways --------------------------------------------------------
-  ,  ( "prof"          , NoArg (add ways WayProf) )
-  ,  ( "unreg"         , NoArg (add ways WayUnreg) )
-  ,  ( "ticky"         , NoArg (add ways WayTicky) )
-  ,  ( "parallel"      , NoArg (add ways WayPar) )
-  ,  ( "gransim"       , NoArg (add ways WayGran) )
-  ,  ( "smp"           , NoArg (add ways WaySMP) )
-  ,  ( "debug"         , NoArg (add ways WayDebug) )
+  ,  ( "prof"          , NoArg (addNoDups ways WayProf) )
+  ,  ( "unreg"         , NoArg (addNoDups ways WayUnreg) )
+  ,  ( "ticky"         , NoArg (addNoDups ways WayTicky) )
+  ,  ( "parallel"      , NoArg (addNoDups ways WayPar) )
+  ,  ( "gransim"       , NoArg (addNoDups ways WayGran) )
+  ,  ( "smp"           , NoArg (addNoDups ways WaySMP) )
+  ,  ( "debug"         , NoArg (addNoDups ways WayDebug) )
        -- ToDo: user ways
 
        ------- Interface files ---------------------------------------------
@@ -1947,6 +1947,11 @@ add var x = do
   xs <- readIORef var
   writeIORef var (x:xs)
 
+addNoDups :: Eq a => IORef [a] -> a -> IO ()
+addNoDups var x = do
+  xs <- readIORef var
+  if x `elem` xs then return () else writeIORef var (x:xs)
+
 remove_suffix :: String -> Char -> String
 remove_suffix s c 
   | null pre  = reverse suf