aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/g-os_lib.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/g-os_lib.adb')
-rw-r--r--gcc/ada/g-os_lib.adb22
1 files changed, 19 insertions, 3 deletions
diff --git a/gcc/ada/g-os_lib.adb b/gcc/ada/g-os_lib.adb
index 473e0eb..9566e21 100644
--- a/gcc/ada/g-os_lib.adb
+++ b/gcc/ada/g-os_lib.adb
@@ -1547,6 +1547,8 @@ package body GNAT.OS_Lib is
S1 : String := S;
-- We may need to fold S to lower case, so we need a variable
+ Last : Natural;
+
begin
-- Interix has the non standard notion of disk drive
-- indicated by two '/' followed by a capital letter
@@ -1566,23 +1568,37 @@ package body GNAT.OS_Lib is
begin
Result (1) := '/';
Result (2 .. Result'Last) := S;
+ Last := Result'Last;
if Fold_To_Lower_Case then
System.Case_Util.To_Lower (Result);
end if;
- return Result;
+ -- Remove trailing directory separator, if any
+
+ if Result (Last) = '/' or else
+ Result (Last) = Directory_Separator
+ then
+ Last := Last - 1;
+ end if;
+ return Result (1 .. Last);
end;
else
-
if Fold_To_Lower_Case then
System.Case_Util.To_Lower (S1);
end if;
- return S1;
+ -- Remove trailing directory separator, if any
+
+ Last := S1'Last;
+
+ if S1 (Last) = '/' or else S1 (Last) = Directory_Separator then
+ Last := Last - 1;
+ end if;
+ return S1 (1 .. Last);
end if;
end Final_Value;