[Ada] fix bug in gnatchop under VMS

Arnaud Charlet charlet@adacore.com
Tue Mar 15 15:04:00 GMT 2005


Manually tested on VMS.
Tested on i686-linux. Committed on mainline.

Gnatchop looks first in its own "which" directory when searching for
programs to spawn, e.g gcc. It gets the directory from Command_Name
prefix which, on VMS, is of course VMS style. This style defeats
the algorithm used to find the prefix, so it must first be "normalized"
which essentially converts it to Unix style.

2005-03-08  Doug Rupp  <rupp@adacore.com>

	* gnatchop.adb (Locate_Executable): Normalize the possibly VMS style
	Command_Name.

-------------- next part --------------
Index: gnatchop.adb
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/gnatchop.adb,v
retrieving revision 1.15
diff -u -p -r1.15 gnatchop.adb
--- gnatchop.adb	10 Feb 2005 13:49:13 -0000	1.15
+++ gnatchop.adb	15 Mar 2005 13:55:38 -0000
@@ -521,17 +521,19 @@ procedure Gnatchop is
 
    function Locate_Executable
      (Program_Name    : String;
-      Look_For_Prefix : Boolean := True)
-     return             String_Access
+      Look_For_Prefix : Boolean := True) return String_Access
    is
-      Current_Command : constant String := Command_Name;
-      End_Of_Prefix   : Natural  := Current_Command'First - 1;
-      Start_Of_Prefix : Positive := Current_Command'First;
+      Current_Command : constant String := Normalize_Pathname (Command_Name);
+      End_Of_Prefix   : Natural;
+      Start_Of_Prefix : Positive;
       Result          : String_Access;
 
    begin
+      Start_Of_Prefix := Current_Command'First;
+      End_Of_Prefix   := Start_Of_Prefix - 1;
 
       if Look_For_Prefix then
+
          --  Find Start_Of_Prefix
 
          for J in reverse Current_Command'Range loop
@@ -546,8 +548,6 @@ procedure Gnatchop is
 
          --  Find End_Of_Prefix
 
-         End_Of_Prefix := Start_Of_Prefix - 1;
-
          for J in reverse Start_Of_Prefix .. Current_Command'Last loop
             if Current_Command (J) = '-' then
                End_Of_Prefix := J;


More information about the Gcc-patches mailing list