diff options
author | Pascal Obry <obry@adacore.com> | 2007-05-02 08:43:30 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2007-05-02 10:43:30 +0200 |
commit | d7598e110d060f8b7fb6598736f68700b20c400f (patch) | |
tree | a90e9a876adb1767b44b61c579a73fec97fa0c8e /gcc/ada/adaint.c | |
parent | 9a60b02d977835f3e7c132c529380e89821c0405 (diff) | |
download | gcc-d7598e110d060f8b7fb6598736f68700b20c400f.zip gcc-d7598e110d060f8b7fb6598736f68700b20c400f.tar.gz gcc-d7598e110d060f8b7fb6598736f68700b20c400f.tar.bz2 |
re PR ada/29856 (broken if..else in gcc/ada/adaint.c)
2007-04-20 Pascal Obry <obry@adacore.com>
* gnatchop.adb (Write_Source_Reference_Pragma): Change implementation
to use Stream_IO.File_Type. This is needed to make use of the UTF-8
encoding support of Stream_IO.
(Write_Unit): Idem.
* adaint.h, adaint.c (__gnat_os_filename): New routine. Returns the
filename and corresponding encoding to match the OS requirement.
(__gnat_file_exists): Do not call __gnat_stat() on Windows as this
routine will fail on specific devices like CON: AUX: ...
PR ada/29856: Add missing braces
From-SVN: r124347
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r-- | gcc/ada/adaint.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 9952bc8..ff2d0a4 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2006, Free Software Foundation, Inc. * + * Copyright (C) 1992-2007, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -619,6 +619,25 @@ __gnat_get_debuggable_suffix_ptr (int *len, const char **value) return; } +/* Returns the OS filename and corresponding encoding. */ + +void +__gnat_os_filename (char *filename, char *w_filename, + char *os_name, int *o_length, + char *encoding, int *e_length) +{ +#if defined (_WIN32) && ! defined (__vxworks) && ! defined (CROSS_DIRECTORY_STRUCTURE) + WS2SU (os_name, (TCHAR *)w_filename, o_length); + *o_length = strlen (os_name); + strcpy (encoding, "encoding=utf8"); + *e_length = strlen (encoding); +#else + strcpy (os_name, filename); + *o_length = strlen (filename); + *e_length = 0; +#endif +} + FILE * __gnat_fopen (char *path, char *mode, int encoding) { @@ -991,8 +1010,10 @@ __gnat_readdir (DIR *dirp, char *buffer, int *len) #elif defined (HAVE_READDIR_R) /* If possible, try to use the thread-safe version. */ if (readdir_r (dirp, buffer) != NULL) - *len = strlen (((struct dirent*) buffer)->d_name); - return ((struct dirent*) buffer)->d_name; + { + *len = strlen (((struct dirent*) buffer)->d_name); + return ((struct dirent*) buffer)->d_name; + } else return NULL; @@ -1513,9 +1534,19 @@ __gnat_stat (char *name, struct stat *statbuf) int __gnat_file_exists (char *name) { +#ifdef __MINGW32__ + /* On Windows do not use __gnat_stat() because a bug in Microsoft + _stat() routine. When the system time-zone is set with a negative + 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); + return GetFileAttributes (wname) != INVALID_FILE_ATTRIBUTES; +#else struct stat statbuf; return !__gnat_stat (name, &statbuf); +#endif } int |