From: Robert Dewar Date: Mon, 5 Sep 2005 07:56:34 +0000 (+0200) Subject: scng.adb (Check_End_Of_Line): Count characters, rather than bytes (makes a difference... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d52f1094e50cf2120eebc5bf2a63ed0aa56c825a;p=gcc.git scng.adb (Check_End_Of_Line): Count characters, rather than bytes (makes a difference for wide characters) 2005-09-01 Robert Dewar * scng.adb (Check_End_Of_Line): Count characters, rather than bytes (makes a difference for wide characters) * widechar.adb, widechar.ads: Add Wide_Char_Byte_Count feature to count chars vs bytes From-SVN: r103875 --- diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb index 74fdc14a37a..9d3483e8251 100644 --- a/gcc/ada/scng.adb +++ b/gcc/ada/scng.adb @@ -257,6 +257,7 @@ package body Scng is First_Non_Blank_Location := Scan_Ptr; Initialize_Checksum; + Wide_Char_Byte_Count := 0; -- Do not call Scan, otherwise the License stuff does not work in Scn @@ -340,7 +341,10 @@ package body Scng is ----------------------- procedure Check_End_Of_Line is - Len : constant Int := Int (Scan_Ptr) - Int (Current_Line_Start); + Len : constant Int := + Int (Scan_Ptr) - + Int (Current_Line_Start) - + Wide_Char_Byte_Count; begin if Style_Check then @@ -362,6 +366,10 @@ package body Scng is elsif Len > Opt.Max_Line_Length then Error_Long_Line; end if; + + -- Reset wide character byte count for next line + + Wide_Char_Byte_Count := 0; end Check_End_Of_Line; ----------------------- diff --git a/gcc/ada/widechar.adb b/gcc/ada/widechar.adb index 9641251d181..e1999286e49 100644 --- a/gcc/ada/widechar.adb +++ b/gcc/ada/widechar.adb @@ -88,6 +88,8 @@ package body Widechar is C : out Char_Code; Err : out Boolean) is + P_Init : constant Source_Ptr := P; + function In_Char return Character; -- Function to obtain characters of wide character escape sequence @@ -108,6 +110,7 @@ package body Widechar is begin C := Char_Code (WC_In (In_Char, Wide_Character_Encoding_Method)); Err := False; + Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1); exception when Constraint_Error => @@ -151,6 +154,8 @@ package body Widechar is --------------- procedure Skip_Wide (S : String; P : in out Natural) is + P_Init : constant Natural := P; + function Skip_Char return Character; -- Function to skip one character of wide character escape sequence @@ -173,6 +178,7 @@ package body Widechar is begin Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method); + Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1); end Skip_Wide; --------------- @@ -180,6 +186,8 @@ package body Widechar is --------------- procedure Skip_Wide (S : Source_Buffer_Ptr; P : in out Source_Ptr) is + P_Init : constant Source_Ptr := P; + function Skip_Char return Character; -- Function to skip one character of wide character escape sequence @@ -202,6 +210,7 @@ package body Widechar is begin Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method); + Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1); end Skip_Wide; end Widechar; diff --git a/gcc/ada/widechar.ads b/gcc/ada/widechar.ads index 4f561584efe..cc0ab34a022 100644 --- a/gcc/ada/widechar.ads +++ b/gcc/ada/widechar.ads @@ -40,6 +40,13 @@ with Types; use Types; package Widechar is + Wide_Char_Byte_Count : Nat := 0; + -- This value is incremented whenever Scan_Wide or Skip_Wide is called. + -- The amount added is the length of the wide character sequence minus + -- one. This means that the count that accululates here represents the + -- difference between the length in characters and the length in bytes. + -- This is used for checking the line length in characters. + function Length_Wide return Nat; -- Returns the maximum length in characters for the escape sequence that -- is used to encode wide character literals outside the ASCII range. Used