comp.lang.ada
 help / color / mirror / Atom feed
* Get_Immediate does not read CR in CRLF pairs
@ 2022-03-08  7:45 Marius Amado-Alves
  2022-03-08  7:46 ` Luke A. Guest
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Marius Amado-Alves @ 2022-03-08  7:45 UTC (permalink / 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;

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-03-09 12:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08  7:45 Get_Immediate does not read CR in CRLF pairs Marius Amado-Alves
2022-03-08  7:46 ` 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

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