aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/s-fileio.adb
diff options
context:
space:
mode:
authorPascal Obry <obry@adacore.com>2014-07-18 10:56:54 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2014-07-18 12:56:54 +0200
commit18f2c4608d3bd85f19aef3068357f1c8fbe098b5 (patch)
tree623ebcb7d17d16425291f23fee7e8a60a5be9602 /gcc/ada/s-fileio.adb
parent19ac960acdc4d8b2212e49ff427c181c78a815cb (diff)
downloadgcc-18f2c4608d3bd85f19aef3068357f1c8fbe098b5.zip
gcc-18f2c4608d3bd85f19aef3068357f1c8fbe098b5.tar.gz
gcc-18f2c4608d3bd85f19aef3068357f1c8fbe098b5.tar.bz2
a-textio.adb: Rename Is_Text_File to Text_Encoding.
2014-07-18 Pascal Obry <obry@adacore.com> * a-textio.adb: Rename Is_Text_File to Text_Encoding. * a-ztexio.adb: Likewise. * a-witeio.adb: Likewise. (Open): Pass file's translation mode to set_text_mode. * s-ficobl.ads (Content_Encoding): New type. (Text_Content_Encoding): New subtype. (AFCB): Rename Is_Text_File to Text_Encoding. * s-fileio.adb (Open): Handles new text_translation values. Remove Is_Text_File which is equivalent to Text_Encoding in Text_Content_Encoding. * adaint.h (__gnat_set_mode): New routine. * sysdep.c (__gnat_set_wide_text_mode): Removed. (__gnat_set_mode): New routine. From-SVN: r212810
Diffstat (limited to 'gcc/ada/s-fileio.adb')
-rw-r--r--gcc/ada/s-fileio.adb46
1 files changed, 38 insertions, 8 deletions
diff --git a/gcc/ada/s-fileio.adb b/gcc/ada/s-fileio.adb
index 78dd34b..627224f 100644
--- a/gcc/ada/s-fileio.adb
+++ b/gcc/ada/s-fileio.adb
@@ -36,6 +36,7 @@ with Interfaces.C;
with Interfaces.C_Streams; use Interfaces.C_Streams;
with System.CRTL;
+
with System.Case_Util; use System.Case_Util;
with System.OS_Lib;
with System.Soft_Links;
@@ -958,7 +959,7 @@ package body System.File_IO is
Formstr : aliased String (1 .. Form'Length + 1);
-- Form string with ASCII.NUL appended, folded to lower case
- Is_Text_File : Boolean;
+ Text_Encoding : Content_Encoding;
Tempfile : constant Boolean := (Name'Length = 0);
-- Indicates temporary file case
@@ -1042,11 +1043,37 @@ package body System.File_IO is
-- if the Form says Text_Translation=No, we use binary mode, so new-line
-- will be just LF, even on Windows.
- Is_Text_File := Text;
+ if Text then
+ Text_Encoding := Default_Text;
+ else
+ Text_Encoding := None;
+ end if;
- if Is_Text_File then
- Is_Text_File :=
- Form_Boolean (Formstr, "text_translation", Default => True);
+ if Text_Encoding in Text_Content_Encoding then
+ declare
+ V1, V2 : Natural;
+
+ begin
+ Form_Parameter (Formstr, "text_translation", V1, V2);
+
+ if V1 = 0 then
+ null;
+ elsif Formstr (V1 .. V2) = "no" then
+ Text_Encoding := None;
+ elsif Formstr (V1 .. V2) = "text"
+ or else Formstr (V1 .. V2) = "yes"
+ then
+ Text_Encoding := File_Control_Block.Text;
+ elsif Formstr (V1 .. V2) = "wtext" then
+ Text_Encoding := Wtext;
+ elsif Formstr (V1 .. V2) = "u8text" then
+ Text_Encoding := U8text;
+ elsif Formstr (V1 .. V2) = "u16text" then
+ Text_Encoding := U16text;
+ else
+ raise Use_Error with "invalid Form";
+ end if;
+ end;
end if;
-- Acquire settings of target specific form parameters on VMS. Only
@@ -1200,7 +1227,9 @@ package body System.File_IO is
-- Open specified file if we did not find an existing stream
if Stream = NULL_Stream then
- Fopen_Mode (Mode, Is_Text_File, Creat, Amethod, Fopstr);
+ Fopen_Mode
+ (Mode, Text_Encoding in Text_Content_Encoding,
+ Creat, Amethod, Fopstr);
-- A special case, if we are opening (OPEN case) a file and the
-- mode returned by Fopen_Mode is not "r" or "r+", then we first
@@ -1274,7 +1303,7 @@ package body System.File_IO is
File_Ptr.Is_Regular_File := (is_regular_file (fileno (Stream)) /= 0);
File_Ptr.Is_System_File := False;
- File_Ptr.Is_Text_File := Is_Text_File;
+ File_Ptr.Text_Encoding := Text_Encoding;
File_Ptr.Shared_Status := Shared;
File_Ptr.Access_Method := Amethod;
File_Ptr.Stream := Stream;
@@ -1398,7 +1427,8 @@ package body System.File_IO is
else
Fopen_Mode
- (Mode, File.Is_Text_File, False, File.Access_Method, Fopstr);
+ (Mode, File.Text_Encoding in Text_Content_Encoding,
+ False, File.Access_Method, Fopstr);
Form_VMS_RMS_Keys (File.Form.all, VMS_Formstr);