unix.c (raw_truncate): Explicit cast from integer-scal to pointer.
2010-04-30 Kai Tietz <kai.tietz@onevision.com> PR/43844 * io/unix.c (raw_truncate): Explicit cast from integer-scal to pointer. (empfile): Use for mingw GetTempPath and avoid double slash for path. From-SVN: r158925
This commit is contained in:
parent
4be68d9a2d
commit
e7fc9c75d0
@ -1,3 +1,11 @@
|
|||||||
|
2010-04-30 Kai Tietz <kai.tietz@onevision.com>
|
||||||
|
|
||||||
|
PR/43844
|
||||||
|
* io/unix.c (raw_truncate): Explicit cast from integer-scalar
|
||||||
|
to pointer.
|
||||||
|
(empfile): Use for mingw GetTempPath and avoid double slash
|
||||||
|
for path.
|
||||||
|
|
||||||
2010-04-24 Kai Tietz <kai.tietz@onevision.com>
|
2010-04-24 Kai Tietz <kai.tietz@onevision.com>
|
||||||
|
|
||||||
PR/43844
|
PR/43844
|
||||||
|
@ -308,7 +308,7 @@ raw_truncate (unix_stream * s, gfc_offset length)
|
|||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
h = _get_osfhandle (s->fd);
|
h = (HANDLE) _get_osfhandle (s->fd);
|
||||||
if (h == INVALID_HANDLE_VALUE)
|
if (h == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
@ -877,20 +877,45 @@ tempfile (st_parameter_open *opp)
|
|||||||
{
|
{
|
||||||
const char *tempdir;
|
const char *tempdir;
|
||||||
char *template;
|
char *template;
|
||||||
|
const char *slash = "/";
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
tempdir = getenv ("GFORTRAN_TMPDIR");
|
tempdir = getenv ("GFORTRAN_TMPDIR");
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
if (tempdir == NULL)
|
||||||
|
{
|
||||||
|
char buffer[MAX_PATH + 1];
|
||||||
|
DWORD ret;
|
||||||
|
ret = GetTempPath (MAX_PATH, buffer);
|
||||||
|
/* If we are not able to get a temp-directory, we use
|
||||||
|
current directory. */
|
||||||
|
if (ret > MAX_PATH || !ret)
|
||||||
|
buffer[0] = 0;
|
||||||
|
else
|
||||||
|
buffer[ret] = 0;
|
||||||
|
tempdir = strdup (buffer);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (tempdir == NULL)
|
if (tempdir == NULL)
|
||||||
tempdir = getenv ("TMP");
|
tempdir = getenv ("TMP");
|
||||||
if (tempdir == NULL)
|
if (tempdir == NULL)
|
||||||
tempdir = getenv ("TEMP");
|
tempdir = getenv ("TEMP");
|
||||||
if (tempdir == NULL)
|
if (tempdir == NULL)
|
||||||
tempdir = DEFAULT_TEMPDIR;
|
tempdir = DEFAULT_TEMPDIR;
|
||||||
|
#endif
|
||||||
|
/* Check for special case that tempdir contains slash
|
||||||
|
or backslash at end. */
|
||||||
|
if (*tempdir == 0 || tempdir[strlen (tempdir) - 1] == '/'
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
|| tempdir[strlen (tempdir) - 1] == '\\'
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
slash = "";
|
||||||
|
|
||||||
template = get_mem (strlen (tempdir) + 20);
|
template = get_mem (strlen (tempdir) + 20);
|
||||||
|
|
||||||
#ifdef HAVE_MKSTEMP
|
#ifdef HAVE_MKSTEMP
|
||||||
sprintf (template, "%s/gfortrantmpXXXXXX", tempdir);
|
sprintf (template, "%s%sgfortrantmpXXXXXX", tempdir, slash);
|
||||||
|
|
||||||
fd = mkstemp (template);
|
fd = mkstemp (template);
|
||||||
|
|
||||||
@ -898,7 +923,7 @@ tempfile (st_parameter_open *opp)
|
|||||||
fd = -1;
|
fd = -1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
sprintf (template, "%s/gfortrantmpXXXXXX", tempdir);
|
sprintf (template, "%s%sgfortrantmpXXXXXX", tempdir, slash);
|
||||||
if (!mktemp (template))
|
if (!mktemp (template))
|
||||||
break;
|
break;
|
||||||
#if defined(HAVE_CRLF) && defined(O_BINARY)
|
#if defined(HAVE_CRLF) && defined(O_BINARY)
|
||||||
@ -909,7 +934,6 @@ tempfile (st_parameter_open *opp)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
while (fd == -1 && errno == EEXIST);
|
while (fd == -1 && errno == EEXIST);
|
||||||
|
|
||||||
#endif /* HAVE_MKSTEMP */
|
#endif /* HAVE_MKSTEMP */
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user