From 5f4e214740242513c837c8a005ca23779bab1d0c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:45 +0200 Subject: tagging ychat-0.8.2 --- scripts/config.pl | 81 ++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 46 deletions(-) (limited to 'scripts/config.pl') diff --git a/scripts/config.pl b/scripts/config.pl index af58012..73b3ae5 100755 --- a/scripts/config.pl +++ b/scripts/config.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# The yhttpd Project (2004, 2005) +# The yChat Project (2004, 2005) # # This script modifues the src/glob.h file. @@ -8,27 +8,24 @@ use strict; use scripts::modules::file; print <; chomp $stdin; - prove_if_default(\$stdin); print "\n"; - if ( $stdin eq "yes") - { + if ( $stdin eq "yes") { print " You chose to use all the default before-compile options. Exiti-\n"; print " ng the configurator now!\n"; print $sep; @@ -44,46 +41,37 @@ for (;;) my @glob = fopen("src/glob.h.org"); my $flag = 0; -for (@glob) -{ - if ( $flag == 0 && /- CONFIG -/ ) - { +for (@glob) { + if ( $flag == 0 && /- CONFIG -/ ) { print $sep; $flag = 1; next; - } - elsif ( $flag == 1 ) - { - if ( /\*\// ) - { + } elsif ( $flag == 1 ) { + if ( /\*\// ) { $flag = 2; - } - else - { + } else { print; } next; - } - elsif ( $flag == 2 ) - { - if ( /#define (.+) (.+)/ ) - { + } elsif ( $flag == 2 ) { + if ( /#define (.+) (.+)/ ) { my $def = $1; my $val = $2; my $flg = 0; $flg = 1 if $val =~ s/"//g; - print " [Press enter to use default value: $val] "; + print " [Press enter to use default value: $val or q to quit] "; $stdin = ; chomp $stdin; - unless ( prove_if_default(\$stdin) ) - { + finish() if $stdin eq "q" or $stdin eq "quit"; + + unless ( parse_input_value(\$stdin,\$val) ) { $stdin = "\"$stdin\"" if $flg == 1; $_ = "#define $def $stdin\n"; } @@ -93,33 +81,28 @@ for (@glob) next; } - elsif ( /#define .+/ ) - { + elsif ( /#define .+/ ) { my $default = "true"; my $stdin; - for (;;) - { + for (;;) { $default = "false" if /\/\/#define/; - print " [Press enter to use default value: $default] "; + print " [Press enter to use default value: $default or q to quit] "; $stdin = ; chomp $stdin; + finish() if $stdin eq "q" or $stdin eq "quit"; last if $stdin eq "" || $stdin eq "true" || $stdin eq "false"; print " Wrong input: You need to specify true or false!\n"; } - if ( $default eq "true" ) - { - $_ = "//$_" - unless prove_if_default(\$stdin); + if ( $default eq "true" ) { + $_ = "//$_" unless parse_input_value(\$stdin,\$default); } - else - { - s/^\/\/// - unless prove_if_default(\$stdin); + else { + s/^\/\/// unless parse_input_value(\$stdin,\$default); } print "\n"; @@ -129,16 +112,22 @@ for (@glob) } } // for - fwrite("src/glob.h", @glob); +finish(); + +sub finish() { + fwrite("src/glob.h", @glob); + exit 0; +} -sub prove_if_default -{ +sub parse_input_value { my $val = shift; - if ( $$val eq "" ) - { + my $def = shift; + + if ( $$val eq "" || $$val eq $$def) { print " -> Using default option!\n"; return 1; } + print " -> Using new option $$val!\n"; return 0; } -- cgit v1.2.3