This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] patch to fix PR20822
- From: "Rolf Ebert" <rolf dot ebert dot gcc at gmx dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 13 Apr 2005 22:23:20 +0200
- Subject: [Ada] patch to fix PR20822
This is my first posting to the patch list, please be patient.
The texi file for the gnat user guide is generated by filter program
xgnatugn written in Ada. The program used Text_IO wich generates Windows
line endings CRLF on Windows. The makeinfo program (at least the one
distributed in MingW) does not like CR characters at the end of texi
keywords or within anchors. IMO, this is more a makeinfo problem than a
GNAT problem. It can be easily avoided by using Ada.Streams output
instead of Text_IO. A similar fix was posted here in
http://gcc.gnu.org/ml/gcc-patches/2005-03/msg02615.html.
It is perhaps cleaner not to 'use' Ada.Streams.Stream_IO, which would
avoid adding Ada.Text_IO at that many places.
Rolf
2005-04-11 Rolf Ebert (rolf.ebert.gcc@gmx.de)
* xgnatugn.adb: Use Stream_IO instead of Text_IO to guarantee
Unix style line terminators for the output files, even when
running on windows.
--- xgnatugn.adb~Mon Aug 9 12:24:22 2004
+++ xgnatugn.adbMon Apr 11 12:28:27 2005
@@ -98,6 +98,7 @@
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
+with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Spitbol; use GNAT.Spitbol;
@@ -109,12 +110,14 @@
-- Print usage information. Invoked if an invalid command line is
-- encountered.
- Output_File : File_Type;
+ subtype Sfile is Ada.Streams.Stream_IO.File_Type;
+
+ Output_File : Sfile;
-- The preprocessed output is written to this file
type Input_File is record
Name : VString;
- Data : File_Type;
+ Data : Ada.Text_IO.File_Type;
Line : Natural := 0;
end record;
-- Records information on an input file. Name and Line are used
@@ -124,6 +127,10 @@
-- Returns a line from Input and performs the necessary
-- line-oriented checks (length, character set, trailing spaces).
+ procedure Put_Line (F : Sfile; S : String);
+ procedure Put_Line (F : Sfile; S : VString);
+ -- Local version of Put_Line ensures Unix style line endings
+
Number_Of_Warnings : Natural := 0;
Number_Of_Errors : Natural := 0;
Warnings_Enabled : Boolean;
@@ -353,6 +360,21 @@
end;
end Get_Line;
+ --------------
+ -- Put_Line --
+ --------------
+
+ procedure Put_Line (F : Sfile; S : String) is
+ begin
+ String'Write (Stream (F), S);
+ Character'Write (Stream (F), ASCII.LF);
+ end Put_Line;
+
+ procedure Put_Line (F : Sfile; S : VString) is
+ begin
+ Put_Line (F, To_String (S));
+ end Put_Line;
+
-----------
-- Error --
-----------
@@ -1312,7 +1334,7 @@
Open (Source_File.Data, In_File, Argument (2));
exception
- when Name_Error =>
+ when Ada.Text_IO.Name_Error =>
Valid_Command_Line := False;
end;
end if;
@@ -1325,7 +1347,7 @@
Open (Dictionary_File.Data, In_File, Argument (3));
exception
- when Name_Error =>
+ when Ada.Text_IO.Name_Error =>
Valid_Command_Line := False;
end;
end if;
@@ -1350,7 +1372,7 @@
Create (Output_File, Out_File, S (Output_File_Name));
exception
- when Name_Error | Use_Error =>
+ when Ada.Text_IO.Name_Error | Ada.Text_IO.Use_Error =>
Valid_Command_Line := False;
end;
end if;