diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index cce971a9..e94daf63 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,8 +13,8 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 230, - BUILD_DATE => "2010-07-04", + BUILD_REVISION => 232, + BUILD_DATE => "2010-07-22", }; 1; diff --git a/modules/gencstd.pl b/modules/gencstd.pl new file mode 100755 index 00000000..22c460a7 --- /dev/null +++ b/modules/gencstd.pl @@ -0,0 +1,112 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use HTML::Entities; + +my $debug = 0; + +# for paragraphs +my $USER_SPECIFIED = 1; +my $RESULTS_SPECIFIED = 2; + + +my ($section, $paragraph, $section_specified, $paragraph_specified, $match, $list_only); + +$section_specified = 0; +$paragraph_specified = 0; +$match = 1; + +if(not defined $section) { + $section = "1."; + $paragraph = 1; +} + +open FH, "; +close FH; + +my $text = join '', @contents; +$text =~ s/\r//g; + +my $result; +my $found_section = ""; +my $found_section_title = ""; +my $section_title; +my $found_paragraph; +my $found = 0; +my $matches = 0; +my $this_section; +my $comma = ""; + +print "\n\n"; + +#$debug = 9999; + +my $last_section_number = 0; +my $section_number = 0; + +while($text =~ m/^\s{4,6}(\d+\.[0-9\.]*)/msg) { + $last_section_number = $section_number; + $this_section = $1; + + ($section_number) = $this_section =~ /([^.]+)\./; + + print "----------------------------------\n" if $debug >= 2; + print "Processing section [$this_section]; number [$section_number]\n" if $debug; + + + my $diff = $section_number - $last_section_number; + print "Diff: $diff\n" if $debug >= 2; + + if($section_number > 0 and $diff < 0 or $diff > 1) { + die "Diff out of bounds: $diff"; + } + + my $section_text; + + if($text =~ m/(.*?)^(?=\s{4,6}\d+\.)/msg) { + $section_text = $1; + } else { + print "No section text, end of file marker found.\n" if $debug >= 4; + last; + } + + if($section_text =~ m/(.*?)$/msg) { + $section_title = $1 if length $1; + $section_title =~ s/^\s+//; + $section_title =~ s/\s+$//; + } + + print "$this_section [$section_title]\n" if $debug >= 2; + + print "
\n"; + print ""; + print "

$this_section [$section_title]

"; + print "
\n"; + + while($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgc or $section_text =~ m/^(\d+)\s(.*)/msg) { + my $p = $1 ; + my $t = $2; + + + print "paragraph $p: [$t]\n" if $debug >= 3; + + $t = encode_entities($t); + + print ""; + print "
$p $t
\n"; + print "
\n"; + } + + last if $found && $paragraph_specified == $USER_SPECIFIED; + + if($paragraph_specified == $USER_SPECIFIED) { + print "No such paragraph '$paragraph' in section '$section' of n1256.\n"; + exit 0; + } +} + +print "\n\n\n"; +