gcc.c-torture/execute: Fix tmpnam issue on Windows
2021-08-22 Jonathan Yong <10walls@gmail.com> gcc/testsuite/ChangeLog: * gcc.c-torture/execute/gcc_tmpnam.h: Fix tmpnam case on Windows where it can return a filename with "\" to indicate current directory. * gcc.c-torture/execute/fprintf-2.c: Use wrapper. * gcc.c-torture/execute/printf-2.c: Use wrapper. * gcc.c-torture/execute/user-printf.c: Use wrapper. Signed-off-by: Jonathan Yong <10walls@gmail.com>
This commit is contained in:
parent
5b2876f96c
commit
4a4616e53f
@ -9,10 +9,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "gcc_tmpnam.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
char *tmpfname = tmpnam (0);
|
||||
char *tmpfname = gcc_tmpnam (0);
|
||||
FILE *f = fopen (tmpfname, "w");
|
||||
if (!f)
|
||||
{
|
||||
|
13
gcc/testsuite/gcc.c-torture/execute/gcc_tmpnam.h
Normal file
13
gcc/testsuite/gcc.c-torture/execute/gcc_tmpnam.h
Normal file
@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#ifndef GCC_TMPNAM
|
||||
#define GCC_TMPNAM
|
||||
static inline char *gcc_tmpnam(char *s)
|
||||
{
|
||||
char *ret = tmpnam (s);
|
||||
// Windows sometimes prepends a backslash to denote the current directory,
|
||||
// so swallow that if it occurs
|
||||
if (ret[0] == '\\')
|
||||
++ret;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
@ -10,6 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "gcc_tmpnam.h"
|
||||
|
||||
__attribute__ ((noipa)) void
|
||||
write_file (void)
|
||||
@ -26,7 +27,7 @@ write_file (void)
|
||||
|
||||
int main (void)
|
||||
{
|
||||
char *tmpfname = tmpnam (0);
|
||||
char *tmpfname = gcc_tmpnam (0);
|
||||
FILE *f = freopen (tmpfname, "w", stdout);
|
||||
if (!f)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "gcc_tmpnam.h"
|
||||
|
||||
void __attribute__ ((format (printf, 1, 2), noipa))
|
||||
user_print (const char *fmt, ...)
|
||||
@ -23,7 +24,7 @@ user_print (const char *fmt, ...)
|
||||
|
||||
int main (void)
|
||||
{
|
||||
char *tmpfname = tmpnam (0);
|
||||
char *tmpfname = gcc_tmpnam (0);
|
||||
FILE *f = freopen (tmpfname, "w", stdout);
|
||||
if (!f)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user