From 60b2207a469a5a1e7a7e5619a8eb1b01c67f314a Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 10 Feb 2017 18:41:36 +1100 Subject: Preference data reads into Bundles properly, with packed memory and a few fixed bugs --- src/csv.adb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/csv.adb') diff --git a/src/csv.adb b/src/csv.adb index 1b8fd7f..6bc5880 100644 --- a/src/csv.adb +++ b/src/csv.adb @@ -22,10 +22,11 @@ package body CSV is then Result := SU.To_Unbounded_String (0); This_In := SU.Tail (Input, SU.Length (Input) - 1); - while SU.Length (This_In) > 0 loop + while SU.Length (This_In) > 0 and then + SU.Element (This_In, 1) /= Quote + loop SU.Append (Result, SU.Head (This_In, 1)); This_In := SU.Tail (This_In, SU.Length (This_In) - 1); - exit when SU.Length (This_In) > 0 and then SU.Element (This_In, 1) = Quote; end loop; Output := Result; if SU.Length (This_In) > 0 then @@ -111,14 +112,12 @@ package body CSV is function Separator (Input : in SU.Unbounded_String; - Output : out SU.Unbounded_String; Remaining : out SU.Unbounded_String) return Boolean is begin if SU.Length (Input) > 0 and then SU.Element (Input, 1) = Delimiter then - Output := SU.Head (Input, 1); Remaining := SU.Tail (Input, SU.Length (Input) - 1); return True; else @@ -140,9 +139,7 @@ package body CSV is loop Field (This_In, This_Out, This_Remaining); Result.Append (This_Out); - This_In := This_Remaining; - exit when not Separator (This_In, This_Out, This_Remaining); - This_In := This_Remaining; + exit when not Separator (This_Remaining, This_In); end loop; return Result; end Parse_Line; -- cgit