[Ttssh2-commit] [7586] ビルドしたときに使われたコンパイラの文字列取得を関数に分離

scmno****@osdn***** scmno****@osdn*****
2019年 4月 13日 (土) 01:19:05 JST


Revision: 7586
          https://osdn.net/projects/ttssh2/scm/svn/commits/7586
Author:   zmatsuo
Date:     2019-04-13 01:19:05 +0900 (Sat, 13 Apr 2019)
Log Message:
-----------
ビルドしたときに使われたコンパイラの文字列取得を関数に分離

Modified Paths:
--------------
    trunk/teraterm/ttpdlg/ttdlg.c

-------------- next part --------------
Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2019-04-12 16:18:52 UTC (rev 7585)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2019-04-12 16:19:05 UTC (rev 7586)
@@ -2059,7 +2059,83 @@
 	parent->timer_done = 0;
 }
 
+#if defined(_MSC_VER)
+// \x83r\x83\x8B\x83h\x82\xB5\x82\xBD\x82Ƃ\xAB\x82Ɏg\x82\xED\x82ꂽVisual C++\x82̃o\x81[\x83W\x83\x87\x83\x93\x82\xF0\x8E擾\x82\xB7\x82\xE9(2009.3.3 yutaka)
+static void GetCompilerInfo(char *buf, size_t buf_size)
+{
+	char tmpbuf[128];
+	int msc_ver, vs_ver, msc_low_ver;
 
+	strcpy(buf, "Microsoft Visual C++ ");
+#ifdef _MSC_FULL_VER
+	// VS2015\x82ł\xCD Compiler version = 19 \x82\xBE\x82\xAA\x81AVisual Studio version = 14 \x82ƂȂ\xC1\x82Ă\xA2\x82邽\x82߁A
+	// \x8C\xB8\x8EZ\x82𒲐\xAE\x82\xB7\x82\xE9\x81B
+	// (2015.12.23 yutaka)
+	msc_ver = (_MSC_FULL_VER / 10000000);
+	msc_low_ver = (_MSC_FULL_VER / 100000) % 100;
+	if (msc_ver < 19) {
+		vs_ver = msc_ver - 6;
+	}
+	else {
+		// 1900 = VS2015(VC++14)
+		// 1910 = VS2017(VC++15)
+		// 1911 = VS2017 update3-4(VC++15)
+		// 1912 = VS2017 update5(VC++15)
+		// 1913 = VS2017 update6(VC++15)
+		// 1914 = VS2017 15.7(VC++15)
+		// 1920 = VS2019 16.0.0(VC++16)
+		// VS2017 Update3\x82\xA9\x82琻\x95i\x83o\x81[\x83W\x83\x87\x83\x93\x82\xAA3\x8C\x85\x95\\x8BL(15.x.x)\x82ɂȂ\xE8\x81A
+		// _MSC_FULL_VER\x82\xA9\x82\xE7\x8EZ\x8Fo\x82ł\xAB\x82Ȃ\xAD\x82Ȃ\xC1\x82\xBD\x82\xBD\x82߁A\x88ꗥ\x82\xC515.0\x82Ƃ\xB7\x82\xE9\x81B
+		if (msc_low_ver >= 10) {
+			vs_ver = msc_ver - 4 + (msc_low_ver - 10)/10;
+			msc_low_ver = 0;
+		}
+		else {
+			vs_ver = msc_ver - 5;
+		}
+	}
+
+	_snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, " %d.%d",
+				vs_ver,
+				msc_low_ver);
+	strncat_s(buf, buf_size, tmpbuf, _TRUNCATE);
+	if (_MSC_FULL_VER % 100000) {
+		_snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, " build %d",
+					_MSC_FULL_VER % 100000);
+		strncat_s(buf, buf_size, tmpbuf, _TRUNCATE);
+	}
+#elif defined(_MSC_VER)
+	_snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, " %d.%d",
+				(_MSC_VER / 100) - 6,
+				_MSC_VER % 100);
+	strncat_s(buf, buf_size, tmpbuf, _TRUNCATE);
+#endif
+}
+
+#elif defined(__MINGW32__)
+static void GetCompilerInfo(char *buf, size_t buf_size)
+{
+#if defined(__GNUC__) || defined(__clang__)
+	_snprintf_s(buf, buf_size, _TRUNCATE,
+				"mingw " __MINGW64_VERSION_STR " "
+#if defined(__clang__)
+				"clang " __clang_version__
+#elif defined(__GNUC__)
+				"gcc " __VERSION__
+#endif
+		);
+#else
+	strncat_s(buf, buf_size, "mingw", _TRUNCATE);
+#endif
+}
+
+#else
+static void GetCompilerInfo(char *buf, size_t buf_size)
+{
+	strncpy_s(buf, buf_size, "unknown compiler");
+}
+#endif
+
 static INT_PTR CALLBACK AboutDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	static const DlgTextInfo TextInfos[] = {
@@ -2073,7 +2149,6 @@
 	WORD w, h;
 	POINT point;
 	char uimsg[MAX_UIMSG];
-	int msc_ver, vs_ver, msc_low_ver;
 
 #if defined(EFFECT_ENABLED) || defined(TEXTURE_ENABLED)
 	// for animation
@@ -2144,62 +2219,20 @@
 			_snprintf_s(buf, sizeof(buf), _TRUNCATE, "Oniguruma %s", onig_version());
 			SetDlgItemTextA(Dialog, IDC_ONIGURUMA_LABEL, buf);
 
-			// \x83r\x83\x8B\x83h\x82\xB5\x82\xBD\x82Ƃ\xAB\x82Ɏg\x82\xED\x82ꂽVisual C++\x82̃o\x81[\x83W\x83\x87\x83\x93\x82\xF0\x90ݒ肷\x82\xE9\x81B(2009.3.3 yutaka)
-			_snprintf_s(buf, sizeof(buf), _TRUNCATE, "Built using Microsoft Visual C++");
-#ifdef _MSC_FULL_VER
-			// VS2015\x82ł\xCD Compiler version = 19 \x82\xBE\x82\xAA\x81AVisual Studio version = 14 \x82ƂȂ\xC1\x82Ă\xA2\x82邽\x82߁A
-			// \x8C\xB8\x8EZ\x82𒲐\xAE\x82\xB7\x82\xE9\x81B
-			// (2015.12.23 yutaka)
-			msc_ver = (_MSC_FULL_VER / 10000000);
-			msc_low_ver = (_MSC_FULL_VER / 100000) % 100;
-			if (msc_ver < 19) {
-				vs_ver = msc_ver - 6;
-			}
-			else {
-				// 1900 = VS2015(VC++14)
-				// 1910 = VS2017(VC++15)
-				// 1911 = VS2017 update3-4(VC++15)
-				// 1912 = VS2017 update5(VC++15)
-				// 1913 = VS2017 update6(VC++15)
-				// 1914 = VS2017 15.7(VC++15)
-				// 1920 = VS2019 16.0.0(VC++16)
-				// VS2017 Update3\x82\xA9\x82琻\x95i\x83o\x81[\x83W\x83\x87\x83\x93\x82\xAA3\x8C\x85\x95\\x8BL(15.x.x)\x82ɂȂ\xE8\x81A
-				// _MSC_FULL_VER\x82\xA9\x82\xE7\x8EZ\x8Fo\x82ł\xAB\x82Ȃ\xAD\x82Ȃ\xC1\x82\xBD\x82\xBD\x82߁A\x88ꗥ\x82\xC515.0\x82Ƃ\xB7\x82\xE9\x81B
-				if (msc_low_ver >= 10) {
-					vs_ver = msc_ver - 4 + (msc_low_ver - 10)/10;
-					msc_low_ver = 0;
-				} 
-				else {
-					vs_ver = msc_ver - 5;
-				}
-			}
+			// \x83r\x83\x8B\x83h\x82\xB5\x82\xBD\x82Ƃ\xAB\x82Ɏg\x82\xED\x82ꂽ\x83R\x83\x93\x83p\x83C\x83\x89\x82\xF0\x90ݒ肷\x82\xE9\x81B(2009.3.3 yutaka)
+			GetCompilerInfo(tmpbuf, sizeof(tmpbuf));
+			_snprintf_s(buf, sizeof(buf), _TRUNCATE, "Built using %s", tmpbuf);
+			SetDlgItemTextA(Dialog, IDC_BUILDTOOL, buf);
 
-			_snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, " %d.%d",
-				vs_ver,
-				msc_low_ver);
-			strncat_s(buf, sizeof(buf), tmpbuf, _TRUNCATE);
-			if (_MSC_FULL_VER % 100000) {
-				_snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, " build %d",
-					_MSC_FULL_VER % 100000);
-				strncat_s(buf, sizeof(buf), tmpbuf, _TRUNCATE);
-			}
-#elif defined(_MSC_VER)
-			_snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, " %d.%d",
-				(_MSC_VER / 100) - 6,
-				_MSC_VER % 100);
-			strncat_s(buf, sizeof(buf), tmpbuf, _TRUNCATE);
-#endif
-			SendMessage(GetDlgItem(Dialog, IDC_BUILDTOOL), WM_SETTEXT, 0, (LPARAM)buf);
-
 			// \x83r\x83\x8B\x83h\x83^\x83C\x83\x80\x82\xF0\x90ݒ肷\x82\xE9\x81B(2009.3.4 yutaka)
 			_snprintf_s(buf, sizeof(buf), _TRUNCATE, "Build time: %s %s", __DATE__, __TIME__);
-			SendMessage(GetDlgItem(Dialog, IDC_BUILDTIME), WM_SETTEXT, 0, (LPARAM)buf);
+			SetDlgItemTextA(Dialog, IDC_BUILDTIME, buf);
 
 			// static text \x82̃T\x83C\x83Y\x82\xF0\x95ύX (2007.4.16 maya)
 			hwnd = GetDlgItem(Dialog, IDC_AUTHOR_URL);
 			hdc = GetDC(hwnd);
 			SelectObject(hdc, (HFONT)SendMessage(Dialog, WM_GETFONT, 0, 0));
-			GetDlgItemText(Dialog, IDC_AUTHOR_URL, uimsg, sizeof(uimsg));
+			GetDlgItemTextA(Dialog, IDC_AUTHOR_URL, uimsg, sizeof(uimsg));
 			dwExt = GetTabbedTextExtent(hdc,uimsg,strlen(uimsg),0,NULL);
 			w = LOWORD(dwExt) + 5; // \x95\x9D\x82\xAA\x8E኱\x91\xAB\x82\xE8\x82Ȃ\xA2\x82̂ŕ␳
 			h = HIWORD(dwExt);
@@ -2212,7 +2245,7 @@
 			hwnd = GetDlgItem(Dialog, IDC_FORUM_URL);
 			hdc = GetDC(hwnd);
 			SelectObject(hdc, (HFONT)SendMessage(Dialog, WM_GETFONT, 0, 0));
-			GetDlgItemText(Dialog, IDC_FORUM_URL, uimsg, sizeof(uimsg));
+			GetDlgItemTextA(Dialog, IDC_FORUM_URL, uimsg, sizeof(uimsg));
 			dwExt = GetTabbedTextExtent(hdc,uimsg,strlen(uimsg),0,NULL);
 			w = LOWORD(dwExt) + 5; // \x95\x9D\x82\xAA\x8E኱\x91\xAB\x82\xE8\x82Ȃ\xA2\x82̂ŕ␳
 			h = HIWORD(dwExt);


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