[Ttssh2-commit] [3233] バージョンダイアログに、SVNリビジョンを表示するようにした。

svnno****@sourc***** svnno****@sourc*****
2009年 3月 25日 (水) 21:05:44 JST


Revision: 3233
          http://svn.sourceforge.jp/view?root=ttssh2&view=rev&rev=3233
Author:   yutakapon
Date:     2009-03-25 21:05:44 +0900 (Wed, 25 Mar 2009)

Log Message:
-----------
バージョンダイアログに、SVNリビジョンを表示するようにした。
ただし、
 ・makearchive.batを使わずに、Visual Studio上からビルドした場合。
 ・何らかの理由により、SVNリビジョンが取得できない場合。
においては、SVNリビジョンは表示されないか、古いままとなる。

Modified Paths:
--------------
    trunk/installer/makearchive.bat
    trunk/teraterm/ttpdlg/ttdlg.c
    trunk/teraterm/ttpdlg/ttpdlg.rc

Added Paths:
-----------
    trunk/installer/make_svn_revision.pl
    trunk/teraterm/ttpdlg/svnversion.h


-------------- next part --------------
Added: trunk/installer/make_svn_revision.pl
===================================================================
--- trunk/installer/make_svn_revision.pl	                        (rev 0)
+++ trunk/installer/make_svn_revision.pl	2009-03-25 12:05:44 UTC (rev 3233)
@@ -0,0 +1,107 @@
+# 
+# Subversion(SVN)‚̍ŐVƒŠƒrƒWƒ‡ƒ“‚ðŽæ“¾‚·‚é
+#
+# Subversion 1.6‚ÅŠm”F (2009.03.25 yutaka)
+#
+
+$svnfile = '../.svn/entries';
+$headerfile = '../teraterm/ttpdlg/svnversion.h';
+
+$val = getVersion($svnfile);
+print "SVN#: $val\n";
+
+#$val = -1;
+makeVersionHeader($val);
+
+exit(0);
+
+sub makeVersionHeader {
+	my($rev) = shift(@_);
+	my($msg);
+	
+	if (!open(FP, "> $headerfile")) {
+		print "Can not write: $headerfile\n";
+		goto error;
+	}
+	
+	if ($val < 0) {
+		$msg = '#undef SVNVERSION';
+	} else {
+		$msg = "#define SVNVERSION	$rev";
+	}
+
+	print FP <<EOD;
+/* This file was automatically generated by make_svn_revision.pl. 
+ * Don't modify this file.
+ */
+$msg
+EOD
+
+	close(FP);
+	
+	print "Success: $headerfile was created.\n";
+	
+error:
+
+}
+
+sub getVersion {
+	my($file) = shift(@_);
+	my($ret) = -1;
+	my($line, $count, $inblock, $author);
+	
+	if (!(-e "$file")) {
+		print "Not found: $file\n";
+		goto error;
+	}
+	
+	if (!open(FP, "< $file")) {
+		print "Can not open: $file\n";
+		goto error;
+	}
+	
+	$count = 0;
+	$inblock = 0;
+	while ($line = <FP>) {
+		chomp($line);
+		$line =~ s/^\s+//;
+		
+		if ($inblock == 0) {
+			if ($line ne '') {
+				# ‹ó”’s‚Å‚È‚¢Žn‚߂̍s‚ª—ˆ‚½‚çAƒuƒƒbƒN‚ÌŠJŽn‚ÆŒ©‚È‚·B
+				$count++;
+				$inblock = 1;
+			}
+		} else {
+			if ($line eq '') {
+				# ƒuƒƒbƒN‚̏I‚í‚èi‹ó”’sj‚ª—ˆ‚½‚©‚Ç‚¤‚©B
+				$inblock = 0;
+			}
+		}
+		
+		if ($count == 3) {  # 3‚‚߂̃uƒƒbƒN‚É svn info î•ñ‚ª‚ ‚éB
+			if ($line =~ /^\d{4}-\d{2}-\d{2}/) {
+				# ˆês–Ú‚Í–³Ž‹
+			
+			} elsif ($line =~ /^(\d+)/) {  # SVNƒŠƒrƒWƒ‡ƒ“
+				$ret = $1;
+				
+			} elsif ($line =~ /^(\w+)/) {
+				if ($ret > 0) {
+					$author = $1;
+					last;
+				}
+			}
+		}
+	
+	}
+	
+	print "$ret $author\n";
+	
+	close(FP);
+	
+error:
+	return ($ret);
+}
+
+

Modified: trunk/installer/makearchive.bat
===================================================================
--- trunk/installer/makearchive.bat	2009-03-24 20:50:54 UTC (rev 3232)
+++ trunk/installer/makearchive.bat	2009-03-25 12:05:44 UTC (rev 3233)
@@ -14,6 +14,9 @@
 if "%1"=="debug" SET debug=yes
 if "%1"=="plugins" SET plugins=yes
 
+rem SVNƒŠƒrƒWƒ‡ƒ“
+perl make_svn_revision.pl
+
 CALL makechm.bat
 CALL build.bat %1
 

Added: trunk/teraterm/ttpdlg/svnversion.h
===================================================================
--- trunk/teraterm/ttpdlg/svnversion.h	                        (rev 0)
+++ trunk/teraterm/ttpdlg/svnversion.h	2009-03-25 12:05:44 UTC (rev 3233)
@@ -0,0 +1,4 @@
+/* This file was automatically generated by make_svn_revision.pl. 
+ * Don't modify this file.
+ */
+#define SVNVERSION	3232

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2009-03-24 20:50:54 UTC (rev 3232)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2009-03-25 12:05:44 UTC (rev 3233)
@@ -15,6 +15,7 @@
 #include "dlglib.h"
 #include "ttcommon.h"
 #include "dlg_res.h"
+#include "svnversion.h"
 
 // Oniguruma: Regular expression library
 #define ONIG_EXTERN extern
@@ -2565,6 +2566,10 @@
 		// __argv[0]‚Å‚Í WinExec() ‚µ‚½ƒvƒƒZƒX‚©‚çŽQÆ‚Å‚«‚È‚¢‚悤‚Ȃ̂ō폜B(2005.3.14 yutaka)
 		get_file_version("ttermpro.exe", &a, &b, &c, &d);
 		_snprintf_s(buf, sizeof(buf), _TRUNCATE, "Version %d.%d", a, b);
+#ifdef SVNVERSION
+		_snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, " (SVN# %d)", SVNVERSION);
+		strncat_s(buf, sizeof(buf), tmpbuf, _TRUNCATE);
+#endif
 		SendMessage(GetDlgItem(Dialog, IDC_TT_VERSION), WM_SETTEXT, 0, (LPARAM)buf);
 
 		// Oniguruma‚̃o[ƒWƒ‡ƒ“‚ðÝ’è‚·‚é 

Modified: trunk/teraterm/ttpdlg/ttpdlg.rc
===================================================================
--- trunk/teraterm/ttpdlg/ttpdlg.rc	2009-03-24 20:50:54 UTC (rev 3232)
+++ trunk/teraterm/ttpdlg/ttpdlg.rc	2009-03-25 12:05:44 UTC (rev 3233)
@@ -266,12 +266,12 @@
     CONTROL         "Mar 10, 1998 T. Teranishi",IDC_TT23DATE_LABEL,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,38,51,90,8
     CONTROL         "Copyright (C) 1994-1998 T. Teranishi",IDC_TERANISHI_LABEL,
                     "Static",SS_LEFTNOWORDWRAP | WS_GROUP,38,59,134,8
-    DEFPUSHBUTTON   "OK",IDOK,136,6,32,16,WS_GROUP
+    DEFPUSHBUTTON   "OK",IDOK,145,6,32,16,WS_GROUP
     CONTROL         "All Rights Reserved.",IDC_RIGHTS_LABEL,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,38,75,76,8
     CONTROL         "(C) 2004-2009 Tera Term Project",IDC_PROJECT_LABEL,
                     "Static",SS_LEFTNOWORDWRAP | WS_GROUP,38,67,122,9
     LTEXT           "Includes:",IDC_INLUCDE_LABEL,38,26,31,8
-    LTEXT           "Version",IDC_TT_VERSION,38,10,68,8
+    LTEXT           "Version",IDC_TT_VERSION,38,10,101,8
     RTEXT           "Author:",IDC_AUTHOR_LABEL,5,106,28,8
     LTEXT           "http://ttssh2.sourceforge.jp/",IDC_AUTHOR_URL,36,106,128,8,SS_NOTIFY | WS_TABSTOP
     RTEXT           "Forum:",IDC_FORUM_LABEL,8,115,25,8



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