summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-05 07:56:34 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-05 07:56:34 +0000
commit52df6c67c170d3fd4e596232b0fea78bf695af74 (patch)
treeef0b76f32135521b32eafcdd1dffd3eb629eb4fd
parent5136a343f985afff7daa6049e2f7ba1949319973 (diff)
downloadppe42-gcc-52df6c67c170d3fd4e596232b0fea78bf695af74.tar.gz
ppe42-gcc-52df6c67c170d3fd4e596232b0fea78bf695af74.zip
2005-09-01 Robert Dewar <dewar@adacore.com>
* 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 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103875 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/scng.adb10
-rw-r--r--gcc/ada/widechar.adb9
-rw-r--r--gcc/ada/widechar.ads7
3 files changed, 25 insertions, 1 deletions
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
OpenPOWER on IntegriCloud