diff mbox

[Ada] Internal clean up (use Is_Directory_Separator)

Message ID 20141017092057.GA8318@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 17, 2014, 9:20 a.m. UTC
This is an internal clean up to use an existing abstraction
more extensively. No external effect, no test required.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-10-17  Robert Dewar  <dewar@adacore.com>

	* gnatcmd.adb, make.adb, prj-part.adb, gnatlink.adb, prj-nmsc.adb,
	prj-conf.adb, prj-env.adb: Use Is_Directory_Separator where possible.
diff mbox

Patch

Index: gnatcmd.adb
===================================================================
--- gnatcmd.adb	(revision 216367)
+++ gnatcmd.adb	(working copy)
@@ -883,10 +883,9 @@ 
       if not Is_Absolute_Path (Exec_File_Name) then
          for Index in Exec_File_Name'Range loop
             if Exec_File_Name (Index) = Directory_Separator then
-               Fail ("relative executable (""" &
-                       Exec_File_Name &
-                       """) with directory part not allowed " &
-                       "when using project files");
+               Fail ("relative executable (""" & Exec_File_Name
+                     & """) with directory part not allowed "
+                     & "when using project files");
             end if;
          end loop;
 
@@ -1398,9 +1397,7 @@ 
 
                   else
                      for K in Switch'Range loop
-                        if Switch (K) = '/'
-                          or else Switch (K) = Directory_Separator
-                        then
+                        if Is_Directory_Separator (Switch (K)) then
                            Test_Existence := True;
                            exit;
                         end if;
Index: make.adb
===================================================================
--- make.adb	(revision 216367)
+++ make.adb	(working copy)
@@ -4057,8 +4057,7 @@ 
    begin
       First := Name'Last;
       while First > Name'First
-        and then Name (First - 1) /= Directory_Separator
-        and then Name (First - 1) /= '/'
+        and then not Is_Directory_Separator (Name (First - 1))
       loop
          First := First - 1;
       end loop;
@@ -6805,8 +6804,7 @@ 
          begin
             First := Name'Last;
             while First > Name'First
-              and then Name (First - 1) /= Directory_Separator
-              and then Name (First - 1) /= '/'
+              and then not Is_Directory_Separator (Name (First - 1))
             loop
                First := First - 1;
             end loop;
Index: prj-part.adb
===================================================================
--- prj-part.adb	(revision 216367)
+++ prj-part.adb	(working copy)
@@ -349,8 +349,7 @@ 
       Get_Name_String (Path_Name_Of (Main_Project, In_Tree));
 
       while Name_Len > 0
-        and then Name_Buffer (Name_Len) /= Directory_Separator
-        and then Name_Buffer (Name_Len) /= '/'
+        and then not Is_Directory_Separator (Name_Buffer (Name_Len))
       loop
          Name_Len := Name_Len - 1;
       end loop;
Index: gnatlink.adb
===================================================================
--- gnatlink.adb	(revision 216367)
+++ gnatlink.adb	(working copy)
@@ -1204,9 +1204,8 @@ 
                                        if GCC_Index = 0 then
                                           GCC_Index :=
                                             Index (Path (1 .. Path_Last),
-                                                   Directory_Separator &
-                                                   "lib" &
-                                                   Directory_Separator);
+                                                   Directory_Separator & "lib"
+                                                   & Directory_Separator);
                                        end if;
 
                                        --  If we have found a "lib" subdir in
Index: prj-nmsc.adb
===================================================================
--- prj-nmsc.adb	(revision 216381)
+++ prj-nmsc.adb	(working copy)
@@ -5031,10 +5031,7 @@ 
 
                if OK then
                   for J in 1 .. Name_Len loop
-                     if Name_Buffer (J) = '/'
-                          or else
-                        Name_Buffer (J) = Directory_Separator
-                     then
+                     if Is_Directory_Separator (Name_Buffer (J)) then
                         OK := False;
                         exit;
                      end if;
@@ -5336,9 +5333,7 @@ 
    function Compute_Directory_Last (Dir : String) return Natural is
    begin
       if Dir'Length > 1
-        and then (Dir (Dir'Last - 1) = Directory_Separator
-                    or else
-                  Dir (Dir'Last - 1) = '/')
+        and then Is_Directory_Separator (Dir (Dir'Last - 1))
       then
          return Dir'Last - 1;
       else
@@ -5858,7 +5853,7 @@ 
                --  Check that there is no directory information
 
                for J in 1 .. Last loop
-                  if Line (J) = '/' or else Line (J) = Directory_Separator then
+                  if Is_Directory_Separator (Line (J)) then
                      Error_Msg_File_1 := Source_Name;
                      Error_Msg
                        (Data.Flags,
@@ -6485,15 +6480,12 @@ 
                         --  Check that there is no directory information
 
                         for J in 1 .. Last loop
-                           if Line (J) = '/'
-                                or else
-                              Line (J) = Directory_Separator
-                           then
+                           if Is_Directory_Separator (Line (J)) then
                               Error_Msg_File_1 := Name;
                               Error_Msg
                                 (Data.Flags,
-                                 "file name cannot include " &
-                                 "directory information ({)",
+                                 "file name cannot include "
+                                 & "directory information ({)",
                                  Location, Project.Project);
                               exit;
                            end if;
@@ -6600,10 +6592,7 @@ 
                --  Check that there is no directory information
 
                for J in 1 .. Name_Len loop
-                  if Name_Buffer (J) = '/'
-                       or else
-                     Name_Buffer (J) = Directory_Separator
-                  then
+                  if Is_Directory_Separator (Name_Buffer (J)) then
                      Error_Msg_File_1 := Name;
                      Error_Msg
                        (Data.Flags,
@@ -7394,11 +7383,11 @@ 
             if Name (1 .. Last) /= "." and then Name (1 .. Last) /= ".." then
                declare
                   Path_Name : constant String :=
-                    Normalize_Pathname
-                      (Name           => Name (1 .. Last),
-                       Directory      => Path_Str,
-                       Resolve_Links  => Resolve_Links)
-                    & Directory_Separator;
+                                Normalize_Pathname
+                                  (Name           => Name (1 .. Last),
+                                   Directory      => Path_Str,
+                                   Resolve_Links  => Resolve_Links)
+                                & Directory_Separator;
 
                   Path2 : Path_Information;
                   OK    : Boolean := True;
@@ -7475,8 +7464,7 @@ 
 
          if Search_For = Search_Files then
             while Pattern_End >= Pattern'First
-              and then Pattern (Pattern_End) /= '/'
-              and then Pattern (Pattern_End) /= Directory_Separator
+              and then not Is_Directory_Separator (Pattern (Pattern_End))
             loop
                Pattern_End := Pattern_End - 1;
             end loop;
@@ -7512,9 +7500,9 @@ 
          Recursive :=
            Pattern_End - 1 >= Pattern'First
            and then Pattern (Pattern_End - 1 .. Pattern_End) = "**"
-           and then (Pattern_End - 1 = Pattern'First
-                      or else Pattern (Pattern_End - 2) = '/'
-                      or else Pattern (Pattern_End - 2) = Directory_Separator);
+           and then
+             (Pattern_End - 1 = Pattern'First
+               or else Is_Directory_Separator (Pattern (Pattern_End - 2)));
 
          if Recursive then
             Pattern_End := Pattern_End - 2;
@@ -7631,7 +7619,7 @@ 
                declare
                   Source_Directory : constant String :=
                                        Get_Name_String (Element.Value)
-                                         & Directory_Separator;
+                                       & Directory_Separator;
 
                   Dir_Last : constant Natural :=
                                Compute_Directory_Last (Source_Directory);
Index: prj-conf.adb
===================================================================
--- prj-conf.adb	(revision 216376)
+++ prj-conf.adb	(working copy)
@@ -26,6 +26,7 @@ 
 with Makeutl;  use Makeutl;
 with MLib.Tgt;
 with Opt;      use Opt;
+with Osint;    use Osint;
 with Output;   use Output;
 with Prj.Env;
 with Prj.Err;
@@ -1526,11 +1527,12 @@ 
 
       function Is_Base_Name (Path : String) return Boolean is
       begin
-         for I in Path'Range loop
-            if Path (I) = Directory_Separator or else Path (I) = '/' then
+         for J in Path'Range loop
+            if Is_Directory_Separator (Path (J)) then
                return False;
             end if;
          end loop;
+
          return True;
       end Is_Base_Name;
 
Index: prj-env.adb
===================================================================
--- prj-env.adb	(revision 216367)
+++ prj-env.adb	(working copy)
@@ -1435,7 +1435,7 @@ 
       function Is_Base_Name (Path : String) return Boolean is
       begin
          for J in Path'Range loop
-            if Path (J) = Directory_Separator or else Path (J) = '/' then
+            if Is_Directory_Separator (Path (J)) then
                return False;
             end if;
          end loop;
@@ -2131,14 +2131,14 @@ 
                --  $prefix/share/gpr
 
                Add_Str_To_Name_Buffer
-                 (Path_Separator & Prefix.all &
-                  "share" & Directory_Separator & "gpr");
+                 (Path_Separator & Prefix.all & "share"
+                  & Directory_Separator & "gpr");
 
                --  $prefix/lib/gnat
 
                Add_Str_To_Name_Buffer
-                 (Path_Separator & Prefix.all &
-                  "lib" & Directory_Separator & "gnat");
+                 (Path_Separator & Prefix.all & "lib"
+                  & Directory_Separator & "gnat");
             end if;
 
             Free (Prefix);
@@ -2293,8 +2293,7 @@ 
             exit Check_Dot;
          end if;
 
-         exit Check_Dot when File (K) = Directory_Separator
-           or else File (K) = '/';
+         exit Check_Dot when Is_Directory_Separator (File (K));
       end loop Check_Dot;
 
       if not Is_Absolute_Path (File) then