===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -65,6 +65,10 @@ package body System.Val_Char is
end if;
end loop;
+ if S (F .. L) = "SOFT_HYPHEN" then
+ return Character'Val (16#AD#);
+ end if;
+
raise Constraint_Error;
end if;
end Value_Character;
===================================================================
@@ -306,8 +306,16 @@ package body Exp_Imgv is
Imid := RE_Image_Boolean;
Tent := Rtyp;
+ -- For standard character, we have to select the version which handles
+ -- soft hyphen correctly, based on the version of Ada in use (ugly!)
+
elsif Rtyp = Standard_Character then
- Imid := RE_Image_Character;
+ if Ada_Version < Ada_05 then
+ Imid := RE_Image_Character;
+ else
+ Imid := RE_Image_Character_05;
+ end if;
+
Tent := Rtyp;
elsif Rtyp = Standard_Wide_Character then
===================================================================
@@ -800,6 +800,7 @@ package Rtsfind is
RE_Image_Boolean, -- System.Img_Bool
RE_Image_Character, -- System.Img_Char
+ RE_Image_Character_05, -- System.Img_Char
RE_Image_Decimal, -- System.Img_Dec
@@ -1972,6 +1973,7 @@ package Rtsfind is
RE_Image_Boolean => System_Img_Bool,
RE_Image_Character => System_Img_Char,
+ RE_Image_Character_05 => System_Img_Char,
RE_Image_Decimal => System_Img_Dec,
===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -61,6 +61,16 @@ package body System.Img_WChar is
P := 4;
+ -- Deal with annoying Ada 95 incompatibility with soft hyphen
+
+ elsif V = Wide_Character'Val (16#00AD#)
+ and then not Ada_2005
+ then
+ P := 3;
+ S (1) := ''';
+ S (2) := Character'Val (16#00AD#);
+ S (3) := ''';
+
-- Normal case, same as Wide_Wide_Character
else
@@ -83,10 +93,14 @@ package body System.Img_WChar is
Val : Unsigned_32 := Wide_Wide_Character'Pos (V);
begin
- -- If in range of standard Character, use Character routine
+ -- If in range of standard Character, use Character routine. Use the
+ -- Ada 2005 version, since either we are called directly in Ada 2005
+ -- mode for Wide_Wide_Character, or this is the Wide_Character case
+ -- which already took care of the Soft_Hyphen glitch.
if Val <= 16#FF# then
- Image_Character (Character'Val (Wide_Wide_Character'Pos (V)), S, P);
+ Image_Character_05
+ (Character'Val (Wide_Wide_Character'Pos (V)), S, P);
-- Otherwise value returned is Hex_hhhhhhhh
===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -158,4 +158,23 @@ package body System.Img_Char is
end if;
end Image_Character;
+ ------------------------
+ -- Image_Character_05 --
+ ------------------------
+
+ procedure Image_Character_05
+ (V : Character;
+ S : in out String;
+ P : out Natural)
+ is
+ pragma Assert (S'First = 1);
+ begin
+ if V = Character'Val (16#00AD#) then
+ P := 11;
+ S (1 .. P) := "SOFT_HYPHEN";
+ else
+ Image_Character (V, S, P);
+ end if;
+ end Image_Character_05;
+
end System.Img_Char;
===================================================================
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
+-- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -42,4 +42,14 @@ package System.Img_Char is
-- setting the resulting value of P. The caller guarantees that S is
-- long enough to hold the result, and that S'First is 1.
+ procedure Image_Character_05
+ (V : Character;
+ S : in out String;
+ P : out Natural);
+ -- Computes Character'Image (V) and stores the result in S (1 .. P)
+ -- setting the resulting value of P. The caller guarantees that S is
+ -- long enough to hold the result, and that S'First is 1. This version
+ -- is for use in Ada 2005 and beyond, where soft hyphen is a non-graphic
+ -- and results in "SOFT_HYPHEN" as the output.
+
end System.Img_Char;
===================================================================
@@ -7413,7 +7413,6 @@ package body Sem_Attr is
-- No need to compute this more than once!
- W := Int'Max (W, 12);
exit;
else
@@ -7427,13 +7426,11 @@ package body Sem_Attr is
case C is
when Reserved_128 | Reserved_129 |
Reserved_132 | Reserved_153
-
=> Wt := 12;
when BS | HT | LF | VT | FF | CR |
SO | SI | EM | FS | GS | RS |
US | RI | MW | ST | PM
-
=> Wt := 2;
when NUL | SOH | STX | ETX | EOT |
@@ -7445,13 +7442,20 @@ package body Sem_Attr is
SS2 | SS3 | DCS | PU1 | PU2 |
STS | CCH | SPA | EPA | SOS |
SCI | CSI | OSC | APC
-
=> Wt := 3;
when Space .. Tilde |
No_Break_Space .. LC_Y_Diaeresis
+ =>
+ -- Special case of soft hyphen in Ada 2005
- => Wt := 3;
+ if C = Character'Val (16#AD#)
+ and then Ada_Version >= Ada_05
+ then
+ Wt := 11;
+ else
+ Wt := 3;
+ end if;
end case;
W := Int'Max (W, Wt);