[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
afuna.
Files modified:
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]](https://www.dreamwidth.org/img/silk/identity/user.png)
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). - " </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 .= " <font color=\"$self->{'color'}\">".LJ::ehtml($word)."</font> "; - $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 ) . + " </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 .= " <font color=\"$self->{'color'}\">" . LJ::ehtml( $word ) . "</font> "; + $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); --------------------------------------------------------------------------------