• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision9165 (tree)
Time2021-02-18 23:37:05
Authornmaya

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

Change Summary

Incremental Difference

--- trunk/ttssh2/ttxssh/hosts.c (revision 9164)
+++ trunk/ttssh2/ttxssh/hosts.c (revision 9165)
@@ -1367,7 +1367,9 @@
13671367 Key key; // known_hostsに登録されている鍵
13681368 int length;
13691369 char filename[MAX_PATH];
1370+#if _MSC_VER < 1900 // less than VSC2015(VC14.0)
13701371 char tmp[L_tmpnam];
1372+#endif
13711373 int fd;
13721374 int amount_written = 0;
13731375 int close_result;
@@ -1375,9 +1377,13 @@
13751377 char buf[FILENAME_MAX];
13761378
13771379 // 書き込み一時ファイルを開く
1380+#if _MSC_VER < 1900 // less than VSC2015(VC14.0)
13781381 _getcwd(filename, sizeof(filename));
1379- tmpnam_s(tmp,sizeof(tmp));
1382+ tmpnam_s(tmp, sizeof(tmp));
13801383 strcat_s(filename, sizeof(filename), tmp);
1384+#else // VSC2015(VC14.0) or later
1385+ tmpnam_s(filename, sizeof(filename));
1386+#endif
13811387 fd = _open(filename,
13821388 _O_CREAT | _O_WRONLY | _O_SEQUENTIAL | _O_BINARY | _O_TRUNC,
13831389 _S_IREAD | _S_IWRITE);
@@ -1556,7 +1562,9 @@
15561562 Key key; // known_hostsに登録されている鍵
15571563 int length;
15581564 char filename[MAX_PATH];
1565+#if _MSC_VER < 1900 // less than VSC2015(VC14.0)
15591566 char tmp[L_tmpnam];
1567+#endif
15601568 int fd;
15611569 int amount_written = 0;
15621570 int close_result;
@@ -1564,9 +1572,13 @@
15641572 char buf[FILENAME_MAX];
15651573
15661574 // 書き込み一時ファイルを開く
1575+#if _MSC_VER < 1900 // less than VSC2015(VC14.0)
15671576 _getcwd(filename, sizeof(filename));
15681577 tmpnam_s(tmp, sizeof(tmp));
15691578 strcat_s(filename, sizeof(filename), tmp);
1579+#else // VSC2015(VC14.0) or later
1580+ tmpnam_s(filename, sizeof(filename));
1581+#endif
15701582 fd = _open(filename,
15711583 _O_CREAT | _O_WRONLY | _O_SEQUENTIAL | _O_BINARY | _O_TRUNC,
15721584 _S_IREAD | _S_IWRITE);
Show on old repository browser