afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-07-01 03:39 pm

[dw-free] Whitespace fix for SpellCheck.pm

[commit: http://hg.dwscoalition.org/dw-free/rev/4758580ad6f5]

Whitespace fix for SpellCheck.pm

(the tabs were bothering me. And then while I was in there, it seemed silly
not to go after the spacing as well...)

patch by [personal profile] afuna.

Files modified:
  • cgi-bin/LJ/SpellCheck.pm
--------------------------------------------------------------------------------
diff -r f28123226658 -r 4758580ad6f5 cgi-bin/LJ/SpellCheck.pm
--- a/cgi-bin/LJ/SpellCheck.pm	Wed Jul 01 15:27:55 2009 +0000
+++ b/cgi-bin/LJ/SpellCheck.pm	Wed Jul 01 23:38:24 2009 +0800
@@ -22,7 +22,7 @@ use Config;
 use Config;
 use constant PERLIO_IS_ENABLED => $Config{useperlio};
 
-use vars qw($VERSION);
+use vars qw( $VERSION );
 $VERSION = '2.0';
 
 # Good spellcommand values:
@@ -61,9 +61,9 @@ sub check_html {
     my ( $iwrite, $iread ) = $r->spawn( $self->{command}, $self->{command_args} );
     
     my $read_data = sub {
-        my ($fh) = @_;
+        my ( $fh ) = @_;
         my $data;
-        $data = <$fh> if PERLIO_IS_ENABLED || IO::Select->new($fh)->can_read(10);
+        $data = <$fh> if PERLIO_IS_ENABLED || IO::Select->new( $fh )->can_read( 10 );
         return defined $data ? $data : '';
     };
 
@@ -77,51 +77,51 @@ sub check_html {
     my $output = "";
     my $footnotes = "";
     
-    my ($srcidx, $lineidx, $mscnt, $other_bad);
+    my ( $srcidx, $lineidx, $mscnt, $other_bad );
     $lineidx = 1;
     $mscnt = 0;
-    foreach my $inline (split(/\n/, $$journal)) {
-	$srcidx = 0;
-	chomp($inline);
-	print $iwrite "^$inline\n";
-	
-	my $idata;
-	do {
-	    $idata = $read_data->($iread);
-	    chomp($idata);
-	    
-	    if ($idata =~ /^& /) {
-		$idata =~ s/^& (\S+) (\d+) (\d+): //;
-		$mscnt++;
-		my ($word, $sugcount, $ofs) = ($1, $2, $3);
-		$ofs -= 1; # because ispell reports "1" for first character
-		
-		$output .= LJ::ehtml(substr($inline, $srcidx, $ofs-$srcidx));
-		$output .= "<font color=\"$self->{'color'}\">" . LJ::ehtml($word)."</font>";
-		
-		$footnotes .= "<tr valign=top><td align=right><font color=$self->{'color'}>" . LJ::ehtml($word).
-                              "&nbsp;</font></td><td>".LJ::ehtml($idata)."</td></tr>";
-		
-		$srcidx = $ofs + length($word);
-	    } elsif ($idata =~ /^\# /) {
-		$other_bad = 1;
-		$idata =~ /^\# (\S+) (\d+)/;
-		my ($word, $ofs) = ($1, $2);
-		$ofs -= 1; # because ispell reports "1" for first character
-		$output .= LJ::ehtml(substr($inline, $srcidx, $ofs-$srcidx));
-		$output .= "&nbsp;<font color=\"$self->{'color'}\">".LJ::ehtml($word)."</font>&nbsp;";
-		$srcidx = $ofs + length($word);
-	    }
-	} while ($idata ne "");
-	$output .= LJ::ehtml(substr($inline, $srcidx, length($inline)-$srcidx)) . "<br>\n";
-	$lineidx++;
+    foreach my $inline ( split( /\n/, $$journal ) ) {
+        $srcidx = 0;
+        chomp( $inline );
+        print $iwrite "^$inline\n";
+        
+        my $idata;
+        do {
+            $idata = $read_data->( $iread );
+            chomp( $idata );
+            
+            if ( $idata =~ /^& / ) {
+                $idata =~ s/^& (\S+) (\d+) (\d+): //;
+                $mscnt++;
+                my ( $word, $sugcount, $ofs ) = ( $1, $2, $3 );
+                $ofs -= 1; # because ispell reports "1" for first character
+                
+                $output .= LJ::ehtml( substr( $inline, $srcidx, $ofs - $srcidx ) );
+                $output .= "<font color=\"$self->{'color'}\">" . LJ::ehtml( $word ) . "</font>";
+                
+                $footnotes .= "<tr valign=top><td align=right><font color=$self->{'color'}>" . LJ::ehtml( $word ) .
+                              "&nbsp;</font></td><td>" . LJ::ehtml( $idata ) . "</td></tr>";
+                
+                $srcidx = $ofs + length( $word );
+            } elsif ($idata =~ /^\# /) {
+                $other_bad = 1;
+                $idata =~ /^\# (\S+) (\d+)/;
+                my ( $word, $ofs ) = ( $1, $2 );
+                $ofs -= 1; # because ispell reports "1" for first character
+                $output .= LJ::ehtml( substr( $inline, $srcidx, $ofs - $srcidx ) );
+                $output .= "&nbsp;<font color=\"$self->{'color'}\">" . LJ::ehtml( $word ) . "</font>&nbsp;";
+                $srcidx = $ofs + length( $word );
+            }
+        } while ( $idata ne "" );
+            $output .= LJ::ehtml( substr( $inline, $srcidx, length( $inline ) - $srcidx ) ) . "<br>\n";
+            $lineidx++;
     }
 
     $iread->close;
     $iwrite->close;
 
 
-    return (($mscnt || $other_bad) ? "$output<p><b>Suggestions:</b><table cellpadding=3 border=0>$footnotes</table>" : "");
+    return ( ( $mscnt || $other_bad ) ? "$output<p><b>Suggestions:</b><table cellpadding=3 border=0>$footnotes</table>" : "" );
 }
 
 1;
@@ -135,8 +135,8 @@ LJ::SpellCheck - let users check spellin
 
   use LJ::SpellCheck;
   my $s = new LJ::SpellCheck { 'spellcommand' => 'ispell -a -h',
-			       'color' => '#ff0000',
-			   };
+                   'color' => '#ff0000',
+               };
 
   my $text = "Lets mispell thigns!";
   my $correction = $s->check_html(\$text);
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org