aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/osint.adb
diff options
context:
space:
mode:
authorPascal Obry <obry@gnat.com>2001-10-25 23:23:44 +0000
committerGeert Bosch <bosch@gcc.gnu.org>2001-10-26 01:23:44 +0200
commit90a9fff2b07b27a3d6fae98f3565ab0536f981c6 (patch)
tree7d2e6f3845308cbd2c3275b30397d7ebd1563dea /gcc/ada/osint.adb
parent5c1ba4cc9cd83595d4f327fe2e5fc0ab1f1222cf (diff)
downloadgcc-90a9fff2b07b27a3d6fae98f3565ab0536f981c6.zip
gcc-90a9fff2b07b27a3d6fae98f3565ab0536f981c6.tar.gz
gcc-90a9fff2b07b27a3d6fae98f3565ab0536f981c6.tar.bz2
osint.adb (Read_Default_Search_Dirs): correctly detect relative pathnames in UNIX and DOS style with drive letter.
* osint.adb (Read_Default_Search_Dirs): correctly detect relative pathnames in UNIX and DOS style with drive letter. (Is_Relative): new routine. * osint.adb: Minor reformatting * osint.adb (Is_Relative): implementation using GNAT.OS_Lib.Is_Absolute_Path. Better fix for 8121-009. From-SVN: r46503
Diffstat (limited to 'gcc/ada/osint.adb')
-rw-r--r--gcc/ada/osint.adb54
1 files changed, 45 insertions, 9 deletions
diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb
index 5d5bf72..b43f2d7 100644
--- a/gcc/ada/osint.adb
+++ b/gcc/ada/osint.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- $Revision: 1.258 $
+-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
@@ -1676,11 +1676,31 @@ package body Osint is
------------------------------
function Read_Default_Search_Dirs
- (Search_Dir_Prefix : String_Access;
- Search_File : String_Access;
+ (Search_Dir_Prefix : String_Access;
+ Search_File : String_Access;
Search_Dir_Default_Name : String_Access)
- return String_Access
+ return String_Access
is
+ function Is_Relative (S : String; K : Positive) return Boolean;
+ -- Returns True if a relative directory specification is found in S at
+ -- position K.
+
+ function Is_Relative (S : String; K : Positive) return Boolean is
+ begin
+ return
+ not (Is_Directory_Separator (S (K)) -- Unix style absolute pathname
+
+ or else -- DOS style absolute pathname with drive letter
+
+ (S'Last > K + 2
+ and then
+ (S (K) in 'a' .. 'z' or else S (K) in 'A' .. 'Z')
+ and then
+ S (K + 1) = ':'
+ and then
+ Is_Directory_Separator (S (K + 2))));
+ end Is_Relative;
+
Prefix_Len : constant Integer := Search_Dir_Prefix.all'Length;
Buffer : String (1 .. Prefix_Len + Search_File.all'Length + 1);
File_FD : File_Descriptor;
@@ -1693,8 +1713,23 @@ package body Osint is
Prev_Was_Separator : Boolean;
Nb_Relative_Dir : Integer;
- begin
+ function Is_Relative (S : String; K : Positive) return Boolean;
+ pragma Inline (Is_Relative);
+ -- Returns True if a relative directory specification is found
+ -- in S at position K, False otherwise.
+ -----------------
+ -- Is_Relative --
+ -----------------
+
+ function Is_Relative (S : String; K : Positive) return Boolean is
+ begin
+ return not Is_Absolute_Path (S (K .. S'Last));
+ end Is_Relative;
+
+ -- Start of processing for Read_Default_Search_Dirs
+
+ begin
-- Construct a C compatible character string buffer.
Buffer (1 .. Search_Dir_Prefix.all'Length)
@@ -1737,12 +1772,13 @@ package body Osint is
S (J) := Path_Separator;
end if;
- if S (J) = Path_Separator then
+ if S (J) = Path_Separator then
Prev_Was_Separator := True;
else
- if Prev_Was_Separator and S (J) /= Directory_Separator then
+ if Prev_Was_Separator and then Is_Relative (S.all, J) then
Nb_Relative_Dir := Nb_Relative_Dir + 1;
end if;
+
Prev_Was_Separator := False;
end if;
end loop;
@@ -1757,11 +1793,11 @@ package body Osint is
J1 := 1;
Prev_Was_Separator := True;
for J in 1 .. Len + 1 loop
- if S (J) = Path_Separator then
+ if S (J) = Path_Separator then
Prev_Was_Separator := True;
else
- if Prev_Was_Separator and S (J) /= Directory_Separator then
+ if Prev_Was_Separator and then Is_Relative (S.all, J) then
S1 (J1 .. J1 + Prefix_Len) := Search_Dir_Prefix.all;
J1 := J1 + Prefix_Len;
end if;