OSDN Git Service

PR 33870
[pf3gnuchains/gcc-fork.git] / gcc / ada / output.ads
index fe881b8..95da496 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
+--          Copyright (C) 1992-2007, 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- --
 --  for writing error messages and informational output. It is also used
 --  by the debug source file output routines (see Sprintf.Print_Eol).
 
-with Types; use Types;
+with Hostparm; use Hostparm;
+with Types;    use Types;
 
 package Output is
-pragma Elaborate_Body (Output);
+   pragma Elaborate_Body;
 
    type Output_Proc is access procedure (S : String);
    --  This type is used for the Set_Special_Output procedure. If this
@@ -86,31 +87,60 @@ pragma Elaborate_Body (Output);
    --  Write one character to the standard output file. Note that the
    --  character should not be LF or CR (use Write_Eol for end of line)
 
+   procedure Write_Erase_Char (C : Character);
+   --  If last character in buffer matches C, erase it, otherwise no effect
+
    procedure Write_Eol;
    --  Write an end of line (whatever is required by the system in use,
    --  e.g. CR/LF for DOS, or LF for Unix) to the standard output file.
    --  This routine also empties the line buffer, actually writing it
    --  to the file. Note that Write_Eol is the only routine that causes
-   --  any actual output to be written.
+   --  any actual output to be written. Trailing spaces are removed.
+
+   procedure Write_Eol_Keep_Blanks;
+   --  Similar as Write_Eol, except that trailing spaces are not removed
 
    procedure Write_Int (Val : Int);
    --  Write an integer value with no leading blanks or zeroes. Negative
    --  values are preceded by a minus sign).
 
+   procedure Write_Spaces (N : Nat);
+   --  Write N spaces
+
    procedure Write_Str (S : String);
    --  Write a string of characters to the standard output file. Note that
-   --  end of line is handled separately using WRITE_EOL, so the string
-   --  should not contain either of the characters LF or CR, but it may
-   --  contain horizontal tab characters.
+   --  end of line is normally handled separately using WRITE_EOL, but it
+   --  is allowed for the string to contain LF (but not CR) characters,
+   --  which are properly interpreted as end of line characters. The string
+   --  may also contain horizontal tab characters.
 
    procedure Write_Line (S : String);
    --  Equivalent to Write_Str (S) followed by Write_Eol;
 
-   function Column return Nat;
+   function Column return Pos;
    pragma Inline (Column);
    --  Returns the number of the column about to be written (e.g. a value
    --  of 1 means the current line is empty).
 
+   -------------------------
+   -- Buffer Save/Restore --
+   -------------------------
+
+   --  This facility allows the current line buffer to be saved and restored
+
+   type Saved_Output_Buffer is private;
+   --  Type used for Save/Restore_Buffer
+
+   Buffer_Max : constant := Hostparm.Max_Line_Length;
+   --  Maximal size of a buffered output line
+
+   function Save_Output_Buffer return Saved_Output_Buffer;
+   --  Save current line buffer and reset line buffer to empty
+
+   procedure Restore_Output_Buffer (S : Saved_Output_Buffer);
+   --  Restore previously saved output buffer. The value in S is not affected
+   --  so it is legtimate to restore a buffer more than once.
+
    --------------------------
    -- Debugging Procedures --
    --------------------------
@@ -121,7 +151,7 @@ pragma Elaborate_Body (Output);
    --  names, precisely to make sure that they are only used for debugging!
 
    procedure w (C : Character);
-   --  Dump quote, character quote, followed by line return
+   --  Dump quote, character, quote, followed by line return
 
    procedure w (S : String);
    --  Dump string followed by line return
@@ -144,4 +174,28 @@ pragma Elaborate_Body (Output);
    procedure w (L : String; B : Boolean);
    --  Dump contents of string followed by blank, Boolean, line return
 
+private
+   --  Note: the following buffer and column position are maintained by the
+   --  subprograms defined in this package, and cannot be directly modified or
+   --  accessed by a client.
+
+   Buffer : String (1 .. Buffer_Max + 1);
+   for Buffer'Alignment use 4;
+   --  Buffer used to build output line. We do line buffering because it
+   --  is needed for the support of the debug-generated-code option (-gnatD).
+   --  Historically it was first added because on VMS, line buffering is
+   --  needed with certain file formats. So in any case line buffering must
+   --  be retained for this purpose, even if other reasons disappear. Note
+   --  any attempt to write more output to a line than can fit in the buffer
+   --  will be silently ignored. The alignment clause improves the efficiency
+   --  of the save/restore procedures.
+
+   Next_Col : Positive range 1 .. Buffer'Length + 1 := 1;
+   --  Column about to be written
+
+   type Saved_Output_Buffer is record
+      Buffer   : String (1 .. Buffer_Max + 1);
+      Next_Col : Positive;
+   end record;
+
 end Output;