diff options
-rw-r--r-- | gcc/ada/s-wchwts.adb | 12 | ||||
-rw-r--r-- | gcc/ada/s-wchwts.ads | 3 |
2 files changed, 8 insertions, 7 deletions
diff --git a/gcc/ada/s-wchwts.adb b/gcc/ada/s-wchwts.adb index ed660fefc0f..1dc2fce4a87 100644 --- a/gcc/ada/s-wchwts.adb +++ b/gcc/ada/s-wchwts.adb @@ -88,16 +88,16 @@ package body System.WCh_WtS is (S : Wide_String; EM : WC_Encoding_Method) return String is - R : String (1 .. 5 * S'Length); -- worst case length! + R : String (S'First .. S'First + 5 * S'Length); -- worst case length! RP : Natural; begin - RP := 0; + RP := R'First - 1; for SP in S'Range loop Store_UTF_32_Character (Wide_Character'Pos (S (SP)), R, RP, EM); end loop; - return R (1 .. RP); + return R (R'First .. RP); end Wide_String_To_String; -------------------------------- @@ -108,17 +108,17 @@ package body System.WCh_WtS is (S : Wide_Wide_String; EM : WC_Encoding_Method) return String is - R : String (1 .. 7 * S'Length); -- worst case length! + R : String (S'First .. S'First + 7 * S'Length); -- worst case length! RP : Natural; begin - RP := 0; + RP := R'First - 1; for SP in S'Range loop Store_UTF_32_Character (Wide_Wide_Character'Pos (S (SP)), R, RP, EM); end loop; - return R (1 .. RP); + return R (R'First .. RP); end Wide_Wide_String_To_String; end System.WCh_WtS; diff --git a/gcc/ada/s-wchwts.ads b/gcc/ada/s-wchwts.ads index 691a322ea6c..4f8bfcf4014 100644 --- a/gcc/ada/s-wchwts.ads +++ b/gcc/ada/s-wchwts.ads @@ -54,7 +54,8 @@ package System.WCh_WtS is -- that normal (non-wide character) mode holds at the start and end of -- the result string. EM indicates the wide character encoding method. -- Note: in the WCEM_Brackets case, we only use the brackets encoding - -- for characters greater than 16#FF#. + -- for characters greater than 16#FF#. The lowest index of the returned + -- String is equal to S'First. function Wide_Wide_String_To_String (S : Wide_Wide_String; |