diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-27 12:55:18 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-27 12:55:18 +0000 |
commit | 12760d32ae6c63daa4ff31a261f0ee8aab0f3958 (patch) | |
tree | 3b852b556143ed9a1fe9a1f0c8a1c04e811bffd3 /gcc/ada/a-textio.adb | |
parent | 9b29458da8153174e43b7183b2ce4f47f4836a19 (diff) | |
download | gcc-12760d32ae6c63daa4ff31a261f0ee8aab0f3958.tar.gz |
2016-04-27 Bob Duff <duff@adacore.com>
* a-coinve.adb, a-comutr.adb, a-conhel.adb, a-convec.adb,
exp_util.adb: Remove assertions that can fail in obscure cases when
assertions are turned on but tampering checks are turned off.
2016-04-27 Javier Miranda <miranda@adacore.com>
* exp_ch6.adb (Add_Call_By_Copy_Code,
Add_Simple_Call_By_Copy_Code, Expand_Actuals): Handle formals
whose type comes from the limited view.
2016-04-27 Yannick Moy <moy@adacore.com>
* a-textio.adb: Complete previous patch.
2016-04-27 Yannick Moy <moy@adacore.com>
* inline.adb (Expand_Inlined_Call): Use Cannot_Inline instead of
Error_Msg_N to issue message about impossibility to inline call,
with slight change of message.
2016-04-27 Hristian Kirtchev <kirtchev@adacore.com>
* exp_spark.adb (Expand_Potential_Renaming): Removed.
(Expand_SPARK): Update the call to expand a potential renaming.
(Expand_SPARK_Potential_Renaming): New routine.
* exp_spark.ads (Expand_SPARK_Potential_Renaming): New routine.
* sem.adb Add with and use clauses for Exp_SPARK.
(Analyze): Expand a non-overloaded potential renaming for SPARK.
2016-04-27 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Constrain_Discriminated_Type): In an instance,
check full view for the presence of defaulted discriminants,
even when the partial view of a private type has no visible and
no unknown discriminants.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235497 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-textio.adb')
-rw-r--r-- | gcc/ada/a-textio.adb | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/gcc/ada/a-textio.adb b/gcc/ada/a-textio.adb index 61d6accc078..59f9190ac18 100644 --- a/gcc/ada/a-textio.adb +++ b/gcc/ada/a-textio.adb @@ -714,11 +714,12 @@ package body Ada.Text_IO is function Get_Rest (S : String) return String is - -- Each time we allocate a buffer the same size as what we have - -- read so far. This limits us to a logarithmic number of calls - -- to Get_Rest and also ensures only a linear use of stack space. + -- The first time we allocate a buffer of size 500. Each following + -- time we allocate a buffer the same size as what we have read so + -- far. This limits us to a logarithmic number of calls to Get_Rest + -- and also ensures only a linear use of stack space. - Buffer : String (1 .. S'Length); + Buffer : String (1 .. Integer'Max (500, S'Length)); Last : Natural; begin @@ -731,43 +732,26 @@ package body Ada.Text_IO is return R; else - return Get_Rest (R); + pragma Assert (Last = Buffer'Last); + + -- If the String has the same length as the buffer, and there + -- is no end of line, check whether we are at the end of file, + -- in which case we have the full String in the buffer. + + if End_Of_File (File) then + return R; + + else + return Get_Rest (R); + end if; end if; end; end Get_Rest; - -- Local variables - - Buffer : String (1 .. 500); - ch : int; - Last : Natural; - -- Start of processing for Get_Line begin - Get_Line (File, Buffer, Last); - - if Last < Buffer'Last then - return Buffer (1 .. Last); - - -- If the String has the same length as the buffer, and there is no end - -- of line, check whether we are at the end of file, in which case we - -- have the full String in the buffer. - - elsif Last = Buffer'Last then - ch := Getc (File); - - if ch = EOF then - return Buffer; - - else - Ungetc (ch, File); - return Get_Rest (Buffer (1 .. Last)); - end if; - - else - return Get_Rest (Buffer (1 .. Last)); - end if; + return Get_Rest (""); end Get_Line; function Get_Line return String is |