From eb72521915b1f109b3b65aa384005c2527f76c31 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Mon, 30 Mar 2020 10:14:27 -0400 Subject: [Ada] Put_Image improvements for strings 2020-06-15 Bob Duff gcc/ada/ * exp_attr.adb (Put_Image): Use underlying type for strings. Remove unchecked union processing. * exp_put_image.adb (Tagged_Put_Image_Enabled): Use -gnatd_z to enable default Put_Image for tagged types. This allows testing that feature. (Build_String_Put_Image_Call): Set Conversion_OK flag. (Make_Component_List_Attributes): Remove unchecked union processing. (Enable_Put_Image): Disable for unchecked unions. Enable for nonscalar types (which were mistakenly disabled in earlier changes). * debug.adb: Document -gnatd_z switch. * libgnat/s-putima.adb (Put_Image_String, Put_Image_Wide_String, Put_Image_Wide_Wide_String): Double double-quote characters. Forget about special handling of control characters for now -- that's rare enough to not be a priority, and it's not clear what the right thing to do is anyway. * namet.adb: Minor: Improve debugger-friendliness. * sinfo.ads: Minor: Add "???" comment. --- gcc/ada/libgnat/s-putima.adb | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'gcc/ada/libgnat') diff --git a/gcc/ada/libgnat/s-putima.adb b/gcc/ada/libgnat/s-putima.adb index 50597b2..2f976ac 100644 --- a/gcc/ada/libgnat/s-putima.adb +++ b/gcc/ada/libgnat/s-putima.adb @@ -142,17 +142,25 @@ package body System.Put_Images is procedure Put_Image_String (S : in out Sink'Class; X : String) is begin - -- ????We should double double quotes, and maybe do something nice with - -- control characters. Put_UTF_8 (S, """"); - Put_String (S, X); + for C of X loop + if C = '"' then + Put_UTF_8 (S, """"); + end if; + Put_Character (S, C); + end loop; Put_UTF_8 (S, """"); end Put_Image_String; procedure Put_Image_Wide_String (S : in out Sink'Class; X : Wide_String) is begin Put_UTF_8 (S, """"); - Put_Wide_String (S, X); + for C of X loop + if C = '"' then + Put_UTF_8 (S, """"); + end if; + Put_Wide_Character (S, C); + end loop; Put_UTF_8 (S, """"); end Put_Image_Wide_String; @@ -160,7 +168,12 @@ package body System.Put_Images is (S : in out Sink'Class; X : Wide_Wide_String) is begin Put_UTF_8 (S, """"); - Put_Wide_Wide_String (S, X); + for C of X loop + if C = '"' then + Put_UTF_8 (S, """"); + end if; + Put_Wide_Wide_Character (S, C); + end loop; Put_UTF_8 (S, """"); end Put_Image_Wide_Wide_String; -- cgit v1.1