]> git.pond.sub.org Git - empserver/commitdiff
Use strict & warnings. Fix several minor bugs uncovered by it.
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 28 Jan 2004 21:21:48 +0000 (21:21 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 28 Jan 2004 21:21:48 +0000 (21:21 +0000)
Semantics of assigning to $[ changed in Perl 5, and its use is `highly
discouraged'.  Programs obviously assumed $[ affects all arrays, but
it doesn't in Perl 5.  If these programs ever worked, then certainly
not with Perl 5.  Remove the assignments and shift indexes
accordingly.

info/checklist.pl
info/emp2html.pl
info/info.pl
info/ls2html.pl
info/subj2html.pl

index 7a2471dcb8ed1444916c92931e025842d4bff613..279f17f0ee857965e4515abcc17128b9030e0696 100644 (file)
 # to check which Empire commands need to be documented.
 #
 
 # to check which Empire commands need to be documented.
 #
 
+use strict;
+use warnings;
+
+my ($com, @list, @obsolete, @Commands);
+
 open(LIST, "<player.list") || die "Can't read player.list\n";
 
 while(<LIST>) {
 open(LIST, "<player.list") || die "Can't read player.list\n";
 
 while(<LIST>) {
@@ -60,10 +65,10 @@ while (<LS>) {
 close LS;
 
 print "In list but not Commands:\n";
 close LS;
 
 print "In list but not Commands:\n";
-for $l (@list) {
+for my $l (@list) {
   print "  $l\n" unless grep (/^$l$/, @Commands);
 }
 print "In Commands but not list:\n";
   print "  $l\n" unless grep (/^$l$/, @Commands);
 }
 print "In Commands but not list:\n";
-for $c (@Commands) {
+for my $c (@Commands) {
   print "  $c\n" unless grep(/^$c$/, @list) || grep(/^$c$/, @obsolete);
 }
   print "  $c\n" unless grep(/^$c$/, @list) || grep(/^$c$/, @obsolete);
 }
index 249c4180fd2f25d01256a77394acdd1cfad10cf2..fa65ab883e4b78a63581ac142c4ff0860d5de3fb 100644 (file)
@@ -1,7 +1,9 @@
 #!/usr/local/bin/perl
 
 #!/usr/local/bin/perl
 
+use strict;
+use warnings;
 
 
-$[ = 1;                        # set array base to 1
+my (@Fld, $str, @a);
 
 line: while (<>) {
     chop;      # strip record separator
 
 line: while (<>) {
     chop;      # strip record separator
@@ -9,17 +11,17 @@ line: while (<>) {
 
 procline:
     if (/^\.TH/) {
 
 procline:
     if (/^\.TH/) {
-       $str=$Fld[3];
-       for ($i=4;$i <= $#Fld; $i++) {
+       $str=$Fld[2];
+       for (my $i=3; $i <= $#Fld; $i++) {
            $str .= " " . $Fld[$i];
        }
        $str = &htmlify($str);
        printf("<title>%s : %s</title><h1>%s : %s</h1>\n",
            $str .= " " . $Fld[$i];
        }
        $str = &htmlify($str);
        printf("<title>%s : %s</title><h1>%s : %s</h1>\n",
-              $Fld[2],$str,$Fld[2], $str);
+              $Fld[1], $str, $Fld[1], $str);
        next line;
     }
 
        next line;
     }
 
-    if (/^\.SY/) {
+    if (/^\.SY../) {
 #      $i = $_ =~ "\"" && ($RLENGTH = length($&), $RSTART = length($`)+1);
 #      $str = substr($_, $i + 1, length($_) - $i - 1);
        $str = substr($_,5);
 #      $i = $_ =~ "\"" && ($RLENGTH = length($&), $RSTART = length($`)+1);
 #      $str = substr($_, $i + 1, length($_) - $i - 1);
        $str = substr($_,5);
@@ -28,13 +30,13 @@ procline:
        next line;
     }
 
        next line;
     }
 
-    if (/^\.EX/) {
+    if (/^\.EX../) {
        $str = substr($_, 5);
        printf "<br><samp>[##:##] </samp><kbd>%s</kbd><p>\n", &htmlify($str);
        next line;
     }
 
        $str = substr($_, 5);
        printf "<br><samp>[##:##] </samp><kbd>%s</kbd><p>\n", &htmlify($str);
        next line;
     }
 
-    if (/^\.L/) {
+    if (/^\.L../) {
        $str = substr($_, 4);
        printf "<h2>%s</h2>\n", &htmlify($str);
        next line;
        $str = substr($_, 4);
        printf "<h2>%s</h2>\n", &htmlify($str);
        next line;
@@ -48,8 +50,8 @@ procline:
     if (/^\.SA/) {
        @a = split('[: ",.]+');
 
     if (/^\.SA/) {
        @a = split('[: ",.]+');
 
-       printf("See also : %s\n",&anchor($a[3]) );
-       for ($i = 4; $i <= $#a ; ($i)++) {       
+       printf("See also : %s\n",&anchor($a[2]) );
+       for (my $i = 3; $i <= $#a ; ($i)++) {       
            printf(", %s\n",&anchor($a[$i]));
        }
 
            printf(", %s\n",&anchor($a[$i]));
        }
 
@@ -58,7 +60,7 @@ procline:
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
-           for ($i = 1; $i <= $#a ; ($i)++) {       
+           for (my $i = 0; $i <= $#a ; ($i)++) {       
                printf(", %s\n",&anchor($a[$i]));
            }
        }
                printf(", %s\n",&anchor($a[$i]));
            }
        }
@@ -71,8 +73,8 @@ procline:
     if (/^(See also|See Also|see also)/) {
        @a = split('[: ,.]+');
 
     if (/^(See also|See Also|see also)/) {
        @a = split('[: ,.]+');
 
-       printf("See also : %s\n",&anchor($a[3]) );
-       for ($i = 4; $i <= $#a ; ($i)++) {       
+       printf("See also : %s\n",&anchor($a[2]) );
+       for (my $i = 3; $i <= $#a ; ($i)++) {       
            printf(", %s\n",&anchor($a[$i]));
        }
 
            printf(", %s\n",&anchor($a[$i]));
        }
 
@@ -81,7 +83,7 @@ procline:
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
-           for ($i = 1; $i <= $#a ; ($i)++) {       
+           for (my $i = 0; $i <= $#a ; ($i)++) {       
                printf(", %s\n",&anchor($a[$i]));
            }
        }
                printf(", %s\n",&anchor($a[$i]));
            }
        }
@@ -103,8 +105,8 @@ procline:
 #}
 
 sub anchor {
 #}
 
 sub anchor {
-    local($_) = @_;
-    local(@file,$file);
+    local ($_) = @_;
+    my (@file,$file);
     $file = $_ . ".t";
 #    if (-r $file) {
     if (1) {
     $file = $_ . ".t";
 #    if (-r $file) {
     if (1) {
@@ -113,9 +115,9 @@ sub anchor {
     } else {
        @file = <$_*t>;
        if (@file) {
     } else {
        @file = <$_*t>;
        if (@file) {
-         warn "Expanding $_ to $file[$[]\n";
-         $file[$[] =~ s/.t$/.html/;
-         return ("<a href=\"$file[$[]\">$_</a>");
+         warn "Expanding $_ to $file[0]\n";
+         $file[0] =~ s/.t$/.html/;
+         return ("<a href=\"$file[0]\">$_</a>");
        } else {
          warn "Unable to link $_\n";
          return ( "<em>$_</em>");
        } else {
          warn "Unable to link $_\n";
          return ( "<em>$_</em>");
@@ -126,7 +128,7 @@ sub anchor {
     
 # Translate HTML special characters into escape sequences
 sub htmlify {
     
 # Translate HTML special characters into escape sequences
 sub htmlify {
-        local($_) = @_;
+        local ($_) = @_;
        s/^\"(.*)\"$/$1/;
        s/\\&//g;               # a nothing character
         s/\&/&amp;/g;
        s/^\"(.*)\"$/$1/;
        s/\\&//g;               # a nothing character
         s/\&/&amp;/g;
@@ -134,15 +136,15 @@ sub htmlify {
         s/\>/&gt;/g;
        while (@a = /(\\\*Q)([A-Za-z0-9\-\.]+)(\\\*U)/) {
            /(\\\*Q)([A-Za-z\-]+)(\\\*U)/;
         s/\>/&gt;/g;
        while (@a = /(\\\*Q)([A-Za-z0-9\-\.]+)(\\\*U)/) {
            /(\\\*Q)([A-Za-z\-]+)(\\\*U)/;
-           $_ = $` . &anchor($a[2]) . $';
+           $_ = $` . &anchor($a[1]) . $';
        }
        while (@a = /(\\\*Q)(\"info )([A-Za-z0-9\-\.]+)(\\\*U)/) {
            /(\\\*Q)(\"info )([\w\-\.]+)(\\\*U)/;
        }
        while (@a = /(\\\*Q)(\"info )([A-Za-z0-9\-\.]+)(\\\*U)/) {
            /(\\\*Q)(\"info )([\w\-\.]+)(\\\*U)/;
-           $_ = $` . "\"info " . &anchor($a[3]) . $';
+           $_ = $` . "\"info " . &anchor($a[2]) . $';
        }
        while (@a = /(\"info )([A-Za-z0-9\-\.]+)/) {
            /(\"info )([\w\-\.]+)/;
        }
        while (@a = /(\"info )([A-Za-z0-9\-\.]+)/) {
            /(\"info )([\w\-\.]+)/;
-           $_ = $` . "\"info " . &anchor($a[2]) . $';
+           $_ = $` . "\"info " . &anchor($a[1]) . $';
        }
         s/\\\*Q/<em>/g;
         s/\\\*U/<\/em>/g;
        }
         s/\\\*Q/<em>/g;
         s/\\\*U/<\/em>/g;
index 91610cd80af7ca6ec10768b9975cd1f8a5c77954..96e1596bcf25bb6568464ee68652423684ab27a1 100644 (file)
 # flush_subj      Print a row of Subjects to TOP
 # error           Print an integrity error to STDERR and exit with code 1.
 
 # flush_subj      Print a row of Subjects to TOP
 # error           Print an integrity error to STDERR and exit with code 1.
 
+use strict;
+use warnings;
+
+our (@dirs, $dir, $filename, %filedir, @Subjects, $type, %desc, %level);
+our (%see_also, %subject, %largest, $subj, @rowsubj, @colsubj, @subj);
+
 eval("require 5");             # Test for perl version 5
 die "info.pl requires version 5 of perl.\n" if $@;
 
 eval("require 5");             # Test for perl version 5
 die "info.pl requires version 5 of perl.\n" if $@;
 
@@ -208,9 +214,9 @@ sub parse_file {
 
 # Create %subject from %see_also
 sub parse_see_also {
 
 # Create %subject from %see_also
 sub parse_see_also {
-  local (@see_also) = split(/, /, $see_also{$filename});
+  my (@see_also) = split(/, /, $see_also{$filename});
   local ($dir) = $filedir{$filename};
   local ($dir) = $filedir{$filename};
-  local ($found);              # Does this item belong to any Subject?
+  my ($found);         # Does this item belong to any Subject?
 
   for (@see_also) {
     if (!(defined $filedir{$_})) { # is this entry a subject?
 
   for (@see_also) {
     if (!(defined $filedir{$_})) { # is this entry a subject?
@@ -225,6 +231,7 @@ sub parse_see_also {
 # Add a new entry to %subject and possibly to %largest
 sub set_subject {
   $subject{$_}{$dir} .= "$filename\n";
 # Add a new entry to %subject and possibly to %largest
 sub set_subject {
   $subject{$_}{$dir} .= "$filename\n";
+  $largest{$_} = "" unless defined $largest{$_};
   $largest{$_} = $filename if length $filename > length $largest{$_};
   $largest{$_} = $dir if length $dir > length $largest{$_};
 }
   $largest{$_} = $filename if length $filename > length $largest{$_};
   $largest{$_} = $dir if length $dir > length $largest{$_};
 }
@@ -283,8 +290,9 @@ EOF
       $subj eq 'TOP' || grep (/^$subj$/, @rowsubj);
   }
 
       $subj eq 'TOP' || grep (/^$subj$/, @rowsubj);
   }
 
-  for $i (0..2) {
-    for ($j = $i; $j <= $#rowsubj; $j += 3) {
+  my $k = 0;
+  for my $i (0..2) {
+    for (my $j = $i; $j <= $#rowsubj; $j += 3) {
       $colsubj[$j] = $rowsubj[$k++];
     }
   }
       $colsubj[$j] = $rowsubj[$k++];
     }
   }
@@ -316,7 +324,7 @@ sub flush_subj {
 
 # Print an integrity error message and exit with code 1
 sub error {
 
 # Print an integrity error message and exit with code 1
 sub error {
-  local ($error) = @_;
+  my ($error) = @_;
 
   print STDERR "Error on line $. of $filedir{$filename}/$filename.t:\n";
   print STDERR "$_";
 
   print STDERR "Error on line $. of $filedir{$filename}/$filename.t:\n";
   print STDERR "$_";
index 6a5be1b6bfb90b9e24fa7637caf82247b9c49a4b..611e4479709c1d095259a9d96cd3afd7f741dfbd 100644 (file)
@@ -1,5 +1,8 @@
 #!/usr/local/bin/perl 
 
 #!/usr/local/bin/perl 
 
+use strict;
+use warnings;
+
 printf("<pre>\n");
 while (<>) {
     s/([\w\.\-]+)\.html/<a href=\"$1.html\">$1<\/a>/g;
 printf("<pre>\n");
 while (<>) {
     s/([\w\.\-]+)\.html/<a href=\"$1.html\">$1<\/a>/g;
index 034e09ef26fdafb75d32ad4d63fcf9d8bce8f296..234ecd10a79b55de3322070a128b61d923b87d28 100644 (file)
@@ -1,8 +1,10 @@
 #!/usr/local/bin/perl
 
 #!/usr/local/bin/perl
 
+use strict;
+use warnings;
 
 
-$[ = 1;                        # set array base to 1
-$dome = 0;
+my $dome = 0;
+my (@Fld, $str, @a);
 
 line: while (<>) {
     chop;      # strip record separator
 
 line: while (<>) {
     chop;      # strip record separator
@@ -10,17 +12,17 @@ line: while (<>) {
 
 procline:
     if (/^\.TH/) {
 
 procline:
     if (/^\.TH/) {
-       $str=$Fld[3];
-       for ($i=4;$i <= $#Fld; $i++) {
+       $str=$Fld[2];
+       for (my $i=3; $i <= $#Fld; $i++) {
            $str .= " " . $Fld[$i];
        }
        $str = &htmlify($str);
        printf("<title>%s : %s</title><h1>%s : %s</h1>\n",
            $str .= " " . $Fld[$i];
        }
        $str = &htmlify($str);
        printf("<title>%s : %s</title><h1>%s : %s</h1>\n",
-              $Fld[2],$str,$Fld[2], $str);
+              $Fld[1], $str, $Fld[1], $str);
        next line;
     }
 
        next line;
     }
 
-    if (/^\.SY/) {
+    if (/^\.SY../) {
 #      $i = $_ =~ "\"" && ($RLENGTH = length($&), $RSTART = length($`)+1);
 #      $str = substr($_, $i + 1, length($_) - $i - 1);
        $str = substr($_,5);
 #      $i = $_ =~ "\"" && ($RLENGTH = length($&), $RSTART = length($`)+1);
 #      $str = substr($_, $i + 1, length($_) - $i - 1);
        $str = substr($_,5);
@@ -29,7 +31,7 @@ procline:
        next line;
     }
 
        next line;
     }
 
-    if (/^\.EX/) {
+    if (/^\.EX../) {
        $str = substr($_, 5);
        printf "<br><samp>[##:##] </samp><kbd>%s</kbd><p>\n", &htmlify($str);
        next line;
        $str = substr($_, 5);
        printf "<br><samp>[##:##] </samp><kbd>%s</kbd><p>\n", &htmlify($str);
        next line;
@@ -37,8 +39,8 @@ procline:
 
     if (/^\.L/) {
        @a = split('[: ",.]+');
 
     if (/^\.L/) {
        @a = split('[: ",.]+');
-       $str = &anchor($a[3]);
-       $str = ("$str $a[4]");
+       $str = &anchor($a[2]);
+       $str = ("$str $a[3]") if defined $a[3];
        printf("<br>%s\n", $str);
        next line;
     }
        printf("<br>%s\n", $str);
        next line;
     }
@@ -53,9 +55,9 @@ procline:
     if ($dome == 1) {
        @a = split('[: ",.]+');
 
     if ($dome == 1) {
        @a = split('[: ",.]+');
 
-       for ($i = 2; $i <= $#a ; ($i)++) {       
+       for (my $i = 1; $i <= $#a ; ($i)++) {       
            printf("%s",&anchor($a[$i]));
            printf("%s",&anchor($a[$i]));
-           for ($j = 0; $j < 20 - length($a[$i]); $j++) {
+           for (my $j = 0; $j < 20 - length($a[$i]); $j++) {
                printf(" ");
            }
        }
                printf(" ");
            }
        }
@@ -65,9 +67,9 @@ procline:
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
-           for ($i = 2; $i <= $#a ; ($i)++) {       
+           for (my $i = 1; $i <= $#a ; ($i)++) {       
                printf("%s",&anchor($a[$i]));
                printf("%s",&anchor($a[$i]));
-               for ($j = 0; $j < 20 - length($a[$i]); $j++) {
+               for (my $j = 0; $j < 20 - length($a[$i]); $j++) {
                    printf(" ");
                }
            }
                    printf(" ");
                }
            }
@@ -79,8 +81,8 @@ procline:
     if (/^\.SA/) {
        @a = split('[: ",.]+');
 
     if (/^\.SA/) {
        @a = split('[: ",.]+');
 
-       printf("See also : %s\n",&anchor($a[3]) );
-       for ($i = 4; $i <= $#a ; ($i)++) {       
+       printf("See also : %s\n",&anchor($a[2]) );
+       for (my $i = 3; $i <= $#a ; ($i)++) {       
            printf(", %s\n",&anchor($a[$i]));
        }
 
            printf(", %s\n",&anchor($a[$i]));
        }
 
@@ -89,7 +91,7 @@ procline:
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
-           for ($i = 1; $i <= $#a ; ($i)++) {       
+           for (my $i = 0; $i <= $#a ; ($i)++) {       
                printf(", %s\n",&anchor($a[$i]));
            }
        }
                printf(", %s\n",&anchor($a[$i]));
            }
        }
@@ -102,8 +104,8 @@ procline:
     if (/^(See also|See Also|see also)/) {
        @a = split('[: ,.]+');
 
     if (/^(See also|See Also|see also)/) {
        @a = split('[: ,.]+');
 
-       printf("See also : %s\n",&anchor($a[3]) );
-       for ($i = 4; $i <= $#a ; ($i)++) {       
+       printf("See also : %s\n",&anchor($a[2]) );
+       for (my $i = 3; $i <= $#a ; ($i)++) {       
            printf(", %s\n",&anchor($a[$i]));
        }
 
            printf(", %s\n",&anchor($a[$i]));
        }
 
@@ -112,7 +114,7 @@ procline:
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
            @a = split('[: ,.]+');
            @Fld = split(' ', $_, 9999);
            if (/^\./) { goto procline; }
-           for ($i = 1; $i <= $#a ; ($i)++) {       
+           for (my $i = 0; $i <= $#a ; ($i)++) {       
                printf(", %s\n",&anchor($a[$i]));
            }
        }
                printf(", %s\n",&anchor($a[$i]));
            }
        }
@@ -134,8 +136,8 @@ procline:
 #}
 
 sub anchor {
 #}
 
 sub anchor {
-    local($_) = @_;
-    local(@file,$file);
+    local ($_) = @_;
+    my (@file, $file);
     $file = $_ . ".t";
 #    if (-r $file) {
     if (1) {
     $file = $_ . ".t";
 #    if (-r $file) {
     if (1) {
@@ -144,9 +146,9 @@ sub anchor {
     } else {
        @file = <$_*t>;
        if (@file) {
     } else {
        @file = <$_*t>;
        if (@file) {
-         warn "Expanding $_ to $file[$[]\n";
-         $file[$[] =~ s/.t$/.html/;
-         return ("<a href=\"$file[$[]\">$_</a>");
+         warn "Expanding $_ to $file[0]\n";
+         $file[0] =~ s/.t$/.html/;
+         return ("<a href=\"$file[0]\">$_</a>");
        } else {
          warn "Unable to link $_\n";
          return ( "<em>$_</em>");
        } else {
          warn "Unable to link $_\n";
          return ( "<em>$_</em>");
@@ -165,15 +167,15 @@ sub htmlify {
         s/\>/&gt;/g;
        while (@a = /(\\\*Q)([A-Za-z0-9\-\.]+)(\\\*U)/) {
            /(\\\*Q)([A-Za-z\-]+)(\\\*U)/;
         s/\>/&gt;/g;
        while (@a = /(\\\*Q)([A-Za-z0-9\-\.]+)(\\\*U)/) {
            /(\\\*Q)([A-Za-z\-]+)(\\\*U)/;
-           $_ = $` . &anchor($a[2]) . $';
+           $_ = $` . &anchor($a[1]) . $';
        }
        while (@a = /(\\\*Q)(\"info )([A-Za-z0-9\-\.]+)(\\\*U)/) {
            /(\\\*Q)(\"info )([\w\-\.]+)(\\\*U)/;
        }
        while (@a = /(\\\*Q)(\"info )([A-Za-z0-9\-\.]+)(\\\*U)/) {
            /(\\\*Q)(\"info )([\w\-\.]+)(\\\*U)/;
-           $_ = $` . "\"info " . &anchor($a[3]) . $';
+           $_ = $` . "\"info " . &anchor($a[2]) . $';
        }
        while (@a = /(\"info )([A-Za-z0-9\-\.]+)/) {
            /(\"info )([\w\-\.]+)/;
        }
        while (@a = /(\"info )([A-Za-z0-9\-\.]+)/) {
            /(\"info )([\w\-\.]+)/;
-           $_ = $` . "\"info " . &anchor($a[2]) . $';
+           $_ = $` . "\"info " . &anchor($a[1]) . $';
        }
         s/\\\*Q/<em>/g;
         s/\\\*U/<\/em>/g;
        }
         s/\\\*Q/<em>/g;
         s/\\\*U/<\/em>/g;