diff options
author | Robert Dewar <dewar@adacore.com> | 2007-12-13 11:29:24 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2007-12-13 11:29:24 +0100 |
commit | b26b5a8f52b45dcbe796cb472997b844b5b22c5d (patch) | |
tree | 43bd0ad62150abfc2319fc29f19db59d9db58ebc /gcc/ada/scn.adb | |
parent | 150bbaff610db5c17dd906a39a2f0453d78ab6b8 (diff) | |
download | gcc-b26b5a8f52b45dcbe796cb472997b844b5b22c5d.zip gcc-b26b5a8f52b45dcbe796cb472997b844b5b22c5d.tar.gz gcc-b26b5a8f52b45dcbe796cb472997b844b5b22c5d.tar.bz2 |
g-byorma.adb, [...]: New files.
2007-12-06 Robert Dewar <dewar@adacore.com>
* g-byorma.adb, g-byorma.ads, g-decstr.adb, g-decstr.ads,
g-deutst.ads, g-encstr.adb, g-encstr.ads, g-enutst.ads: New files.
* scn.adb: Implement BOM recognition
From-SVN: r130849
Diffstat (limited to 'gcc/ada/scn.adb')
-rw-r--r-- | gcc/ada/scn.adb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ada/scn.adb b/gcc/ada/scn.adb index f970d84..d4e7bd3 100644 --- a/gcc/ada/scn.adb +++ b/gcc/ada/scn.adb @@ -28,6 +28,7 @@ with Csets; use Csets; with Hostparm; use Hostparm; with Namet; use Namet; with Opt; use Opt; +with Output; use Output; with Restrict; use Restrict; with Rident; use Rident; with Scans; use Scans; @@ -35,6 +36,10 @@ with Sinfo; use Sinfo; with Sinput; use Sinput; with Uintp; use Uintp; +with GNAT.Byte_Order_Mark; use GNAT.Byte_Order_Mark; + +with System.WCh_Con; use System.WCh_Con; + package body Scn is use ASCII; @@ -266,6 +271,42 @@ package body Scn is Set_License (Current_Source_File, Determine_License); end if; + -- Check for BOM + + declare + BOM : BOM_Kind; + Len : Natural; + Tst : String (1 .. 5); + + begin + for J in 1 .. 5 loop + Tst (J) := Source (Scan_Ptr + Source_Ptr (J) - 1); + end loop; + + Read_BOM (Tst, Len, BOM, False); + + case BOM is + when UTF8_All => + Scan_Ptr := Scan_Ptr + Source_Ptr (Len); + Wide_Character_Encoding_Method := WCEM_UTF8; + Upper_Half_Encoding := True; + + when UTF16_LE | UTF16_BE => + Write_Line ("UTF-16 encoding format not recognized"); + raise Unrecoverable_Error; + + when UTF32_LE | UTF32_BE => + Write_Line ("UTF-32 encoding format not recognized"); + raise Unrecoverable_Error; + + when Unknown => + null; + + when others => + raise Program_Error; + end case; + end; + -- Because of the License stuff above, Scng.Initialize_Scanner cannot -- call Scan. Scan initial token (note this initializes Prev_Token, -- Prev_Token_Ptr). |