This is first of 4 patches for DJGPP support of Ada compiler
Patch adds support of handling DJGPP special paths which do not follow normal
DOS file-name rules.
Some details about handled DJGPP special pathnames: for example '/dev/c/foo' is interpreted as
'c:/foo', '/dev/env/DJDIR/include' is interpreted as $DJDIR/include. Adding drive prefix (like
c:/dev/c/foo) is not supported for these special path-names.
ChangeLog entry:
2016-07-30 Andris Pavenis <andris.pave...@iki.fi>
* ada/adaint.c (__gnat_is_djgpp): define (1 for DJGPP host, 0 otherwise).
* ada/s-os_lib.ads (Is_Djgpp): import __gnat_is_djgpp as constant.
* ada/s-os_lib.adb (Normalize_Pathname): support DJGPP special paths
(/dev/*) for DJGPP hosts
Andris
>From ecf2e5463c56c5221107090288b2990584cd4bfb Mon Sep 17 00:00:00 2001
From: Andris Pavenis <andris.pave...@iki.fi>
Date: Sat, 30 Jul 2016 08:01:45 +0300
Subject: [PATCH 1/4] [DJGPP, Ada] File path handling for DJGPP host
* ada/adaint.c (__gnat_is_djgpp): define (1 for DJGPP host, 0 otherwise).
* ada/s-os_lib.ads (Is_Djgpp): import __gnat_is_djgpp as constant.
* ada/s-os_lib.adb (Normalize_Pathname): support DJGPP special paths (/dev/*) for DJGPP hosts
---
gcc/ada/adaint.c | 6 ++++++
gcc/ada/s-os_lib.adb | 35 ++++++++++++++++++++++++++++++++++-
gcc/ada/s-os_lib.ads | 3 +++
3 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index e011fef..f317865 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -226,6 +226,12 @@ char __gnat_dir_separator = DIR_SEPARATOR;
char __gnat_path_separator = PATH_SEPARATOR;
+#ifdef __DJGPP__
+int __gnat_is_djgpp = 1;
+#else
+int __gnat_is_djgpp = 0;
+#endif
+
/* The GNAT_LIBRARY_TEMPLATE contains a list of expressions that define
the base filenames that libraries specified with -lsomelib options
may have. This is used by GNATMAKE to check whether an executable
diff --git a/gcc/ada/s-os_lib.adb b/gcc/ada/s-os_lib.adb
index 31b2f08..73bc2db 100644
--- a/gcc/ada/s-os_lib.adb
+++ b/gcc/ada/s-os_lib.adb
@@ -2069,6 +2069,13 @@ package body System.OS_Lib is
not Case_Sensitive
and then Get_File_Names_Case_Sensitive = 0;
+ function Is_Directory_Separator (C : Character) return Boolean;
+ -- Test whether provided character is directory separator
+
+ function Is_Djgpp_Special_Path (Path : String) return Boolean;
+ -- Test whether provided path is DJGPP special path (/dev/...).
+ -- Returns false in all other cases also when not DJGPP.
+
function Final_Value (S : String) return String;
-- Make final adjustment to the returned string. This function strips
-- trailing directory separators, and folds returned string to lower
@@ -2079,6 +2086,28 @@ package body System.OS_Lib is
-- if not already present, otherwise return current working directory
-- with terminating directory separator.
+ ----------------------------
+ -- Is_Directory_Separator --
+ ----------------------------
+
+ function Is_Directory_Separator (C : Character) return Boolean is
+ begin
+ return C = '/'
+ or else C = Directory_Separator;
+ end Is_Directory_Separator;
+
+ ---------------------------
+ -- Is_Djgpp_Special_Path --
+ ---------------------------
+
+ function Is_Djgpp_Special_Path (Path : String) return Boolean is
+ begin
+ return Is_Djgpp /= 0
+ and then Is_Directory_Separator (Path (Path'First))
+ and then Path (Path'First + 1 .. Path'First + 3) = "dev"
+ and then Is_Directory_Separator (Path (Path'First + 4));
+ end Is_Djgpp_Special_Path;
+
-----------------
-- Final_Value --
-----------------
@@ -2242,8 +2271,11 @@ package body System.OS_Lib is
end File_Name_Conversion;
-- Replace all '/' by Directory Separators (this is for Windows)
+ -- No need to do that however for DJGPP
- if Directory_Separator /= '/' then
+ if Directory_Separator /= '/'
+ and then Is_Djgpp = 0
+ then
for Index in 1 .. End_Path loop
if Path_Buffer (Index) = '/' then
Path_Buffer (Index) := Directory_Separator;
@@ -2264,6 +2296,7 @@ package body System.OS_Lib is
if Path_Buffer (1) = Directory_Separator
and then Path_Buffer (2) /= Directory_Separator
+ and then not Is_Djgpp_Special_Path (Path_Buffer)
then
declare
Cur_Dir : constant String := Get_Directory ("");
diff --git a/gcc/ada/s-os_lib.ads b/gcc/ada/s-os_lib.ads
index 9004874..5c8bfe2 100644
--- a/gcc/ada/s-os_lib.ads
+++ b/gcc/ada/s-os_lib.ads
@@ -1068,9 +1068,12 @@ package System.OS_Lib is
Path_Separator : constant Character;
-- The character to separate paths in an environment variable value
+ Is_Djgpp : constant Integer;
+
private
pragma Import (C, Path_Separator, "__gnat_path_separator");
pragma Import (C, Directory_Separator, "__gnat_dir_separator");
+ pragma Import (C, Is_Djgpp, "__gnat_is_djgpp");
pragma Import (C, Current_Time, "__gnat_current_time");
pragma Import (C, Current_Process_Id, "__gnat_current_process_id");
--
2.7.4