From 4b4277588a0795560abb9ea0f01881c7d5010c4a Mon Sep 17 00:00:00 2001 From: brarcher Date: Sat, 21 Sep 2013 16:03:14 +0000 Subject: [PATCH] Always try alternative to tmpfile() if necessary If tmpfile fails on a platform, there is no harm in trying the alternative. Previously the alternative was only attempted for Windows. However, checking for WIN32 was not correct; instead _WIN32 should be used. When the proper check for Windows was attempted, OSX would fail to run its tests. However, removing the conditional and renaming _tempnam to tempnam (which is available in MinGW, OSX, and GNU/Linux) works for all three platforms. Correctly check for Windows environment The correct way to check for compiling for Windows is to check for _WIN32 instead of WIN32. Patch submitted by username bross on Sourceforge, patch#48 git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@756 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- src/check_msg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/check_msg.c b/src/check_msg.c index 6fdcc79..3d3fcb4 100644 --- a/src/check_msg.c +++ b/src/check_msg.c @@ -193,15 +193,13 @@ open_tmp_file (void) /* it's also not clear if we need _tempnam instead of tempnam on WIN32 */ /* and finally, the "b" from "w+b" is ignored on OS X, not sure about WIN32 */ FILE *file = tmpfile (); -#ifdef WIN32 if (file == NULL) { char *tmp = getenv ("TEMP"); - char *tmp_file = _tempnam (tmp, "check_"); + char *tmp_file = tempnam (tmp, "check_"); file = fopen (tmp_file, "w+b"); free (tmp_file); } -#endif /* WIN32 */ return file; } -- 2.50.0