svnno****@sourc*****
svnno****@sourc*****
2012年 5月 3日 (木) 00:38:31 JST
Revision: 28 http://sourceforge.jp/projects/miranda-jp/svn/view?view=rev&revision=28 Author: taguchi-ch Date: 2012-05-03 00:38:01 +0900 (Thu, 03 May 2012) Log Message: ----------- add processing to get default version number Modified Paths: -------------- trunk/miranda-tools/lpgen/lpgen.pl -------------- next part -------------- Modified: trunk/miranda-tools/lpgen/lpgen.pl =================================================================== --- trunk/miranda-tools/lpgen/lpgen.pl 2012-05-01 14:16:39 UTC (rev 27) +++ trunk/miranda-tools/lpgen/lpgen.pl 2012-05-02 15:38:01 UTC (rev 28) @@ -25,49 +25,69 @@ use POSIX; use File::Find; use strict; +use warnings; my $rootdir = ''; my %hash = (); my $clines = 0; -my $version = '0.7svn'; +my $version = ''; +my $version_file = '../../miranda/include/m_version.h'; my $time = localtime(); -if (@ARGV && $ARGV[0] eq "version") { +my $vermaj = ''; +my $vermin = ''; +my $build = ''; + +if (@ARGV && $ARGV[0] eq "version") +{ shift @ARGV; - # 1st arg version major i.e. 07 for "0.7" - if (@ARGV) { - my $vermaj = shift @ARGV; - if ($vermaj =~ /^([0-9]*)([0-9])$/) { - if ($1 eq "") { - $version = $2; - } else { - $version = "$1.$2"; - } - } else { - $version = $vermaj; - } + $vermaj = shift @ARGV; + $vermin = shift @ARGV; + $build = shift @ARGV; +} +else +{ +#Get default version no. from m_version.h + ($vermaj, $vermin, $build) = get_version( $version_file ); +} + +# 1st arg version major i.e. 07 for "0.7" +if ($vermaj =~ /^([0-9]*)([0-9])$/) +{ + if ($1 eq "") + { + $version = $2; } - # 2nd arg version minor i.e. 1 for "0.7.1" - if (@ARGV) { - my $vermin = shift @ARGV; - if ($vermin =~ /^[0-9]+$/) { - $version .= ".$vermin"; - } else { - $version .= $vermin; - } + else + { + $version = "$1.$2"; } - # 3rd arg build number i.e. 36 for "0.7.1 build 36" - if (@ARGV) { - my $build = shift @ARGV; - if ($build =~ /^[0-9]+$/) { - $version .= " build $build"; - } else { - $version .= $build; - } - } } +else +{ + $version = $vermaj; +} +# 2nd arg version minor i.e. 1 for "0.7.1" +if ($vermin =~ /^[0-9]+$/) +{ + $version .= ".$vermin"; +} +else +{ + $version .= $vermin; +} +# 3rd arg build number i.e. 36 for "0.7.1 build 36" +if ($build =~ /^[0-9]+$/) +{ + $version .= " build $build"; +} +else +{ + $version .= $build; +} + #Language Files if (!@ARGV) { create_langfile( @@ -226,3 +246,29 @@ print "($found)\n"; } } + +sub get_version +{ + my $version_file = shift(@_); + my @version_no = ('','',''); + my $build = ''; + + open my $fh, '<', $version_file + or die qq/Error : Cannot open "$version_file": $!/; + + while( my $get_line = <$fh> ) + { + chomp $get_line; + if( $get_line =~ /^\#define MIRANDA_VERSION_STRING\s*?\"(\d*?\.\d*?)\.(\d*?)\.(\d*?)\"/) + { + if( $3 != 0 ) + { + my $build = $3; + } + @version_no = ($1,$2,$build); + last; + } + } + close $fh; + return @version_no; +}