diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-31 18:12:08 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-31 18:12:08 +0000 |
commit | ecbf3d7953068297861d48ee174694bb6eb79b59 (patch) | |
tree | 374d2d90cdcdd4dd3c0fb149432044df12f6fb67 /gcc/ada | |
parent | aaf3a95f087d99f677bd7ed8d0ca85b5ad0191b3 (diff) | |
download | gcc-ecbf3d7953068297861d48ee174694bb6eb79b59.tar.gz |
2006-10-31 Robert Dewar <dewar@adacore.com>
* widechar.adb (Is_Start_Of_Wide_Char): In case of brackets encoding,
add more precise check for the character sequence that follows '[' to
avoid possible confusion in case if '[' is the last character of a
string literals.
(Scan_Wide): Always allow brackets encoding
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118319 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/widechar.adb | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/gcc/ada/widechar.adb b/gcc/ada/widechar.adb index 31fedc48d11..49976958caf 100644 --- a/gcc/ada/widechar.adb +++ b/gcc/ada/widechar.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2006, 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- -- @@ -52,20 +52,35 @@ package body Widechar is is begin case Wide_Character_Encoding_Method is + + -- For Hex mode, just test for an ESC character. The ESC character + -- cannot appear in any other context in a legal Ada program. + when WCEM_Hex => return S (P) = ASCII.ESC; - when WCEM_Upper | - WCEM_Shift_JIS | - WCEM_EUC | - WCEM_UTF8 => - return S (P) >= Character'Val (16#80#); + -- For brackets, just test ["x where x is a hex character. This is + -- sufficient test, since this sequence cannot otherwise appear in a + -- legal Ada program. when WCEM_Brackets => return P <= S'Last - 2 and then S (P) = '[' and then S (P + 1) = '"' - and then S (P + 2) /= '"'; + and then (S (P + 2) in '0' .. '9' + or else + S (P + 2) in 'a' .. 'f' + or else + S (P + 2) in 'A' .. 'F'); + + -- All other encoding methods use the upper bit set in the first + -- character to uniquely represent a wide character. + + when WCEM_Upper | + WCEM_Shift_JIS | + WCEM_EUC | + WCEM_UTF8 => + return S (P) >= Character'Val (16#80#); end case; end Is_Start_Of_Wide_Char; @@ -89,6 +104,7 @@ package body Widechar is Err : out Boolean) is P_Init : constant Source_Ptr := P; + Chr : Character; function In_Char return Character; -- Function to obtain characters of wide character escape sequence @@ -108,7 +124,18 @@ package body Widechar is -- Start of processingf for Scan_Wide begin - C := Char_Code (WC_In (In_Char, Wide_Character_Encoding_Method)); + Chr := In_Char; + + -- Scan out the wide character. if the first character is a bracket, + -- we allow brackets encoding regardless of the standard encoding + -- method being used, but otherwise we use this standard method. + + if Chr = '[' then + C := Char_Code (WC_In (Chr, WCEM_Brackets)); + else + C := Char_Code (WC_In (Chr, Wide_Character_Encoding_Method)); + end if; + Err := False; Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1); |