~nytpu/tlsada

f6e9dad601c18de063eb6e7897afdc6949e649e8 — nytpu 1 year, 11 months ago ac6c35c
TLS.Get_Delim: Fix bug where End_Error would be raised instead of setting Encountered_Delim to False
2 files changed, 8 insertions(+), 12 deletions(-)

M src/tls.adb
M src/tls.ads
M src/tls.adb => src/tls.adb +7 -9
@@ 47,21 47,16 @@ package body TLS is
		C : Character;
		O : Unbounded_String := Null_Unbounded_String;
	begin
		-- Read an initial character outside the exception handler so the
		-- No_Available_Incoming will be propogated properly when starting to
		-- read a new line, but data won't be dropped once we've successfully
		-- read.
		Character'Read(Stream, C);
		Encountered_Delim := False;
		loop
			begin
				Character'Read(Stream, C);
				if Is_In(C, Delimeters) then
					Encountered_Delim := True;
					exit;
				end if;
				Append(O, C);
				exit when Max_Length > 0 and Length(O) >= Max_Length;
				Character'Read(Stream, C);

			exception
				when End_Error => exit;


@@ 82,13 77,16 @@ package body TLS is
		O : Unbounded_String := Null_Unbounded_String;
	begin
		Encountered_Delim := False;
		-- Same deal as the alternate Get_Delim version
		Character'Read(Stream, Sliding(Sliding'First));
		for I in Sliding'First + 1 .. Sliding'Last loop

		-- Fill the sliding buffer first before entering the main loop.
		for I in Sliding'First .. Sliding'Last loop
			begin
				Character'Read(Stream, Sliding(I));
			exception
				when End_Error =>
					if I = Sliding'First then
						return "";
					end if;
					return Sliding(Sliding'First .. I - 1);
			end;
		end loop;

M src/tls.ads => src/tls.ads +1 -3
@@ 30,9 30,7 @@ package TLS is
	-- Encountered_Delim will be set to True if the line was returned due to
	-- encountering a delimeter, and will be set to False if the line was
	-- returned due to reaching the end of the available data (i.e. an
	-- End_Error was raised).  In most situations, if Encountered_Delim is
	-- set to false then any future calls to Get_Delim will raise an End_Error
	-- unless new data has been made available.
	-- End_Error was raised).
	function Get_Delim (
		Stream : access Ada.Streams.Root_Stream_Type'Class;
		Delimeters : Character_Set;