remove misleading comment (from M.J.T. Guy)
[p5sagit/p5-mst-13.2.git] / utils / perlbug.PL
index c46df79..208da36 100644 (file)
@@ -37,8 +37,8 @@ my @patches;
 while (<PATCH_LEVEL>) {
     last if /^\s*}/;
     chomp;
-    s/^\s+,?"?//;
-    s/"?,?$//;
+    s/^\s+,?\s*"?//;
+    s/"?\s*,?$//;
     s/(['\\])/\\$1/g;
     push @patches, $_ unless $_ eq 'NULL';
 }
@@ -57,12 +57,14 @@ print "Extracting $file (with variable substitutions)\n";
 # In this section, perl variables will be expanded during extraction.
 # You can use $Config{...} to use Configure variables.
 
+my $extract_version = sprintf("v%vd", $^V);
+
 print OUT <<"!GROK!THIS!";
 $Config{startperl}
     eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
        if \$running_under_some_shell;
 
-my \$config_tag1 = '$] - $Config{cf_time}';
+my \$config_tag1 = '$extract_version - $Config{cf_time}';
 
 my \$patchlevel_date = $patchlevel_date;
 my \$patch_tags = '$patch_tags';
@@ -76,7 +78,7 @@ my \@patches = (
 print OUT <<'!NO!SUBS!';
 
 use Config;
-use File::Spec::Functions;
+use File::Spec;                # keep perlbug Perl 5.005 compatible
 use Getopt::Std;
 use strict;
 
@@ -89,7 +91,7 @@ BEGIN {
     $::HaveUtil = ($@ eq "");
 };
 
-my $Version = "1.27";
+my $Version = "1.28";
 
 # Changed in 1.06 to skip Mail::Send and Mail::Util if not available.
 # Changed in 1.07 to see more sendmail execs, and added pipe output.
@@ -121,6 +123,7 @@ my $Version = "1.27";
 # Changed in 1.25 Warn on failure to open save file. HVDS 98-07-12
 # Changed in 1.26 Don't require -t STDIN for -ok. HVDS 98-07-15
 # Changed in 1.27 Added Mac OS and File::Spec support CNANDOR 99-07-27
+# Changed in 1.28 Additional questions for Perlbugtron RFOLEY 20.03.2000
 
 # TODO: - Allow the user to re-name the file on mail failure, and
 #       make sure failure (transmission-wise) of Mail::Send is
@@ -128,10 +131,12 @@ my $Version = "1.27";
 #       - Test -b option
 
 my( $file, $usefile, $cc, $address, $perlbug, $testaddress, $filename,
-    $subject, $from, $verbose, $ed, $outfile, $Is_MacOS,
+    $subject, $from, $verbose, $ed, $outfile, $Is_MacOS, $category, $severity, 
     $fh, $me, $Is_MSWin32, $Is_VMS, $msg, $body, $andcc, %REP, $ok);
 
-my $config_tag2 = "$] - $Config{cf_time}";
+my $perl_version = $^V ? sprintf("v%vd", $^V) : $];
+
+my $config_tag2 = "$perl_version - $Config{cf_time}";
 
 Init();
 
@@ -153,6 +158,33 @@ Send();
 
 exit;
 
+sub ask_for_alternatives {
+    my $name = shift;
+    my $default = shift;
+    my @alts = @_;
+    my $alt = "";
+    paraprint <<EOF;
+Please pick a \u$name from the following:
+
+    @alts
+
+EOF
+    my $err = 0;
+    my $joined_alts = join('|', @alts);
+    do {
+       if ($err++ > 5) {
+           die "Invalid $name: aborting.\n";
+       }
+       print "Please enter a \u$name [$default]: ";
+       $alt = <>;
+       chomp $alt;
+       if ($alt =~ /^\s*$/) {
+           $alt = $default;
+       }
+    } while ($alt !~ /^($joined_alts)$/i);
+    lc $alt;
+}
+
 sub Init {
     # -------- Setup --------
 
@@ -242,8 +274,10 @@ EOF
            $::opt_C = 1; # don't send a copy to the local admin
            $::opt_s = 1; # we have a subject line
            $subject = ($::opt_n ? 'Not ' : '')
-                   . "OK: perl $] ${patch_tags}on"
+                   . "OK: perl $perl_version ${patch_tags}on"
                    ." $::Config{'archname'} $::Config{'osvers'} $subject";
+           $category = "install";
+           $severity = "none";
            $ok = 1;
        } else {
            Help();
@@ -433,6 +467,16 @@ EOF
        }
     }
 
+    # Prompt for category of bug
+    $category ||= ask_for_alternatives("category", "core",
+                                    qw(core docs install
+                                       library utilities));
+
+    # Prompt for severity of bug
+    $severity ||= ask_for_alternatives("severity", "low",
+                                      qw(critical high medium
+                                         low wishlist none));
+
     # Generate scratch file to edit report in
     $filename = filename();
 
@@ -470,7 +514,7 @@ EOF
 
     print REP <<EOF;
 This is a $reptype report for perl from $from,
-generated with the help of perlbug $Version running under perl $].
+generated with the help of perlbug $Version running under perl $perl_version.
 
 EOF
 
@@ -512,13 +556,19 @@ EOF
 sub Dump {
     local(*OUT) = @_;
 
-    print REP "\n---\n";
-    print REP "This perlbug was built using Perl $config_tag2\n",
-           "It is being executed now by  Perl $config_tag1.\n\n"
+    print OUT <<EFF;
+---
+Flags:
+    category=$category
+    severity=$severity
+---
+EFF
+    print OUT "This perlbug was built using Perl $config_tag1\n",
+           "It is being executed now by  Perl $config_tag2.\n\n"
        if $config_tag2 ne $config_tag1;
 
     print OUT <<EOF;
-Site configuration information for perl $]:
+Site configuration information for perl $perl_version:
 
 EOF
     if ($::Config{cf_by} and $::Config{cf_time}) {
@@ -534,7 +584,7 @@ EOF
     print OUT <<EOF;
 
 ---
-\@INC for perl $]:
+\@INC for perl $perl_version:
 EOF
     for my $i (@INC) {
        print OUT "    $i\n";
@@ -543,7 +593,7 @@ EOF
     print OUT <<EOF;
 
 ---
-Environment for perl $]:
+Environment for perl $perl_version:
 EOF
     my @env =
         qw(PATH LD_LIBRARY_PATH LANG PERL_BADLANG SHELL HOME LOGDIR LANGUAGE);
@@ -557,7 +607,7 @@ EOF
                "\n";
     }
     if ($verbose) {
-       print OUT "\nComplete configuration data for perl $]:\n\n";
+       print OUT "\nComplete configuration data for perl $perl_version:\n\n";
        my $value;
        foreach (sort keys %::Config) {
            $value = $::Config{$_};
@@ -848,8 +898,8 @@ sub filename {
        : '/tmp';
     $filename = "bugrep0$$";
 #    $dir .= "\\" if $Is_MSWin32 and $dir !~ m|[\\/]$|;
-    $filename++ while -e catfile($dir, $filename);
-    $filename = catfile($dir, $filename);
+    $filename++ while -e File::Spec->catfile($dir, $filename);
+    $filename = File::Spec->catfile($dir, $filename);
 }
 
 sub paraprint {
@@ -1126,8 +1176,9 @@ by Gurusamy Sarathy (E<lt>gsar@activestate.comE<gt>), Tom Christiansen
 Charles F. Randall (E<lt>cfr@pobox.comE<gt>), Mike Guy
 (E<lt>mjtg@cam.a.ukE<gt>), Dominic Dunlop (E<lt>domo@computer.orgE<gt>),
 Hugo van der Sanden (E<lt>hv@crypt0.demon.co.ukE<gt>),
-Jarkko Hietaniemi (E<lt>jhi@iki.fiE<gt>), hris Nandor
-(E<lt>pudge@pobox.comE<gt>), and Jon Orwant (E<lt>orwant@media.mit.eduE<gt>).
+Jarkko Hietaniemi (E<lt>jhi@iki.fiE<gt>), Chris Nandor
+(E<lt>pudge@pobox.comE<gt>), Jon Orwant (E<lt>orwant@media.mit.eduE<gt>,
+and Richard Foley (E<lt>richard@rfi.netE<gt>).
 
 =head1 SEE ALSO