Patchwork [Ada] OpenVMS: truncate the length of GNAT_DRIVER_COMMAND_LINE logical

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 29, 2011, 1:39 p.m.
Message ID <20110829133911.GA18790@adacore.com>
Download mbox | patch
Permalink /patch/112051/
State New
Headers show

Comments

Arnaud Charlet - Aug. 29, 2011, 1:39 p.m.
As the length of any logical is limited to 255 bytes.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-29  Tristan Gingold  <gingold@adacore.com>

	* gnatcmd.adb (GNATCmd): On OpenVMS, truncate the length of
	GNAT_DRIVER_COMMAND_LINE to 255.

Patch

Index: gnatcmd.adb
===================================================================
--- gnatcmd.adb	(revision 178155)
+++ gnatcmd.adb	(working copy)
@@ -202,6 +202,9 @@ 
    --  indicate that the underlying tool (gnatcheck, gnatpp or gnatmetric)
    --  should be invoked for all sources of all projects.
 
+   Max_OpenVMS_Logical_Length : constant Integer := 255;
+   --  The maximum length of OpenVMS logicals
+
    -----------------------
    -- Local Subprograms --
    -----------------------
@@ -1420,6 +1423,15 @@ 
       Add_Str_To_Name_Buffer (Argument (J));
    end loop;
 
+   --  On OpenVMS, setenv creates a logical whose length is limited to
+   --  255 bytes.
+
+   if OpenVMS and then Name_Len > Max_OpenVMS_Logical_Length then
+      Name_Buffer (Max_OpenVMS_Logical_Length - 2
+                     .. Max_OpenVMS_Logical_Length) := "...";
+      Name_Len := Max_OpenVMS_Logical_Length;
+   end if;
+
    Setenv ("GNAT_DRIVER_COMMAND_LINE", Name_Buffer (1 .. Name_Len));
 
    --  Add the directory where the GNAT driver is invoked in front of the path,