Commit ce09c3c0 by Pascal Obry Committed by Pierre-Marie de Rodat

[Ada] Fix constraint error in Normalize_Pathname

Fix Normalize_Pathname to avoid a constraint error.

2018-05-29  Pascal Obry  <obry@adacore.com>

gcc/ada/

	* libgnat/s-os_lib.adb (Normalize_Pathname): Fix handling of ".." in
	the root directory.

gcc/testsuite/

	* gnat.dg/normalize_pathname.adb: New testcase.

From-SVN: r260872
parent ae3d5f11
2018-05-29 Pascal Obry <obry@adacore.com> 2018-05-29 Pascal Obry <obry@adacore.com>
* libgnat/s-os_lib.adb (Normalize_Pathname): Fix handling of ".." in
the root directory.
2018-05-29 Pascal Obry <obry@adacore.com>
* libgnat/s-os_lib.adb: Minor reformatting. * libgnat/s-os_lib.adb: Minor reformatting.
2018-05-29 Doug Rupp <rupp@adacore.com> 2018-05-29 Doug Rupp <rupp@adacore.com>
......
...@@ -2389,12 +2389,18 @@ package body System.OS_Lib is ...@@ -2389,12 +2389,18 @@ package body System.OS_Lib is
elsif Finish = Start + 1 elsif Finish = Start + 1
and then Path_Buffer (Start .. Finish) = ".." and then Path_Buffer (Start .. Finish) = ".."
then then
Start := Last; if Last > 1 then
loop Start := Last - 1;
Start := Start - 1;
exit when Start = 1 while Start > 1
or else Path_Buffer (Start) = Directory_Separator; and then Path_Buffer (Start) /= Directory_Separator
end loop; loop
Start := Start - 1;
end loop;
else
Start := Last;
end if;
if Start = 1 then if Start = 1 then
if Finish = End_Path then if Finish = End_Path then
......
2018-05-29 Pascal Obry <obry@adacore.com>
* gnat.dg/normalize_pathname.adb: New testcase.
2018-05-29 Tom de Vries <tom@codesourcery.com> 2018-05-29 Tom de Vries <tom@codesourcery.com>
* lib/scanasm.exp (scan-assembler-times): Use proc name in error * lib/scanasm.exp (scan-assembler-times): Use proc name in error
......
-- { dg-do run }
with GNAT.OS_Lib;
procedure Normalize_Pathname is
S : constant String := GNAT.OS_Lib.Normalize_Pathname
("/../tmp", Directory => "", Resolve_Links => True);
begin
null;
end Normalize_Pathname;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment