comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado-Alves <amado.alves@gmail.com>
Subject: Get_Immediate does not read CR in CRLF pairs
Date: Mon, 7 Mar 2022 23:45:30 -0800 (PST)	[thread overview]
Message-ID: <1bd9b7ee-9195-44b3-8de2-c018a44b7eden@googlegroups.com> (raw)

Behaviour of Ada.Text_IO on GNAT/Windows 11:

(1) Get_Immediate does not read the CR in CRLF pairs

(2) Get_Immediate does not read the ending CRLF pair at all (in loop terminated upon End_Of_File)

(3) an extra ending CRLF pair is output

Does this behaviour follow from the ARM?
Do other compilers behave 'better'?

Sequential_IO instantiated with Character works correctly (so I am not blocked, just curious:-)

Thanks.
______
with Ada.Text_IO; use Ada.Text_IO;

procedure Get_Immediate_Test is
   C: Character;
   F_In: File_Type;
   F_Out: File_Type;

   procedure Default_Files_With_End_Of_File is
   begin
      while not End_Of_File loop
         Get_Immediate (C);
         Put (Character'Pos (C)'Img);
      end loop;
   end;

   procedure Default_Files_With_Exception is
   begin
      loop
         Get_Immediate (C);
         Put (Character'Pos (C)'Img);
      end loop;
   exception
      when others => null;
   end;

   procedure Named_Files_With_End_Of_File is
   begin
      Open (F_In, In_File, "imm_test_in_file.txt");
      Create (F_Out, Out_File, "imm_test_out_file.txt");
      while not End_Of_File loop
         Get_Immediate (F_In, C);
         Put (F_Out, Character'Pos (C)'Img);
      end loop;
      Close (F_In);
      Close (F_Out);
   end;

   procedure Named_Files_With_Exception is
   begin
      Open (F_In, In_File, "imm_test_in_file.txt");
      Create (F_Out, Out_File, "imm_test_out_file.txt");
      begin
         loop
            Get_Immediate (F_In, C);
            Put (F_Out, Character'Pos (C)'Img);
         end loop;
      exception
         when others =>
            Close (F_In);
            Close (F_Out);
      end;
   end;

begin
   Named_Files_With_Exception;
end;

             reply	other threads:[~2022-03-08  7:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08  7:45 Marius Amado-Alves [this message]
2022-03-08  7:46 ` Get_Immediate does not read CR in CRLF pairs Luke A. Guest
2022-03-08 12:08   ` Marius Amado-Alves
2022-03-08 14:57     ` Luke A. Guest
2022-03-08 16:43       ` Marius Amado-Alves
2022-03-08 17:21         ` Dennis Lee Bieber
2022-03-08 17:26         ` Dennis Lee Bieber
2022-03-09  9:11         ` Luke A. Guest
2022-03-08  8:03 ` Dmitry A. Kazakov
2022-03-08  9:06 ` Jeffrey R.Carter
2022-03-08 12:20   ` Marius Amado-Alves
2022-03-08 12:53     ` Dmitry A. Kazakov
2022-03-09 11:26       ` Marius Amado-Alves
2022-03-09 12:54         ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox