Commit cd077efd by Pascal Obry Committed by Arnaud Charlet

a-textio.adb, [...]: Use C_Streams Default_Text.

2014-07-18  Pascal Obry  <obry@adacore.com>

	* a-textio.adb, a-witeio.adb, a-ztexio.adb: Use C_Streams Default_Text.
	* i-cstrea.ads (Content_Encoding): Moved here, add convention C.
	* s-ficobl.ads (Content_Encoding): Moved to C_Streams.
	* s-fileio.adb (Open): Adjust to use Content_Encoding from C_Streams.

From-SVN: r212811
parent 18f2c460
2014-07-18 Pascal Obry <obry@adacore.com> 2014-07-18 Pascal Obry <obry@adacore.com>
* a-textio.adb, a-witeio.adb, a-ztexio.adb: Use C_Streams Default_Text.
* i-cstrea.ads (Content_Encoding): Moved here, add convention C.
* s-ficobl.ads (Content_Encoding): Moved to C_Streams.
* s-fileio.adb (Open): Adjust to use Content_Encoding from C_Streams.
2014-07-18 Pascal Obry <obry@adacore.com>
* a-textio.adb: Rename Is_Text_File to Text_Encoding. * a-textio.adb: Rename Is_Text_File to Text_Encoding.
* a-ztexio.adb: Likewise. * a-ztexio.adb: Likewise.
* a-witeio.adb: Likewise. * a-witeio.adb: Likewise.
......
...@@ -921,7 +921,7 @@ package body Ada.Text_IO is ...@@ -921,7 +921,7 @@ package body Ada.Text_IO is
Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0; Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0;
Standard_Err.Is_Temporary_File := False; Standard_Err.Is_Temporary_File := False;
Standard_Err.Is_System_File := True; Standard_Err.Is_System_File := True;
Standard_Err.Text_Encoding := FCB.Default_Text; Standard_Err.Text_Encoding := Default_Text;
Standard_Err.Access_Method := 'T'; Standard_Err.Access_Method := 'T';
Standard_Err.Self := Standard_Err; Standard_Err.Self := Standard_Err;
Standard_Err.WC_Method := Default_WCEM; Standard_Err.WC_Method := Default_WCEM;
...@@ -933,7 +933,7 @@ package body Ada.Text_IO is ...@@ -933,7 +933,7 @@ package body Ada.Text_IO is
Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0; Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0;
Standard_In.Is_Temporary_File := False; Standard_In.Is_Temporary_File := False;
Standard_In.Is_System_File := True; Standard_In.Is_System_File := True;
Standard_In.Text_Encoding := FCB.Default_Text; Standard_In.Text_Encoding := Default_Text;
Standard_In.Access_Method := 'T'; Standard_In.Access_Method := 'T';
Standard_In.Self := Standard_In; Standard_In.Self := Standard_In;
Standard_In.WC_Method := Default_WCEM; Standard_In.WC_Method := Default_WCEM;
...@@ -945,7 +945,7 @@ package body Ada.Text_IO is ...@@ -945,7 +945,7 @@ package body Ada.Text_IO is
Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0; Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0;
Standard_Out.Is_Temporary_File := False; Standard_Out.Is_Temporary_File := False;
Standard_Out.Is_System_File := True; Standard_Out.Is_System_File := True;
Standard_Out.Text_Encoding := FCB.Default_Text; Standard_Out.Text_Encoding := Default_Text;
Standard_Out.Access_Method := 'T'; Standard_Out.Access_Method := 'T';
Standard_Out.Self := Standard_Out; Standard_Out.Self := Standard_Out;
Standard_Out.WC_Method := Default_WCEM; Standard_Out.WC_Method := Default_WCEM;
......
...@@ -892,7 +892,7 @@ package body Ada.Wide_Text_IO is ...@@ -892,7 +892,7 @@ package body Ada.Wide_Text_IO is
Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0; Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0;
Standard_Err.Is_Temporary_File := False; Standard_Err.Is_Temporary_File := False;
Standard_Err.Is_System_File := True; Standard_Err.Is_System_File := True;
Standard_Err.Text_Encoding := FCB.Default_Text; Standard_Err.Text_Encoding := Default_Text;
Standard_Err.Access_Method := 'T'; Standard_Err.Access_Method := 'T';
Standard_Err.Self := Standard_Err; Standard_Err.Self := Standard_Err;
Standard_Err.WC_Method := Default_WCEM; Standard_Err.WC_Method := Default_WCEM;
...@@ -904,7 +904,7 @@ package body Ada.Wide_Text_IO is ...@@ -904,7 +904,7 @@ package body Ada.Wide_Text_IO is
Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0; Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0;
Standard_In.Is_Temporary_File := False; Standard_In.Is_Temporary_File := False;
Standard_In.Is_System_File := True; Standard_In.Is_System_File := True;
Standard_In.Text_Encoding := FCB.Default_Text; Standard_In.Text_Encoding := Default_Text;
Standard_In.Access_Method := 'T'; Standard_In.Access_Method := 'T';
Standard_In.Self := Standard_In; Standard_In.Self := Standard_In;
Standard_In.WC_Method := Default_WCEM; Standard_In.WC_Method := Default_WCEM;
...@@ -916,7 +916,7 @@ package body Ada.Wide_Text_IO is ...@@ -916,7 +916,7 @@ package body Ada.Wide_Text_IO is
Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0; Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0;
Standard_Out.Is_Temporary_File := False; Standard_Out.Is_Temporary_File := False;
Standard_Out.Is_System_File := True; Standard_Out.Is_System_File := True;
Standard_Out.Text_Encoding := FCB.Default_Text; Standard_Out.Text_Encoding := Default_Text;
Standard_Out.Access_Method := 'T'; Standard_Out.Access_Method := 'T';
Standard_Out.Self := Standard_Out; Standard_Out.Self := Standard_Out;
Standard_Out.WC_Method := Default_WCEM; Standard_Out.WC_Method := Default_WCEM;
...@@ -1227,8 +1227,6 @@ package body Ada.Wide_Text_IO is ...@@ -1227,8 +1227,6 @@ package body Ada.Wide_Text_IO is
(File : File_Type; (File : File_Type;
Item : Wide_Character) Item : Wide_Character)
is is
use type FCB.Content_Encoding;
wide_text_translation_required : Boolean; wide_text_translation_required : Boolean;
for wide_text_translation_required'Size use Character'Size; for wide_text_translation_required'Size use Character'Size;
pragma Import (C, wide_text_translation_required, pragma Import (C, wide_text_translation_required,
...@@ -1259,11 +1257,9 @@ package body Ada.Wide_Text_IO is ...@@ -1259,11 +1257,9 @@ package body Ada.Wide_Text_IO is
FIO.Check_Write_Status (AP (File)); FIO.Check_Write_Status (AP (File));
if wide_text_translation_required if wide_text_translation_required
or else File.Text_Encoding /= FCB.Default_Text or else File.Text_Encoding /= Default_Text
then then
set_mode set_mode (fileno (File.Stream), File.Text_Encoding);
(fileno (File.Stream),
FCB.Text_Content_Encoding'Pos (File.Text_Encoding));
Discard := fputwc (Wide_Character'Pos (Item), File.Stream); Discard := fputwc (Wide_Character'Pos (Item), File.Stream);
else else
WC_Out (Item, File.WC_Method); WC_Out (Item, File.WC_Method);
......
...@@ -892,7 +892,7 @@ package body Ada.Wide_Wide_Text_IO is ...@@ -892,7 +892,7 @@ package body Ada.Wide_Wide_Text_IO is
Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0; Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0;
Standard_Err.Is_Temporary_File := False; Standard_Err.Is_Temporary_File := False;
Standard_Err.Is_System_File := True; Standard_Err.Is_System_File := True;
Standard_Err.Text_Encoding := FCB.Default_Text; Standard_Err.Text_Encoding := Default_Text;
Standard_Err.Access_Method := 'T'; Standard_Err.Access_Method := 'T';
Standard_Err.Self := Standard_Err; Standard_Err.Self := Standard_Err;
Standard_Err.WC_Method := Default_WCEM; Standard_Err.WC_Method := Default_WCEM;
...@@ -904,7 +904,7 @@ package body Ada.Wide_Wide_Text_IO is ...@@ -904,7 +904,7 @@ package body Ada.Wide_Wide_Text_IO is
Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0; Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0;
Standard_In.Is_Temporary_File := False; Standard_In.Is_Temporary_File := False;
Standard_In.Is_System_File := True; Standard_In.Is_System_File := True;
Standard_In.Text_Encoding := FCB.Default_Text; Standard_In.Text_Encoding := Default_Text;
Standard_In.Access_Method := 'T'; Standard_In.Access_Method := 'T';
Standard_In.Self := Standard_In; Standard_In.Self := Standard_In;
Standard_In.WC_Method := Default_WCEM; Standard_In.WC_Method := Default_WCEM;
...@@ -916,7 +916,7 @@ package body Ada.Wide_Wide_Text_IO is ...@@ -916,7 +916,7 @@ package body Ada.Wide_Wide_Text_IO is
Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0; Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0;
Standard_Out.Is_Temporary_File := False; Standard_Out.Is_Temporary_File := False;
Standard_Out.Is_System_File := True; Standard_Out.Is_System_File := True;
Standard_Out.Text_Encoding := FCB.Default_Text; Standard_Out.Text_Encoding := Default_Text;
Standard_Out.Access_Method := 'T'; Standard_Out.Access_Method := 'T';
Standard_Out.Self := Standard_Out; Standard_Out.Self := Standard_Out;
Standard_Out.WC_Method := Default_WCEM; Standard_Out.WC_Method := Default_WCEM;
......
...@@ -228,17 +228,31 @@ package Interfaces.C_Streams is ...@@ -228,17 +228,31 @@ package Interfaces.C_Streams is
-- versa. These functions have no effect if text_translation_required is -- versa. These functions have no effect if text_translation_required is
-- false (e.g. in normal unix mode). Use fileno to get a stream handle. -- false (e.g. in normal unix mode). Use fileno to get a stream handle.
procedure set_mode (handle : int; Mode : int); type Content_Encoding is (None, Default_Text, Text, U8text, Wtext, U16text);
-- As above but can set the handle to any mode. On Windows this can be used for Content_Encoding use (0, 1, 2, 3, 4, 5);
-- to have proper 16-bit wide-string output on the console for example. The pragma Convention (C, Content_Encoding);
-- mode value corresponds to Content_Encoding'Pos: -- Content_Encoding describes the text encoding for file content:
-- 0 = binary, equivalent to set_binary_mode -- None : No text encoding, this file is treated as a binary file
-- 1 = default mode, as set by the GNAT_CCS_ENCODING or equivalent to 2 -- Default_Text : A text file but not from Text_Translation form string
-- 2 = text, equivalent to set_text_mode -- In this mode we are eventually using the system-wide
-- 3 = u8text, set encoding to Unicode UTF-8 -- translation if activated.
-- 4 = wide-text, set encoding to Unicode -- Text : Text encoding activated
-- 5 = u16text, set encoding to Unicode UTF-16 -- Wtext : Unicode mode
-- Wouldn't it be better to use an enumeration type here??? -- U16text : Unicode UTF-16 encoding
-- U8text : Unicode UTF-8 encoding
--
-- This encoding is system dependent and only used on Windows systems.
--
-- Note that modifications to Content_Encoding must be synchronized
-- with sysdep.c:__gnat_set_mode.
subtype Text_Content_Encoding
is Content_Encoding range Default_Text .. U16text;
procedure set_mode (handle : int; Mode : Content_Encoding);
-- As above but can set the handle to any mode.
-- On Windows this can be used to have proper 16-bit wide-string output
-- on the console for example.
---------------------------- ----------------------------
-- Full Path Name support -- -- Full Path Name support --
......
...@@ -78,25 +78,6 @@ package System.File_Control_Block is ...@@ -78,25 +78,6 @@ package System.File_Control_Block is
-- stream with the semantics specified in the RM for file sharing. All -- stream with the semantics specified in the RM for file sharing. All
-- files opened with "shared=no" will have their own stream. -- files opened with "shared=no" will have their own stream.
type Content_Encoding is (None, Default_Text, Text, U8text, Wtext, U16text);
-- Described the text encoding for file content:
-- None : No text encoding, this file is treated as a binary file
-- Default_Text : A text file but not from Text_Translation form string
-- In this mode we are eventually using the system-wide
-- translation if activated.
-- Text : Text encoding activated
-- Wtext : Unicode mode
-- U16text : Unicode UTF-16 encoding
-- U8text : Unicode UTF-8 encoding
--
-- This encoding is system dependent and only used on Windows systems.
--
-- Note that modifications to Content_Encoding must be synchronized
-- with sysdep.c:__gnat_set_mode.
subtype Text_Content_Encoding
is Content_Encoding range Default_Text .. U16text;
type AFCB is tagged; type AFCB is tagged;
type AFCB_Ptr is access all AFCB'Class; type AFCB_Ptr is access all AFCB'Class;
...@@ -135,7 +116,7 @@ package System.File_Control_Block is ...@@ -135,7 +116,7 @@ package System.File_Control_Block is
Is_System_File : Boolean; Is_System_File : Boolean;
-- A flag set only for system files (stdin, stdout, stderr) -- A flag set only for system files (stdin, stdout, stderr)
Text_Encoding : Content_Encoding; Text_Encoding : Interfaces.C_Streams.Content_Encoding;
-- A flag set to describe file content encoding -- A flag set to describe file content encoding
Shared_Status : Shared_Status_Type; Shared_Status : Shared_Status_Type;
......
...@@ -1063,7 +1063,7 @@ package body System.File_IO is ...@@ -1063,7 +1063,7 @@ package body System.File_IO is
elsif Formstr (V1 .. V2) = "text" elsif Formstr (V1 .. V2) = "text"
or else Formstr (V1 .. V2) = "yes" or else Formstr (V1 .. V2) = "yes"
then then
Text_Encoding := File_Control_Block.Text; Text_Encoding := Interfaces.C_Streams.Text;
elsif Formstr (V1 .. V2) = "wtext" then elsif Formstr (V1 .. V2) = "wtext" then
Text_Encoding := Wtext; Text_Encoding := Wtext;
elsif Formstr (V1 .. V2) = "u8text" then elsif Formstr (V1 .. V2) = "u8text" then
......
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