diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:41 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:41 +0200 |
| commit | 520f54d6219b7c625b4e07463ac393e6982ddab6 (patch) | |
| tree | 74b4483786b3842b1a0384fd33deb7483276bea1 /scripts | |
| parent | ae4e87df37ed8904de92c7cf2f3a11128cda2a21 (diff) | |
tagging ychat-0.7.1ychat-0.7.1
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/buildnr.pl | 2 | ||||
| -rw-r--r-- | scripts/makeyhttpd.pl | 10 | ||||
| -rwxr-xr-x | scripts/mergeconf.pl | 104 | ||||
| -rwxr-xr-x | scripts/stats.pl | 24 |
4 files changed, 122 insertions, 18 deletions
diff --git a/scripts/buildnr.pl b/scripts/buildnr.pl index ee3d3e2..e691a11 100755 --- a/scripts/buildnr.pl +++ b/scripts/buildnr.pl @@ -13,7 +13,7 @@ close MSGS; foreach (@msgs) { - if ( /define BUILDNR/ ) + if ( /BUILDNR/ ) { s/(BUILDNR )(.+)$/$1.($2+1)/e; print; diff --git a/scripts/makeyhttpd.pl b/scripts/makeyhttpd.pl index 101343a..2805360 100644 --- a/scripts/makeyhttpd.pl +++ b/scripts/makeyhttpd.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# The yChat & yhttpd Project (2004, 2005) +# The yChat & yhttpd Project (2004) # # This scripts modifies the yChat sources to yhttpd sources. @@ -17,8 +17,6 @@ my @delete = ( 'src/data', 'src/irc', 'src/contrib/crypt', - 'src/modl.h', - 'src/modl.cpp', 'src/mods', 'src/mods/commands', 'src/mods/irc', @@ -77,7 +75,7 @@ foreach (@delete) { system("rm -Rf $_"); } -print "\nDeleting CVS directories\n"; +print "Deleting CVS directories\n"; system("find . -name CVS | xargs rm -Rf"); print "Creating new dirs\n->"; @@ -86,14 +84,14 @@ foreach (@createdir) { system("mkdir $_"); } -print "\nRenaming config file\n"; +print "Renaming config file\n"; system("mv etc/ychat.conf etc/yhttpd.conf"); print "Moving html templates\n"; system("mv demo.html html/index.html"); system("mv test.cgi notfound.html style.css html"); -print "Removing marked lines of code\n->"; +print "Removing marked lines of code\n ->"; &remove_marked_lines('.'); sub remove_marked_lines { diff --git a/scripts/mergeconf.pl b/scripts/mergeconf.pl new file mode 100755 index 0000000..85e76cb --- /dev/null +++ b/scripts/mergeconf.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl + +# The yChat Project (2003) +# +# This script merges configuration files + +use strict; + +use scripts::modules::file; + +my @files = ('conf.txt','lang/en.txt','lang/de.txt'); + +foreach my $filename ( @files ) +{ + next if ( ! -f $filename || ! -f "$filename.old" ); + + print "=> Merge $filename\n"; + my @newoptions = &merge("$filename.old",$filename ); + if (defined $newoptions[0]) + { + print " => Modified $filename. Edit to set the new values [or leave standard]\n => New options are:"; + foreach (@newoptions) + { + print " $_"; + } + print "\n"; + } +} + +sub merge +{ + my ($oldfile,$newfile) = @_; + my @oldfile = fopen($oldfile); + my @newfile = fopen($newfile); + my %oldfile = get_options(@oldfile); + my %newfile = get_options(@newfile); + my @newoptions; + + foreach my $option (keys %newfile) + { + unless (defined $oldfile{$option}) + { + push @newoptions, $option; + my $_comment = $newfile{$option}[0]; + my $_value = $newfile{$option}[1]; + my $_comment_b = $newfile{$option}[2]; + my $_behind = $newfile{$option}[3]; + print " => Adding to $newfile\n => New option is $option\n" + ." => Adding it after option $_behind\n"; + + my $added = 0; + my $insert = $_comment . "$option=\"$_value\";$_comment_b\n"; + foreach (@oldfile) + { + if (/^$_behind.+$/) + { + $_ .= $insert; + $added = 1; + last; + } + } + if ( $added == 0 ) + { + print " => Adding new option at EOF\n"; + push @oldfile, $insert; + } + } + } + + &fwrite($newfile,@oldfile); + + return @newoptions; +} + +sub get_options +{ + my @file = @_; + my %options; + my $option_comment; + my $option_before = ''; + + foreach (@file) + { + if (/(^.+)="(.+)";(.*)/) + { + my $option = $1; + my $option_value = $2; + my $option_comment_behind = $3; + my @values = ($option_comment, + $option_value, + $option_comment_behind, + $option_before); + $options{$option} = \@values; + $option_comment = ''; + $option_before = $option; + } + else + { + $option_comment .= $_; + } + } + + return %options; +} diff --git a/scripts/stats.pl b/scripts/stats.pl index e5cc2b3..38cc67c 100755 --- a/scripts/stats.pl +++ b/scripts/stats.pl @@ -9,7 +9,6 @@ use strict; use scripts::modules::file; my %stats; -my $param = shift; &recursive("."); @@ -18,16 +17,19 @@ $stats{"Lines total"} = $stats{"Lines of source"} + $stats{"Lines of text"} + $stats{"Lines of HTML"}; -unless (defined $param) { - - print "$_ = " . $stats{$_} . "\n" - for ( sort keys %stats ); - -} else { - - print $stats{$_} . " " - for sort keys %stats; - +my $bool = 0; +foreach ( sort keys %stats ) +{ + if ($bool == 0) + { + print "$_ = " . $stats{$_} . "\n"; + $bool = 1; + } + else + { + print "$_ = " . $stats{$_} . "\n"; + $bool = 0; + } } print "\n"; |
