From 1732c156412b8af08b0b24a615c99176a8ec3237 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 7 Apr 2009 18:22:41 +0200 Subject: [PATCH] [multiple changes] 2009-04-07 Bob Duff * s-secsta.ads, g-pehage.ads, s-fileio.ads: Minor comment fixes 2009-04-07 Bob Duff * gnat_rm.texi, s-fileio.adb (System.File_IO.Open): New feature: A Form parameter of Text_Translation=No allows binary mode for Text_IO files. * gnat_rm.texi: Document Form parameter Text_Translation=xxx. 2009-04-07 Javier Miranda * exp_ch5.adb (Expand_Assign_Array): Add implicit conversion when processing the bounds for bit packed arrays or VM target machines. From-SVN: r145691 --- gcc/ada/ChangeLog | 17 +++++++++++++++++ gcc/ada/exp_ch5.adb | 17 ++++++++++++++--- gcc/ada/g-pehage.ads | 26 +++++++++++++------------- gcc/ada/gnat_rm.texi | 20 +++++++++++++++++++- gcc/ada/s-fileio.adb | 20 +++++++++++++++++--- gcc/ada/s-fileio.ads | 8 ++++---- gcc/ada/s-secsta.ads | 4 ++-- 7 files changed, 86 insertions(+), 26 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ba395384fbd..e5fbcbaf494 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,20 @@ +2009-04-07 Bob Duff + + * s-secsta.ads, g-pehage.ads, s-fileio.ads: Minor comment fixes + +2009-04-07 Bob Duff + + * gnat_rm.texi, s-fileio.adb (System.File_IO.Open): New feature: A + Form parameter of Text_Translation=No allows binary mode for Text_IO + files. + + * gnat_rm.texi: Document Form parameter Text_Translation=xxx. + +2009-04-07 Javier Miranda + + * exp_ch5.adb (Expand_Assign_Array): Add implicit conversion when + processing the bounds for bit packed arrays or VM target machines. + 2009-04-07 Thomas Quinot * g-sothco.ads (Int_Access): Remove extraneous access type (use diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 4305887cff6..16cb44fad2d 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -851,12 +851,23 @@ package body Exp_Ch5 is -- conversions ??? else - -- Copy the bounds and reset the Analyzed flag, because the - -- bounds of the index type itself may be universal, and must - -- must be reaanalyzed to acquire the proper type for Gigi. + -- Copy the bounds Cleft_Lo := New_Copy_Tree (Left_Lo); Cright_Lo := New_Copy_Tree (Right_Lo); + + -- If the types do not match we add an implicit conversion + -- here to ensure proper match + + if Etype (Left_Lo) /= Etype (Right_Lo) then + Cright_Lo := + Unchecked_Convert_To (Etype (Left_Lo), Cright_Lo); + end if; + + -- Reset the Analyzed flag, because the bounds of the index + -- type itself may be universal, and must must be reaanalyzed + -- to acquire the proper type for the back end. + Set_Analyzed (Cleft_Lo, False); Set_Analyzed (Cright_Lo, False); diff --git a/gcc/ada/g-pehage.ads b/gcc/ada/g-pehage.ads index 8b75f2e8803..e4d0e902df9 100644 --- a/gcc/ada/g-pehage.ads +++ b/gcc/ada/g-pehage.ads @@ -40,17 +40,17 @@ -- Processing Letters, 43(1992) pp.257-264, Oct.1992 -- Let W be a set of m words. A hash function h is a function that maps the --- set of words W into some given interval of integers [0, k-1], where k is an --- integer, usually k >= m. h (w) where is a word computes an address or an --- integer from I for the storage or the retrieval of that item. The storage --- area used to store items is known as a hash table. Words for which the same --- address is computed are called synonyms. Due to the existence of synonyms a --- situation called collision may arise in which two items w1 and w2 have the --- same address. Several schemes for resolving known. A perfect hash function --- is an injection from the word set W to the integer interval I with k >= m. --- If k = m, then h is a minimal perfect hash function. A hash function is --- order preserving if it puts entries into the hash table in prespecified --- order. +-- set of words W into some given interval I of integers [0, k-1], where k is +-- an integer, usually k >= m. h (w) where w is a word in W computes an +-- address or an integer from I for the storage or the retrieval of that +-- item. The storage area used to store items is known as a hash table. Words +-- for which the same address is computed are called synonyms. Due to the +-- existence of synonyms a situation called collision may arise in which two +-- items w1 and w2 have the same address. Several schemes for resolving +-- collisions are known. A perfect hash function is an injection from the word +-- set W to the integer interval I with k >= m. If k = m, then h is a minimal +-- perfect hash function. A hash function is order preserving if it puts +-- entries into the hash table in a prespecified order. -- A minimal perfect hash function is defined by two properties: @@ -62,8 +62,8 @@ -- The functions generated by this package require the words to be known in -- advance (they are "static" hash functions). The hash functions are also --- order preserving. If w2 is inserted after w1 in the generator, then (w1) --- < f (w2). These hashing functions are convenient for use with realtime +-- order preserving. If w2 is inserted after w1 in the generator, then h (w1) +-- < h (w2). These hashing functions are convenient for use with realtime -- applications. package GNAT.Perfect_Hash_Generators is diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index b2aa6620beb..4d50a50cd41 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -278,6 +278,7 @@ The Implementation of Standard I/O * Wide_Text_IO:: * Wide_Wide_Text_IO:: * Stream_IO:: +* Text Translation:: * Shared Files:: * Filenames encoding:: * Open Modes:: @@ -12161,6 +12162,7 @@ these additional facilities are also described in this chapter. * Wide_Text_IO:: * Wide_Wide_Text_IO:: * Stream_IO:: +* Text Translation:: * Shared Files:: * Filenames encoding:: * Open Modes:: @@ -12237,11 +12239,13 @@ The format of a FORM string in GNAT is: @noindent where letters may be in upper or lower case, and there are no spaces between values. The order of the entries is not important. Currently -there are two keywords defined. +the following keywords defined. @smallexample +TEXT_TRANSLATION=[YES|NO] SHARED=[YES|NO] WCEM=[n|h|u|s|e|8|b] +ENCODING=[UTF8|8BITS] @end smallexample @noindent @@ -12941,6 +12945,20 @@ The stream attributes applied to a stream file transfer data in the manner described for stream attributes. @end itemize +@node Text Translation +@section Text Translation + +@noindent +@samp{Text_Translation=@var{xxx}} may be used as the Form parameter +passed to Text_IO.Create and Text_IO.Open: +@samp{Text_Translation=@var{Yes}} is the default, which means to +translate LF to/from CR/LF on Windows systems. +@samp{Text_Translation=@var{No}} disables this translation; i.e. it +uses binary mode. For output files, @samp{Text_Translation=@var{No}} +may be used to create Unix-style files on +Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix +systems. + @node Shared Files @section Shared Files diff --git a/gcc/ada/s-fileio.adb b/gcc/ada/s-fileio.adb index d2af05c2048..2edf4213e5a 100644 --- a/gcc/ada/s-fileio.adb +++ b/gcc/ada/s-fileio.adb @@ -739,6 +739,8 @@ package body System.File_IO is Formstr : aliased String (1 .. Form'Length + 1); -- Form string with ASCII.NUL appended, folded to lower case + Is_Text_File : Boolean; + Tempfile : constant Boolean := (Name'Length = 0); -- Indicates temporary file case @@ -800,7 +802,7 @@ package body System.File_IO is end if; end; - -- Acquire setting of shared parameter + -- Acquire setting of encoding parameter declare V1, V2 : Natural; @@ -822,6 +824,18 @@ package body System.File_IO is end if; end; + -- Acquire setting of text_translation parameter. Only needed if this is + -- a [Wide_[Wide_]]Text_IO file, in which case we default to True, but + -- if the Form says Text_Translation=No, we use binary mode, so new-line + -- will be just LF, even on Windows. + + Is_Text_File := Text; + + if Is_Text_File then + Is_Text_File := + Form_Boolean (Formstr, "text_translation", Default => True); + end if; + -- If we were given a stream (call from xxx.C_Streams.Open), then set -- the full name to the given one, and skip to end of processing. @@ -962,7 +976,7 @@ package body System.File_IO is -- Open specified file if we did not find an existing stream if Stream = NULL_Stream then - Fopen_Mode (Mode, Text, Creat, Amethod, Fopstr); + Fopen_Mode (Mode, Is_Text_File, Creat, Amethod, Fopstr); -- A special case, if we are opening (OPEN case) a file and the -- mode returned by Fopen_Mode is not "r" or "r+", then we first @@ -1026,7 +1040,7 @@ package body System.File_IO is File_Ptr.Is_Regular_File := (is_regular_file (fileno (Stream)) /= 0); File_Ptr.Is_System_File := False; - File_Ptr.Is_Text_File := Text; + File_Ptr.Is_Text_File := Is_Text_File; File_Ptr.Shared_Status := Shared; File_Ptr.Access_Method := Amethod; File_Ptr.Stream := Stream; diff --git a/gcc/ada/s-fileio.ads b/gcc/ada/s-fileio.ads index f69c580856b..9522c6121bc 100644 --- a/gcc/ada/s-fileio.ads +++ b/gcc/ada/s-fileio.ads @@ -72,7 +72,7 @@ package System.File_IO is -- Mode is the required mode -- -- Name is the file name, with a null string indicating that a temporary - -- file is to be created (only permitted in create mode, not open mode) + -- file is to be created (only permitted in create mode, not open mode). -- -- Creat is True for a create call, and false for an open call -- @@ -80,16 +80,16 @@ package System.File_IO is -- of the usual binary mode open (w+b or r+b). -- -- Form is the form string given in the open or create call, this is - -- stored in the AFCB, but otherwise is not used by this or any other - -- routine in this unit (except Form which retrieves the original value) + -- stored in the AFCB. -- - -- Amethod indicates the access method + -- Amethod indicates the access method: -- -- D = Direct_IO -- Q = Sequential_IO -- S = Stream_IO -- T = Text_IO -- W = Wide_Text_IO + -- ??? Wide_Wide_Text_IO ??? -- -- C_Stream is left at its default value for the normal case of an -- Open or Create call as defined in the RM. The only time this is diff --git a/gcc/ada/s-secsta.ads b/gcc/ada/s-secsta.ads index 4e39e224210..22fbd882a11 100644 --- a/gcc/ada/s-secsta.ads +++ b/gcc/ada/s-secsta.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -60,7 +60,7 @@ package System.Secondary_Stack is -- -- Otherwise (Sec_Stack_Ratio between 0 and 100), Stk is an IN parameter -- that is already pointing to a Stack_Id. The secondary stack in this case - -- is fixed, and any attempt to allocated more than the initial size will + -- is fixed, and any attempt to allocate more than the initial size will -- result in a Storage_Error being raised. -- -- Note: the reason that Stk is passed is that SS_Init is called before -- 2.43.0