[Ttssh2-commit] [8497] MinGWでビルドできるよう _dupenv_s() のラッパを作成

scmno****@osdn***** scmno****@osdn*****
2020年 1月 22日 (水) 22:53:52 JST


Revision: 8497
          https://osdn.net/projects/ttssh2/scm/svn/commits/8497
Author:   zmatsuo
Date:     2020-01-22 22:53:52 +0900 (Wed, 22 Jan 2020)
Log Message:
-----------
MinGWでビルドできるよう _dupenv_s() のラッパを作成

- r8488

Revision Links:
--------------
    https://osdn.net/projects/ttssh2/scm/svn/commits/8488

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2020-01-22 13:53:43 UTC (rev 8496)
+++ trunk/teraterm/teraterm/vtwin.cpp	2020-01-22 13:53:52 UTC (rev 8497)
@@ -3898,6 +3898,19 @@
 	}
 }
 
+static void __dupenv_s(char **envptr, size_t, const char* name)
+{
+#if defined(_MSC_VER)
+	_dupenv_s(envptr, NULL, name);
+#else
+    const char* s = getenv(name);
+	if (s == NULL) {
+		*envptr = NULL;
+		return;
+	}
+	*envptr = strdup(s);
+#endif
+}
 
 //
 // Connect to local cygwin
@@ -3939,7 +3952,7 @@
 	return;
 
 found_dll:;
-	_dupenv_s(&envptr, NULL, "PATH");
+	__dupenv_s(&envptr, NULL, "PATH");
 	file[strlen(file)-12] = '\0'; // delete "\\cygwin1.dll"
 	if (envptr != NULL) {
 		envbufflen = strlen(file) + strlen(envptr) + 7; // "PATH="(5) + ";"(1) + NUL(1)


Ttssh2-commit メーリングリストの案内