From: Michael Orlitzky Date: Sun, 2 May 2010 21:08:23 +0000 (-0400) Subject: Don't validate the CIDR strings; rather, check whether the type of the returned Cidrs... X-Git-Tag: 0.0.1~74 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=78e436a8b3548f41f6c9bfd1db1b318a010f1472;p=hath.git Don't validate the CIDR strings; rather, check whether the type of the returned Cidrs is Cidr.None. --- diff --git a/src/Main.hs b/src/Main.hs index a86eebf..2fdcfd0 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -3,8 +3,7 @@ import System.Exit (ExitCode(..), exitWith) import System.IO (stderr, hPutStrLn) import Cidr (Cidr(..), - cidr_from_string, - is_valid_cidr) + cidr_from_string) import CommandLine (help_set, help_text, @@ -81,18 +80,6 @@ numeric_range x y = upper = maximum [x,y] --- Take a CIDR String, and exit with a failure if it's invalid. -validate_or_die :: String -> IO () -validate_or_die cidr = do - if (Cidr.is_valid_cidr cidr) - then do - return () - else do - putStrLn "Error: not valid CIDR notation." - exitWith (ExitFailure exit_invalid_cidr) - - - main :: IO () main = do -- First, check for any errors that occurred while parsing @@ -119,9 +106,14 @@ main = do input <- inputfunc let cidr_strings = lines input - mapM validate_or_die cidr_strings let cidrs = map Cidr.cidr_from_string cidr_strings + if (any (== Cidr.None) cidrs) + then do + putStrLn "Error: not valid CIDR notation." + exitWith (ExitFailure exit_invalid_cidr) + else do -- Nothing + -- Get the mode of operation. mode <- CommandLine.parse_mode