mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-14 22:01:17 +08:00
[multiple changes]
2009-04-17 Eric Botcazou <ebotcazou@adacore.com> * exp_ch4.adb (Expand_Concatenation): Do not use calls at -Os. 2009-04-17 Pascal Obry <obry@adacore.com> * mingw32.h: Add S2WSC and WS2SC macros to convert to/from CurrentCodePage. * adaint.h: Encoding_Unspecified is now defined. Corresponds to the value when no encoding form paramter is set on Text_IO services. * adaint.c: CurrentCodePage new variable on Windows. Use new macros S2WSC and WS2SC instead of the UTF-8 oriented ones. * mkdir.c: Use new macros S2WSC and WS2SC instead of the UTF-8 oriented ones. * initialize.c: Initialize CurrentCodePage depending on GNAT_CODE_PAGE environment variable value. Default is UTF-8. * s-crtl.ads: Filename_Encoding add Unspecified in the enumeration type. fopen and freopen encoding parameter is now set to Unspecified. The default value is in this case UTF-8 (as it was before) but use the new macros that convert to/from the code page set at runtime (CurrentCodePage). * s-fileio.adb: When no encoding specified use Unspecified value. 2009-04-17 Ed Schonberg <schonberg@adacore.com> * atree.adb, atree.ads: Remove dead code. From-SVN: r146235
This commit is contained in:
parent
432e3422d0
commit
ffec8e81da
@ -1,3 +1,37 @@
|
||||
2009-04-17 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* exp_ch4.adb (Expand_Concatenation): Do not use calls at -Os.
|
||||
|
||||
2009-04-17 Pascal Obry <obry@adacore.com>
|
||||
|
||||
* mingw32.h: Add S2WSC and WS2SC macros to convert to/from
|
||||
CurrentCodePage.
|
||||
|
||||
* adaint.h: Encoding_Unspecified is now defined. Corresponds to the
|
||||
value when no encoding form paramter is set on Text_IO services.
|
||||
|
||||
* adaint.c: CurrentCodePage new variable on Windows.
|
||||
Use new macros S2WSC and WS2SC instead of the UTF-8 oriented
|
||||
ones.
|
||||
|
||||
* mkdir.c: Use new macros S2WSC and WS2SC instead of the UTF-8 oriented
|
||||
ones.
|
||||
|
||||
* initialize.c: Initialize CurrentCodePage depending on GNAT_CODE_PAGE
|
||||
environment variable value. Default is UTF-8.
|
||||
|
||||
* s-crtl.ads: Filename_Encoding add Unspecified in the enumeration type.
|
||||
fopen and freopen encoding parameter is now set to Unspecified.
|
||||
The default value is in this case UTF-8 (as it was before) but
|
||||
use the new macros that convert to/from the code page set
|
||||
at runtime (CurrentCodePage).
|
||||
|
||||
* s-fileio.adb: When no encoding specified use Unspecified value.
|
||||
|
||||
2009-04-17 Ed Schonberg <schonberg@adacore.com>
|
||||
|
||||
* atree.adb, atree.ads: Remove dead code.
|
||||
|
||||
2009-04-17 Arnaud Charlet <charlet@adacore.com>
|
||||
|
||||
* gcc-interface/Make-lang.in: Update dependencies.
|
||||
|
@ -82,6 +82,9 @@
|
||||
#include <Rtapi.h>
|
||||
#else
|
||||
#include "mingw32.h"
|
||||
|
||||
/* Current code page to use, set in initialize.c. */
|
||||
UINT CurrentCodePage;
|
||||
#endif
|
||||
|
||||
#include <sys/utime.h>
|
||||
@ -482,8 +485,8 @@ __gnat_try_lock (char *dir, char *file)
|
||||
TCHAR wfile[GNAT_MAX_PATH_LEN];
|
||||
TCHAR wdir[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wdir, dir, GNAT_MAX_PATH_LEN);
|
||||
S2WSU (wfile, file, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wdir, dir, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wfile, file, GNAT_MAX_PATH_LEN);
|
||||
|
||||
_stprintf (wfull_path, _T("%s%c%s"), wdir, _T(DIR_SEPARATOR), wfile);
|
||||
fd = _topen (wfull_path, O_CREAT | O_EXCL, 0600);
|
||||
@ -585,7 +588,7 @@ __gnat_get_current_dir (char *dir, int *length)
|
||||
|
||||
_tgetcwd (wdir, *length);
|
||||
|
||||
WS2SU (dir, wdir, GNAT_MAX_PATH_LEN);
|
||||
WS2SC (dir, wdir, GNAT_MAX_PATH_LEN);
|
||||
|
||||
#elif defined (VMS)
|
||||
/* Force Unix style, which is what GNAT uses internally. */
|
||||
@ -662,7 +665,7 @@ __gnat_os_filename (char *filename, char *w_filename ATTRIBUTE_UNUSED,
|
||||
char *encoding ATTRIBUTE_UNUSED, int *e_length)
|
||||
{
|
||||
#if defined (_WIN32) && ! defined (__vxworks) && ! defined (CROSS_DIRECTORY_STRUCTURE)
|
||||
WS2SU (os_name, (TCHAR *)w_filename, o_length);
|
||||
WS2SC (os_name, (TCHAR *)w_filename, o_length);
|
||||
*o_length = strlen (os_name);
|
||||
strcpy (encoding, "encoding=utf8");
|
||||
*e_length = strlen (encoding);
|
||||
@ -682,7 +685,7 @@ __gnat_unlink (char *path)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
return _tunlink (wpath);
|
||||
}
|
||||
#else
|
||||
@ -699,8 +702,8 @@ __gnat_rename (char *from, char *to)
|
||||
{
|
||||
TCHAR wfrom[GNAT_MAX_PATH_LEN], wto[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wfrom, from, GNAT_MAX_PATH_LEN);
|
||||
S2WSU (wto, to, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wfrom, from, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wto, to, GNAT_MAX_PATH_LEN);
|
||||
return _trename (wfrom, wto);
|
||||
}
|
||||
#else
|
||||
@ -717,7 +720,7 @@ __gnat_chdir (char *path)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
return _tchdir (wpath);
|
||||
}
|
||||
#else
|
||||
@ -734,7 +737,7 @@ __gnat_rmdir (char *path)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
return _trmdir (wpath);
|
||||
}
|
||||
#else
|
||||
@ -751,7 +754,9 @@ __gnat_fopen (char *path, char *mode, int encoding ATTRIBUTE_UNUSED)
|
||||
|
||||
S2WS (wmode, mode, 10);
|
||||
|
||||
if (encoding == Encoding_UTF8)
|
||||
if (encoding == Encoding_Unspecified)
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
else if (encoding == Encoding_UTF8)
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
else
|
||||
S2WS (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
@ -773,7 +778,9 @@ __gnat_freopen (char *path, char *mode, FILE *stream, int encoding ATTRIBUTE_UNU
|
||||
|
||||
S2WS (wmode, mode, 10);
|
||||
|
||||
if (encoding == Encoding_UTF8)
|
||||
if (encoding == Encoding_Unspecified)
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
else if (encoding == Encoding_UTF8)
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
else
|
||||
S2WS (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
@ -805,7 +812,7 @@ __gnat_open_read (char *path, int fmode)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
fd = _topen (wpath, O_RDONLY | o_fmode, 0444);
|
||||
}
|
||||
#else
|
||||
@ -846,7 +853,7 @@ __gnat_open_rw (char *path, int fmode)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
fd = _topen (wpath, O_RDWR | o_fmode, PERM);
|
||||
}
|
||||
#else
|
||||
@ -872,7 +879,7 @@ __gnat_open_create (char *path, int fmode)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
fd = _topen (wpath, O_WRONLY | O_CREAT | O_TRUNC | o_fmode, PERM);
|
||||
}
|
||||
#else
|
||||
@ -894,7 +901,7 @@ __gnat_create_output_file (char *path)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
fd = _topen (wpath, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT, PERM);
|
||||
}
|
||||
#else
|
||||
@ -920,7 +927,7 @@ __gnat_open_append (char *path, int fmode)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
fd = _topen (wpath, O_WRONLY | O_CREAT | O_APPEND | o_fmode, PERM);
|
||||
}
|
||||
#else
|
||||
@ -948,7 +955,7 @@ __gnat_open_new (char *path, int fmode)
|
||||
{
|
||||
TCHAR wpath[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
|
||||
fd = _topen (wpath, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
|
||||
}
|
||||
#else
|
||||
@ -1101,7 +1108,7 @@ DIR* __gnat_opendir (char *name)
|
||||
#elif defined (__MINGW32__)
|
||||
TCHAR wname[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN);
|
||||
return (DIR*)_topendir (wname);
|
||||
|
||||
#else
|
||||
@ -1125,7 +1132,7 @@ __gnat_readdir (DIR *dirp, char *buffer, int *len)
|
||||
|
||||
if (dirent != NULL)
|
||||
{
|
||||
WS2SU (buffer, dirent->d_name, GNAT_MAX_PATH_LEN);
|
||||
WS2SC (buffer, dirent->d_name, GNAT_MAX_PATH_LEN);
|
||||
*len = strlen (buffer);
|
||||
|
||||
return buffer;
|
||||
@ -1231,7 +1238,7 @@ __gnat_file_time_name (char *name)
|
||||
time_t ret = -1;
|
||||
TCHAR wname[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN);
|
||||
|
||||
HANDLE h = CreateFile
|
||||
(wname, GENERIC_READ, FILE_SHARE_READ, 0,
|
||||
@ -1368,7 +1375,7 @@ __gnat_set_file_time_name (char *name, time_t time_stamp)
|
||||
} t_write;
|
||||
TCHAR wname[GNAT_MAX_PATH_LEN];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN);
|
||||
|
||||
HANDLE h = CreateFile
|
||||
(wname, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
|
||||
@ -1631,7 +1638,7 @@ __gnat_stat (char *name, struct stat *statbuf)
|
||||
int name_len;
|
||||
TCHAR last_char;
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
name_len = _tcslen (wname);
|
||||
|
||||
if (name_len > GNAT_MAX_PATH_LEN)
|
||||
@ -1667,7 +1674,7 @@ __gnat_file_exists (char *name)
|
||||
offset the _stat() routine fails on specific files like CON: */
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
return GetFileAttributes (wname) != INVALID_FILE_ATTRIBUTES;
|
||||
#else
|
||||
struct stat statbuf;
|
||||
@ -1851,7 +1858,7 @@ __gnat_is_readable_file (char *name)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
GENERIC_MAPPING GenericMapping;
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
|
||||
ZeroMemory (&GenericMapping, sizeof (GENERIC_MAPPING));
|
||||
GenericMapping.GenericRead = GENERIC_READ;
|
||||
@ -1875,7 +1882,7 @@ __gnat_is_writable_file (char *name)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
GENERIC_MAPPING GenericMapping;
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
|
||||
ZeroMemory (&GenericMapping, sizeof (GENERIC_MAPPING));
|
||||
GenericMapping.GenericWrite = GENERIC_WRITE;
|
||||
@ -1901,7 +1908,7 @@ __gnat_is_executable_file (char *name)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
GENERIC_MAPPING GenericMapping;
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
|
||||
ZeroMemory (&GenericMapping, sizeof (GENERIC_MAPPING));
|
||||
GenericMapping.GenericExecute = GENERIC_EXECUTE;
|
||||
@ -1924,7 +1931,7 @@ __gnat_set_writable (char *name)
|
||||
#if defined (_WIN32) && !defined (RTX)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
|
||||
__gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_WRITE);
|
||||
SetFileAttributes
|
||||
@ -1946,7 +1953,7 @@ __gnat_set_executable (char *name)
|
||||
#if defined (_WIN32) && !defined (RTX)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
|
||||
__gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_EXECUTE);
|
||||
#elif ! defined (__vxworks) && ! defined(__nucleus__)
|
||||
@ -1966,7 +1973,7 @@ __gnat_set_non_writable (char *name)
|
||||
#if defined (_WIN32) && !defined (RTX)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
|
||||
__gnat_set_OWNER_ACL
|
||||
(wname, DENY_ACCESS,
|
||||
@ -1991,7 +1998,7 @@ __gnat_set_readable (char *name)
|
||||
#if defined (_WIN32) && !defined (RTX)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
|
||||
__gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_READ);
|
||||
#elif ! defined (__vxworks) && ! defined(__nucleus__)
|
||||
@ -2010,7 +2017,7 @@ __gnat_set_non_readable (char *name)
|
||||
#if defined (_WIN32) && !defined (RTX)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
|
||||
S2WSU (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
|
||||
|
||||
__gnat_set_OWNER_ACL (wname, DENY_ACCESS, FILE_GENERIC_READ);
|
||||
#elif ! defined (__vxworks) && ! defined(__nucleus__)
|
||||
@ -2285,7 +2292,7 @@ win32_no_block_spawn (char *command, char *args[])
|
||||
int wsize = csize * 2;
|
||||
TCHAR *wcommand = (TCHAR *) xmalloc (wsize);
|
||||
|
||||
S2WSU (wcommand, full_command, wsize);
|
||||
S2WSC (wcommand, full_command, wsize);
|
||||
|
||||
free (full_command);
|
||||
|
||||
@ -2581,7 +2588,7 @@ __gnat_locate_exec_on_path (char *exec_name)
|
||||
|
||||
apath_val = alloca (EXPAND_BUFFER_SIZE);
|
||||
|
||||
WS2SU (apath_val, wapath_val, EXPAND_BUFFER_SIZE);
|
||||
WS2SC (apath_val, wapath_val, EXPAND_BUFFER_SIZE);
|
||||
return __gnat_locate_exec (exec_name, apath_val);
|
||||
|
||||
#else
|
||||
|
@ -39,8 +39,9 @@
|
||||
#include <dirent.h>
|
||||
|
||||
/* Constants used for the form parameter encoding values */
|
||||
#define Encoding_UTF8 0
|
||||
#define Encoding_8bits 1
|
||||
#define Encoding_UTF8 0 /* UTF-8 */
|
||||
#define Encoding_8bits 1 /* Standard 8bits, CP_ACP on Windows. */
|
||||
#define Encoding_Unspecified 2 /* Based on GNAT_CODE_PAGE env variable. */
|
||||
|
||||
typedef long OS_Time; /* Type corresponding to GNAT.OS_Lib.OS_Time */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -430,46 +430,6 @@ package Atree is
|
||||
-- Source to be Empty, in which case Relocate_Node simply returns
|
||||
-- Empty as the result.
|
||||
|
||||
function New_Copy_Tree1
|
||||
(Source : Node_Id;
|
||||
Map : Elist_Id := No_Elist;
|
||||
New_Sloc : Source_Ptr := No_Location;
|
||||
New_Scope : Entity_Id := Empty) return Node_Id;
|
||||
-- Given a node that is the root of a subtree, Copy_Tree copies the entire
|
||||
-- syntactic subtree, including recursively any descendents whose parent
|
||||
-- field references a copied node (descendents not linked to a copied node
|
||||
-- by the parent field are not copied, instead the copied tree references
|
||||
-- the same descendent as the original in this case, which is appropriate
|
||||
-- for non-syntactic fields such as Etype). The parent pointers in the
|
||||
-- copy are properly set. Copy_Tree (Empty/Error) returns Empty/Error.
|
||||
-- The one exception to the rule of not copying semantic fields is that
|
||||
-- any implicit types attached to the subtree are duplicated, so that
|
||||
-- the copy contains a distinct set of implicit type entities. The Map
|
||||
-- argument, if set to a non-empty Elist, specifies a set of mappings
|
||||
-- to be applied to entities in the tree. The map has the form:
|
||||
--
|
||||
-- old entity 1
|
||||
-- new entity to replace references to entity 1
|
||||
-- old entity 2
|
||||
-- new entity to replace references to entity 2
|
||||
-- ...
|
||||
--
|
||||
-- The call destroys the contents of Map in this case
|
||||
--
|
||||
-- The parameter New_Sloc, if set to a value other than No_Location, is
|
||||
-- used as the Sloc value for all nodes in the new copy. If New_Sloc is
|
||||
-- set to its default value No_Location, then the Sloc values of the
|
||||
-- nodes in the copy are simply copied from the corresponding original.
|
||||
--
|
||||
-- The Comes_From_Source indication is unchanged if New_Sloc is set to
|
||||
-- the default No_Location value, but is reset if New_Sloc is given, since
|
||||
-- in this case the result clearly is neither a source node or an exact
|
||||
-- copy of a source node.
|
||||
--
|
||||
-- The parameter New_Scope, if set to a value other than Empty, is the
|
||||
-- value to use as the Scope for any Itypes that are copied. The most
|
||||
-- typical value for this parameter, if given, is Current_Scope.
|
||||
|
||||
function Copy_Separate_Tree (Source : Node_Id) return Node_Id;
|
||||
-- Given a node that is the root of a subtree, Copy_Separate_Tree copies
|
||||
-- the entire syntactic subtree, including recursively any descendants
|
||||
|
@ -2822,7 +2822,7 @@ package body Exp_Ch4 is
|
||||
|
||||
-- There are nine or fewer retained (non-null) operands
|
||||
|
||||
-- The optimization level is -O0 or -Os
|
||||
-- The optimization level is -O0
|
||||
|
||||
-- The corresponding System.Concat_n.Str_Concat_n routine is
|
||||
-- available in the run time.
|
||||
@ -2835,9 +2835,7 @@ package body Exp_Ch4 is
|
||||
|
||||
if Atyp = Standard_String
|
||||
and then NN in 2 .. 9
|
||||
and then (Opt.Optimization_Level = 0
|
||||
or else Opt.Optimize_Size /= 0
|
||||
or else Debug_Flag_Dot_CC)
|
||||
and then (Opt.Optimization_Level = 0 or else Debug_Flag_Dot_CC)
|
||||
and then not Debug_Flag_Dot_C
|
||||
then
|
||||
declare
|
||||
|
@ -81,6 +81,22 @@ __gnat_initialize (void *eh)
|
||||
given that we have set Max_Digits etc with this in mind */
|
||||
__gnat_init_float ();
|
||||
|
||||
#ifdef GNAT_UNICODE_SUPPORT
|
||||
/* Set current code page for filenames handling. */
|
||||
{
|
||||
char *codepage = getenv ("GNAT_CODE_PAGE");
|
||||
|
||||
/* Default code page is UTF-8. */
|
||||
CurrentCodePage = CP_UTF8;
|
||||
|
||||
if (codepage != NULL)
|
||||
if (strcmp (codepage, "CP_ACP") == 0)
|
||||
CurrentCodePage = CP_ACP;
|
||||
else if (strcmp (codepage, "CP_UTF8") == 0)
|
||||
CurrentCodePage = CP_UTF8;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Adjust gnat_argv to support Unicode characters. */
|
||||
{
|
||||
char arg_utf8[MAX_PATH];
|
||||
@ -97,7 +113,7 @@ __gnat_initialize (void *eh)
|
||||
|
||||
for (k=0; k<wargc; k++)
|
||||
{
|
||||
WS2SU (arg_utf8, wargv[k], MAX_PATH);
|
||||
WS2SC (arg_utf8, wargv[k], MAX_PATH);
|
||||
gnat_argv[k] = (char *) xmalloc (strlen (arg_utf8) + 1);
|
||||
strcpy (gnat_argv[k], arg_utf8);
|
||||
}
|
||||
|
@ -62,6 +62,7 @@
|
||||
#endif
|
||||
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
/* After including this file it is possible to use the character t as prefix
|
||||
to routines. If GNAT_UNICODE_SUPPORT is defined then the unicode enabled
|
||||
@ -71,10 +72,22 @@
|
||||
the proper translations using the UTF-8 encoding. */
|
||||
|
||||
#ifdef GNAT_UNICODE_SUPPORT
|
||||
|
||||
extern UINT CurrentCodePage;
|
||||
|
||||
/* Macros to convert to/from the code page speficied in CurrentCodePage. */
|
||||
#define S2WSC(wstr,str,len) \
|
||||
MultiByteToWideChar (CurrentCodePage,0,str,-1,wstr,len)
|
||||
#define WS2SC(str,wstr,len) \
|
||||
WideCharToMultiByte (CurrentCodePage,0,wstr,-1,str,len,NULL,NULL)
|
||||
|
||||
/* Macros to convert to/from UTF-8 code page. */
|
||||
#define S2WSU(wstr,str,len) \
|
||||
MultiByteToWideChar (CP_UTF8,0,str,-1,wstr,len)
|
||||
#define WS2SU(str,wstr,len) \
|
||||
WideCharToMultiByte (CP_UTF8,0,wstr,-1,str,len,NULL,NULL)
|
||||
|
||||
/* Macros to convert to/from Windows default code page. */
|
||||
#define S2WS(wstr,str,len) \
|
||||
MultiByteToWideChar (CP_ACP,0,str,-1,wstr,len)
|
||||
#define WS2S(str,wstr,len) \
|
||||
|
@ -65,7 +65,7 @@ __gnat_mkdir (char *dir_name)
|
||||
#elif defined (__MINGW32__)
|
||||
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
|
||||
|
||||
S2WSU (wname, dir_name, GNAT_MAX_PATH_LEN + 2);
|
||||
S2WSC (wname, dir_name, GNAT_MAX_PATH_LEN + 2);
|
||||
return _tmkdir (wname);
|
||||
#else
|
||||
return mkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
|
@ -55,8 +55,8 @@ package System.CRTL is
|
||||
|
||||
type size_t is mod 2 ** Standard'Address_Size;
|
||||
|
||||
type Filename_Encoding is (UTF8, ASCII_8bits);
|
||||
for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1);
|
||||
type Filename_Encoding is (UTF8, ASCII_8bits, Unspecified);
|
||||
for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1, Unspecified => 2);
|
||||
pragma Convention (C, Filename_Encoding);
|
||||
-- Describes the filename's encoding
|
||||
|
||||
@ -90,7 +90,7 @@ package System.CRTL is
|
||||
function fopen
|
||||
(filename : chars;
|
||||
mode : chars;
|
||||
encoding : Filename_Encoding := UTF8) return FILEs;
|
||||
encoding : Filename_Encoding := Unspecified) return FILEs;
|
||||
pragma Import (C, fopen, "__gnat_fopen");
|
||||
|
||||
function fputc (C : int; stream : FILEs) return int;
|
||||
@ -106,7 +106,7 @@ package System.CRTL is
|
||||
(filename : chars;
|
||||
mode : chars;
|
||||
stream : FILEs;
|
||||
encoding : Filename_Encoding := UTF8) return FILEs;
|
||||
encoding : Filename_Encoding := Unspecified) return FILEs;
|
||||
pragma Import (C, freopen, "__gnat_freopen");
|
||||
|
||||
function fseek
|
||||
|
@ -809,7 +809,7 @@ package body System.File_IO is
|
||||
Form_Parameter (Formstr, "encoding", V1, V2);
|
||||
|
||||
if V1 = 0 then
|
||||
Encoding := System.CRTL.UTF8;
|
||||
Encoding := System.CRTL.Unspecified;
|
||||
|
||||
elsif Formstr (V1 .. V2) = "utf8" then
|
||||
Encoding := System.CRTL.UTF8;
|
||||
|
Loading…
x
Reference in New Issue
Block a user