Commit 86e16c56 by Robert Dewar Committed by Arnaud Charlet

widechar.adb (Is_Start_Of_Wide_Char): In case of brackets encoding...

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

From-SVN: r118319
parent c0297c47
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment