home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / g-io.adb < prev    next >
Text File  |  2000-07-19  |  4KB  |  133 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                              G N A T . I O                               --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.9 $
  10. --                                                                          --
  11. --           Copyright (C) 1995-2000 Ada Core Technologies, Inc.            --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).   --
  32. --                                                                          --
  33. ------------------------------------------------------------------------------
  34.  
  35. package body GNAT.IO is
  36.  
  37.    ---------
  38.    -- Get --
  39.    ---------
  40.  
  41.    procedure Get (X : out Integer) is
  42.  
  43.       function Get_Int return Integer;
  44.       pragma Import (C, Get_Int, "get_int");
  45.  
  46.    begin
  47.       X := Get_Int;
  48.    end Get;
  49.  
  50.    procedure Get (C : out Character) is
  51.  
  52.       function Get_Char return Character;
  53.       pragma Import (C, Get_Char, "get_char");
  54.  
  55.    begin
  56.       C := Get_Char;
  57.    end Get;
  58.  
  59.    --------------
  60.    -- Get_Line --
  61.    --------------
  62.  
  63.    procedure Get_Line (Item : in out String; Last : out Natural) is
  64.       C : Character;
  65.  
  66.    begin
  67.       for Nstore in Item'Range loop
  68.          Get (C);
  69.  
  70.          if C = ASCII.LF then
  71.             Last := Nstore - 1;
  72.             return;
  73.  
  74.          else
  75.             Item (Nstore) := C;
  76.          end if;
  77.       end loop;
  78.  
  79.       Last := Item'Last;
  80.    end Get_Line;
  81.  
  82.    --------------
  83.    -- New_Line --
  84.    --------------
  85.  
  86.    procedure New_Line (Spacing : Positive := 1) is
  87.    begin
  88.       for J in 1 .. Spacing loop
  89.          Put (ASCII.LF);
  90.       end loop;
  91.    end New_Line;
  92.  
  93.    ---------
  94.    -- Put --
  95.    ---------
  96.  
  97.    procedure Put (X : Integer) is
  98.  
  99.       procedure Put_Int (X : Integer);
  100.       pragma Import (C, Put_Int, "put_int");
  101.  
  102.    begin
  103.       Put_Int (X);
  104.    end Put;
  105.  
  106.    procedure Put (C : Character) is
  107.  
  108.       procedure Put_Char (C : Character);
  109.       pragma Import (C, Put_Char, "put_char");
  110.  
  111.    begin
  112.       Put_Char (C);
  113.    end Put;
  114.  
  115.    procedure Put (S : String) is
  116.    begin
  117.       for J in S'Range loop
  118.          Put (S (J));
  119.       end loop;
  120.    end Put;
  121.  
  122.    --------------
  123.    -- Put_Line --
  124.    --------------
  125.  
  126.    procedure Put_Line (S : String) is
  127.    begin
  128.       Put (S);
  129.       New_Line;
  130.    end Put_Line;
  131.  
  132. end GNAT.IO;
  133.