On Windows the directory separator can be / or \, in some cases this was not properly handled. This patch fixes this issue.
Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-31 Pascal Obry <o...@adacore.com> * a-direct.adb: Use Dir_Seps everywhere to properly handle all directory speparators. (Compose): Use Dir_Seps to handle both forms. (Create_Path): Use Dir_Seps instead of explicit check, no semantic changes. (Extension): Use Dir_Seps to handle both forms.
Index: a-direct.adb =================================================================== --- a-direct.adb (revision 178358) +++ a-direct.adb (working copy) @@ -32,7 +32,7 @@ with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Ada.Directories.Validity; use Ada.Directories.Validity; -with Ada.Strings.Maps; +with Ada.Strings.Maps; use Ada; use Ada.Strings.Maps; with Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Unchecked_Conversion; @@ -61,8 +61,7 @@ pragma Import (C, Dir_Separator, "__gnat_dir_separator"); -- Running system default directory separator - Dir_Seps : constant Ada.Strings.Maps.Character_Set := - Ada.Strings.Maps.To_Set ("/\"); + Dir_Seps : constant Character_Set := Strings.Maps.To_Set ("/\"); -- UNIX and DOS style directory separators Max_Path : Integer; @@ -175,7 +174,7 @@ -- Add a directory separator if needed - if Last /= 0 and then Result (Last) /= Dir_Separator then + if Last /= 0 and then not Is_In (Result (Last), Dir_Seps) then Last := Last + 1; Result (Last) := Dir_Separator; end if; @@ -457,17 +456,13 @@ -- Look for the end of an intermediate directory - if New_Dir (J) /= Dir_Separator and then - New_Dir (J) /= '/' - then + if not Is_In (New_Dir (J), Dir_Seps) then Last := J; -- We have found a new intermediate directory each time we find -- a first directory separator. - elsif New_Dir (J - 1) /= Dir_Separator and then - New_Dir (J - 1) /= '/' - then + elsif not Is_In (New_Dir (J - 1), Dir_Seps) then -- No need to create the directory if it already exists @@ -664,7 +659,7 @@ -- If a directory separator is found before a dot, there is no -- extension. - if Name (Pos) = Dir_Separator then + if Is_In (Name (Pos), Dir_Seps) then return Empty_String; elsif Name (Pos) = '.' then