[Ttssh2-commit] [9165] Visual C 2015 から tmpnam() がフルパスを返すようになったため、バージョン判定の分岐を追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 2月 18日 (木) 23:37:05 JST


Revision: 9165
          https://osdn.net/projects/ttssh2/scm/svn/commits/9165
Author:   nmaya
Date:     2021-02-18 23:37:05 +0900 (Thu, 18 Feb 2021)
Log Message:
-----------
Visual C 2015 から tmpnam() がフルパスを返すようになったため、バージョン判定の分岐を追加

https://docs.microsoft.com/en-us/cpp/porting/visual-cpp-change-history-2003-2015?view=msvc-160
tmpnam Generates Usable File Names

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/hosts.c

-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/hosts.c
===================================================================
--- trunk/ttssh2/ttxssh/hosts.c	2021-02-18 14:14:15 UTC (rev 9164)
+++ trunk/ttssh2/ttxssh/hosts.c	2021-02-18 14:37:05 UTC (rev 9165)
@@ -1367,7 +1367,9 @@
 		Key key; // known_hosts\x82ɓo\x98^\x82\xB3\x82\xEA\x82Ă\xA2\x82錮
 		int length;
 		char filename[MAX_PATH];
+#if _MSC_VER < 1900 // less than VSC2015(VC14.0)
 		char tmp[L_tmpnam];
+#endif
 		int fd;
 		int amount_written = 0;
 		int close_result;
@@ -1375,9 +1377,13 @@
 		char buf[FILENAME_MAX];
 
 		// \x8F\x91\x82\xAB\x8D\x9E\x82݈ꎞ\x83t\x83@\x83C\x83\x8B\x82\xF0\x8AJ\x82\xAD
+#if _MSC_VER < 1900 // less than VSC2015(VC14.0)
 		_getcwd(filename, sizeof(filename));
-		tmpnam_s(tmp,sizeof(tmp));
+		tmpnam_s(tmp, sizeof(tmp));
 		strcat_s(filename, sizeof(filename), tmp);
+#else // VSC2015(VC14.0) or later
+		tmpnam_s(filename, sizeof(filename));
+#endif
 		fd = _open(filename,
 		          _O_CREAT | _O_WRONLY | _O_SEQUENTIAL | _O_BINARY | _O_TRUNC,
 		          _S_IREAD | _S_IWRITE);
@@ -1556,7 +1562,9 @@
 		Key key; // known_hosts\x82ɓo\x98^\x82\xB3\x82\xEA\x82Ă\xA2\x82錮
 		int length;
 		char filename[MAX_PATH];
+#if _MSC_VER < 1900 // less than VSC2015(VC14.0)
 		char tmp[L_tmpnam];
+#endif
 		int fd;
 		int amount_written = 0;
 		int close_result;
@@ -1564,9 +1572,13 @@
 		char buf[FILENAME_MAX];
 
 		// \x8F\x91\x82\xAB\x8D\x9E\x82݈ꎞ\x83t\x83@\x83C\x83\x8B\x82\xF0\x8AJ\x82\xAD
+#if _MSC_VER < 1900 // less than VSC2015(VC14.0)
 		_getcwd(filename, sizeof(filename));
 		tmpnam_s(tmp, sizeof(tmp));
 		strcat_s(filename, sizeof(filename), tmp);
+#else // VSC2015(VC14.0) or later
+		tmpnam_s(filename, sizeof(filename));
+#endif
 		fd = _open(filename,
 			_O_CREAT | _O_WRONLY | _O_SEQUENTIAL | _O_BINARY | _O_TRUNC,
 			_S_IREAD | _S_IWRITE);


Ttssh2-commit メーリングリストの案内
Back to archive index