g-comlin.adb (Getopt): Skip any leading space in the Switches string.
authorJoel Brobecker <brobecker@adacore.com>
Thu, 16 Jun 2005 08:38:55 +0000 (10:38 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Jun 2005 08:38:55 +0000 (10:38 +0200)
2005-06-14  Joel Brobecker  <brobecker@adacore.com>

* g-comlin.adb (Getopt): Skip any leading space in the Switches string.
Avoids a CE when it starts with spaces.

From-SVN: r101038

gcc/ada/g-comlin.adb

index 05862b478ebaaea50f6e65e427a27a777777e58a..0c5457a190e9acd84d478650fa1c6b11ecb5a1be 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1999-2004 Free Software Foundation, Inc.          --
+--          Copyright (C) 1999-2005 Free Software Foundation, Inc.          --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -384,11 +384,19 @@ package body GNAT.Command_Line is
          Arg            : String renames CL.Argument (Current_Argument);
          Index_Switches : Natural := 0;
          Max_Length     : Natural := 0;
-         Index          : Natural := Switches'First;
+         Index          : Natural;
          Length         : Natural := 1;
          End_Index      : Natural;
 
       begin
+         --  Remove all leading spaces first to make sure that Index points
+         --  at the start of the first switch.
+
+         Index := Switches'First;
+         while Index <= Switches'Last and then Switches (Index) = ' ' loop
+            Index := Index + 1;
+         end loop;
+
          while Index <= Switches'Last loop
 
             --  Search the length of the parameter at this position in Switches