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
+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.
elsif Finish = Start + 1
and then Path_Buffer (Start .. Finish) = ".."
then
- Start := Last;
- loop
- Start := Start - 1;
- exit when Start = 1
- or else Path_Buffer (Start) = Directory_Separator;
- end loop;
+ if Last > 1 then
+ Start := Last - 1;
+
+ while Start > 1
+ and then Path_Buffer (Start) /= Directory_Separator
+ loop
+ Start := Start - 1;
+ end loop;
+
+ else
+ Start := Last;
+ end if;
if Start = 1 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>
* lib/scanasm.exp (scan-assembler-times): Use proc name in error
--- /dev/null
+-- { 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;