Patchwork [Ada] Refactoring of Ada.Text_IO.Put

login
register
mail settings
Submitter Arnaud Charlet
Date Jan. 23, 2012, 8:33 a.m.
Message ID <20120123083344.GA22182@adacore.com>
Download mbox | patch
Permalink /patch/137292/
State New
Headers show

Comments

Arnaud Charlet - Jan. 23, 2012, 8:33 a.m.
This change reorganizes code to avoid gratuitous duplication.
No behaviour change, no test.

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

2012-01-23  Thomas Quinot  <quinot@adacore.com>

	* a-textio.adb (Put): Rewrite one-parameter Character version to
	just call the two-parameter one with Current_Out.

Patch

Index: a-textio.adb
===================================================================
--- a-textio.adb	(revision 183406)
+++ a-textio.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, 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- --
@@ -1274,30 +1274,7 @@ 
 
    procedure Put (Item : Character) is
    begin
-      FIO.Check_Write_Status (AP (Current_Out));
-
-      if Current_Out.Line_Length /= 0
-        and then Current_Out.Col > Current_Out.Line_Length
-      then
-         New_Line (Current_Out);
-      end if;
-
-      --  If lower half character, or brackets encoding, output directly
-
-      if Character'Pos (Item) < 16#80#
-        or else Default_WCEM = WCEM_Brackets
-      then
-         if fputc (Character'Pos (Item), Current_Out.Stream) = EOF then
-            raise Device_Error;
-         end if;
-
-      --  Case of upper half character with non-brackets encoding
-
-      else
-         Put_Encoded (Current_Out, Item);
-      end if;
-
-      Current_Out.Col := Current_Out.Col + 1;
+      Put (Current_Out, Item);
    end Put;
 
    ---------