Natools

Check-in [e66be760b0]
Login
Overview
Comment:s_expressions-printers-pretty: add an assert on final cursor position after writing quoted strings
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e66be760b05e788acb2f7d1032b3cf9dafc6a1ab
User & Date: nat on 2014-07-25 20:07:26
Other Links: manifest | tags
Context
2014-07-27
17:32
s_expressions-printers-pretty: fix cursor position after writing a quoted string check-in: 8fffe1590c user: nat tags: trunk
2014-07-25
20:07
s_expressions-printers-pretty: add an assert on final cursor position after writing quoted strings check-in: e66be760b0 user: nat tags: trunk
2014-07-24
18:59
s_expressions-printers-pretty: fix Fit_In_Line width test check-in: fc581ebd8d user: nat tags: trunk
Changes

Modified src/natools-s_expressions-printers-pretty.adb from [11731ef9d6] to [0e61f6dceb].

562
563
564
565
566
567
568

569
570
571
572
573
574
575
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576







+







      procedure Escape
        (Value : in Octet;
         Result : in out Atom;
         Pos : in Offset);

      Size : Count;
      Last_Non_NL : Offset := Data'Last;
      Expected_Cursor : Screen_Offset := Output.Cursor;

      procedure Escape
        (Value : in Octet;
         Result : in out Atom;
         Pos : in Offset) is
      begin
         Result (Pos) := Encodings.Escape;
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602








603
604
605
606
607
608
609
610
586
587
588
589
590
591
592











593
594
595
596
597
598
599
600

601
602
603
604
605
606
607







-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-







                 (Value,
                  Output.Param.Hex_Casing,
                  Result (Pos + 2),
                  Result (Pos + 3));
         end case;
      end Escape;
   begin
      declare
         Discarded_Cursor : Screen_Offset := Output.Cursor;
      begin
         Quoted_Lengths
           (Data,
            Output.Param.Char_Encoding,
            Output.Param.Width,
            Output.Param.Newline,
            Single_Line,
            Size,
            Discarded_Cursor);
      Quoted_Lengths
        (Data,
         Output.Param.Char_Encoding,
         Output.Param.Width,
         Output.Param.Newline,
         Single_Line,
         Size,
         Expected_Cursor);
      end;

      while Last_Non_NL in Data'Range
        and then (Data (Last_Non_NL) = Encodings.CR
                  or Data (Last_Non_NL) = Encodings.LF)
      loop
         Last_Non_NL := Last_Non_NL - 1;
      end loop;
754
755
756
757
758
759
760


761
762
763
764
765
766
767
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766







+
+







         end loop;

         pragma Assert (O = Result'Last);
         Result (O) := Encodings.Quoted_Atom_End;

         Write_Raw (Printer'Class (Output), Result);
      end;

      pragma Assert (Output.Cursor = Expected_Cursor);
   end Write_Quoted;


   procedure Write_Verbatim (Output : in out Printer; Data : in Atom) is
      Length_Image : constant String := Count'Image (Data'Length);
      Prefix : Atom (0 .. Length_Image'Length - 1);
   begin