public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3062] gcc.c-torture/execute: Fix tmpnam issue on Windows
@ 2021-08-23 2:16 Jonathan Yong
0 siblings, 0 replies; only message in thread
From: Jonathan Yong @ 2021-08-23 2:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4a4616e53f440e15d0f3e91e23b67a3b5c84dddf
commit r12-3062-g4a4616e53f440e15d0f3e91e23b67a3b5c84dddf
Author: Jonathan Yong <10walls@gmail.com>
Date: Sun Aug 22 03:05:07 2021 +0000
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>
Diff:
---
gcc/testsuite/gcc.c-torture/execute/fprintf-2.c | 3 ++-
gcc/testsuite/gcc.c-torture/execute/gcc_tmpnam.h | 13 +++++++++++++
gcc/testsuite/gcc.c-torture/execute/printf-2.c | 3 ++-
gcc/testsuite/gcc.c-torture/execute/user-printf.c | 3 ++-
4 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/gcc/testsuite/gcc.c-torture/execute/fprintf-2.c b/gcc/testsuite/gcc.c-torture/execute/fprintf-2.c
index d8e19e7b2f8..00517d1d1ac 100644
--- a/gcc/testsuite/gcc.c-torture/execute/fprintf-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/fprintf-2.c
@@ -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)
{
diff --git a/gcc/testsuite/gcc.c-torture/execute/gcc_tmpnam.h b/gcc/testsuite/gcc.c-torture/execute/gcc_tmpnam.h
new file mode 100644
index 00000000000..2136e6eaf13
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/gcc_tmpnam.h
@@ -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
diff --git a/gcc/testsuite/gcc.c-torture/execute/printf-2.c b/gcc/testsuite/gcc.c-torture/execute/printf-2.c
index 4e7d8f7cdfa..2087bba8448 100644
--- a/gcc/testsuite/gcc.c-torture/execute/printf-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/printf-2.c
@@ -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)
{
diff --git a/gcc/testsuite/gcc.c-torture/execute/user-printf.c b/gcc/testsuite/gcc.c-torture/execute/user-printf.c
index 42a3b17f123..bfee0760dd7 100644
--- a/gcc/testsuite/gcc.c-torture/execute/user-printf.c
+++ b/gcc/testsuite/gcc.c-torture/execute/user-printf.c
@@ -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)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-23 2:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 2:16 [gcc r12-3062] gcc.c-torture/execute: Fix tmpnam issue on Windows Jonathan Yong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).