diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-07-31 08:54:53 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-07-31 08:54:53 +0200 |
commit | a497e6451cc2b8244395d2abb3e7a3c6a49fe0b2 (patch) | |
tree | a8e3be993111a035e5818291bf8412516c0a1160 | |
parent | 198e5da752e36bf1b11d09b7f2c134783725a0b5 (diff) | |
download | ghdl-a497e6451cc2b8244395d2abb3e7a3c6a49fe0b2.tar.gz ghdl-a497e6451cc2b8244395d2abb3e7a3c6a49fe0b2.tar.bz2 ghdl-a497e6451cc2b8244395d2abb3e7a3c6a49fe0b2.zip |
Check missing argument for -P, also support -P=
Fixes #103
-rw-r--r-- | src/options.adb | 56 | ||||
-rw-r--r-- | src/options.ads | 2 |
2 files changed, 36 insertions, 22 deletions
diff --git a/src/options.adb b/src/options.adb index 8f02e3712..341a7125b 100644 --- a/src/options.adb +++ b/src/options.adb @@ -17,6 +17,7 @@ -- 02111-1307, USA. with Ada.Text_IO; use Ada.Text_IO; with Name_Table; +with Errorout; with Libraries; with Std_Names; with PSL.Nodes; @@ -65,46 +66,59 @@ package body Options is return True; end Option_Warning; - function Parse_Option (Opt: String) return Boolean + function Parse_Option (Option : String) return Boolean is - Beg: constant Integer := Opt'First; + subtype Option_String is String (1 .. Option'Length); + Opt : Option_String renames Option; begin - if Opt'Length > 5 and then Opt (Beg .. Beg + 5) = "--std=" then + if Opt'Last > 5 and then Opt (1 .. 6) = "--std=" then if Opt'Length = 8 then - if Opt (Beg + 6 .. Beg + 7) = "87" then + if Opt (7 .. 8) = "87" then Vhdl_Std := Vhdl_87; - elsif Opt (Beg + 6 .. Beg + 7) = "93" then + elsif Opt (7 .. 8) = "93" then Vhdl_Std := Vhdl_93; - elsif Opt (Beg + 6 .. Beg + 7) = "00" then + elsif Opt (7 .. 8) = "00" then Vhdl_Std := Vhdl_00; - elsif Opt (Beg + 6 .. Beg + 7) = "02" then + elsif Opt (7 .. 8) = "02" then Vhdl_Std := Vhdl_02; - elsif Opt (Beg + 6 .. Beg + 7) = "08" then + elsif Opt (7 .. 8) = "08" then Vhdl_Std := Vhdl_08; else return False; end if; - elsif Opt'Length = 9 and then Opt (Beg + 6 .. Beg + 8) = "93c" then + elsif Opt'Length = 9 and then Opt (7 .. 9) = "93c" then Vhdl_Std := Vhdl_93c; else return False; end if; - elsif Opt'Length = 5 and then Opt (Beg .. Beg + 4) = "--ams" then + elsif Opt'Length = 5 and then Opt (1 .. 5) = "--ams" then AMS_Vhdl := True; - elsif Opt'Length > 2 and then Opt (Beg .. Beg + 1) = "-P" then - Libraries.Add_Library_Path (Opt (Beg + 2 .. Opt'Last)); - elsif Opt'Length > 10 and then Opt (Beg .. Beg + 9) = "--workdir=" then - Libraries.Set_Work_Library_Path (Opt (Beg + 10 .. Opt'Last)); - elsif Opt'Length > 10 and then Opt (Beg .. Beg + 9) = "--warn-no-" then - return Option_Warning (Opt (Beg + 10 .. Opt'Last), False); - elsif Opt'Length > 7 and then Opt (Beg .. Beg + 6) = "--warn-" then - return Option_Warning (Opt (Beg + 7 .. Opt'Last), True); - elsif Opt'Length > 7 and then Opt (Beg .. Beg + 6) = "--work=" then + elsif Opt'Length >= 2 and then Opt (1 .. 2) = "-P" then + if Opt'Last = 2 then + Errorout.Error_Msg_Option ("missing directory after -P"); + return True; + end if; + if Opt (3) = '=' then + if Opt'Last = 3 then + Errorout.Error_Msg_Option ("missing directory after -P="); + return True; + end if; + Libraries.Add_Library_Path (Opt (4 .. Opt'Last)); + else + Libraries.Add_Library_Path (Opt (3 .. Opt'Last)); + end if; + elsif Opt'Length > 10 and then Opt (1 .. 10) = "--workdir=" then + Libraries.Set_Work_Library_Path (Opt (11 .. Opt'Last)); + elsif Opt'Length > 10 and then Opt (1 .. 10) = "--warn-no-" then + return Option_Warning (Opt (11 .. Opt'Last), False); + elsif Opt'Length > 7 and then Opt (1 .. 7) = "--warn-" then + return Option_Warning (Opt (8 .. Opt'Last), True); + elsif Opt'Length > 7 and then Opt (1 .. 7) = "--work=" then declare use Name_Table; begin - Nam_Length := Opt'Last - (Beg + 7) + 1; - Nam_Buffer (1 .. Nam_Length) := Opt (Beg + 7 .. Opt'Last); + Nam_Length := Opt'Last - 8 + 1; + Nam_Buffer (1 .. Nam_Length) := Opt (8 .. Opt'Last); Scanner.Convert_Identifier; Libraries.Work_Library_Name := Get_Identifier; end; diff --git a/src/options.ads b/src/options.ads index 24a844b59..b8a7f9f16 100644 --- a/src/options.ads +++ b/src/options.ads @@ -20,7 +20,7 @@ package Options is -- Return true if opt is recognize by flags. -- Note: std_names.std_names_initialize and files_map.init_pathes must have -- been called before this subprogram. - function Parse_Option (Opt: String) return Boolean; + function Parse_Option (Option : String) return Boolean; -- Disp help about these options. procedure Disp_Options_Help; |