This file is indexed.

/usr/share/perl5/Pod/Spell.pm is in libpod-spell-perl 1.01-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
require 5;
package Pod::Spell;    # Time-stamp: "2001-10-27 00:05:01 MDT"
use strict;
use vars qw(@ISA $VERSION);
$VERSION = '1.01';
use Pod::Parser ();
@ISA = ('Pod::Parser');

use constant MAXWORDLENGTH => 50; # max length of a word

BEGIN { *DEBUG = sub () {0} unless defined &DEBUG }
use Pod::Wordlist ();
use Pod::Escapes ('e2char');
use Text::Wrap ('wrap');
 # We don't need a very new version of Text::Wrap, altho they are nicer.
$Text::Wrap::huge = 'overflow';

use integer;
use locale;    # so our uc/lc works right
use Carp;

#==========================================================================
#
#  Override some methods
#

sub new {
  my $x = shift;
  my $new = $x->SUPER::new(@_);
  $new->{'spell_stopwords'} = { };
  @{ $new->{'spell_stopwords'} }{ keys %Pod::Wordlist::Wordlist } = ();
  $new->{'region'} = [];
  return $new;
}

sub verbatim { return ''; } # totally ignore verbatim sections

#----------------------------------------------------------------------

sub _get_stopwords_from {
  my $stopwords = $_[0]{'spell_stopwords'};

  my $word;
  while($_[1] =~ m<(\S+)>g) {
    $word = $1;
    if($word =~ m/^!(.+)/s) {  # "!word" deletes from the stopword list
      delete $stopwords->{$1};
      DEBUG and print "Unlearning stopword $1\n";
    } else {
      $stopwords->{$1} = 1;
      DEBUG and print "Learning stopword $1\n";
    }
  }
  return;

}

#----------------------------------------------------------------------

sub textblock {
  my($self, $paragraph) = @_;
  if(@{ $self->{'region'} }) {
    my $last = $self->{'region'}[-1];
    if($last eq 'stopwords') {
      $self->_get_stopwords_from( $paragraph );
      return;
    } elsif($last eq ':stopwords') {
      $self->_get_stopwords_from( $self->interpolate($paragraph) );
       # I guess that'd work.
      return;
    } elsif($last !~ m/^:/s) {
      DEBUG and printf "Ignoring a textblock because inside a %s region.\n",
        $self->{'region'}[-1];
      return;
    }
     # else fall thru, as with a :footnote region or something...
  }
  $self->_treat_words( $self->interpolate($paragraph) );
  return;
}

sub command {
  my $self = shift;
  my $command = shift;
  return if $command eq 'pod';

  if($command eq 'begin') {
    my $region_name;
    #print "BEGIN <$_[0]>\n";
    if(shift(@_) =~ m/^\s*(\S+)/s) {
      $region_name = $1;
    } else {
      $region_name = 'WHATNAME';
    }
    DEBUG and print "~~~~ Beginning region \"$region_name\" ~~~~\n";
    push @{ $self->{'region'} }, $region_name;
    
  } elsif($command eq 'end') {
    pop @{ $self->{'region'} }; # doesn't bother to check

  } elsif($command eq 'for') {
    if($_[0] =~ s/^\s*(\:?)stopwords\s*(.*)//s) {
      my $para = $2;
      $para = $self->interpolate($para) if $1;
      DEBUG > 1 and print "Stopword para: <$2>\n";
      $self->_get_stopwords_from( $para );
    }
  } elsif(@{ $self->{'region'} }) {  # TODO: accept POD formatting
    # ignore
  } elsif(
    $command eq 'head1' or $command eq 'head2' or
    $command eq 'head2' or $command eq 'head3' or
    $command eq 'item'
  ) {
    my $out_fh = $self->output_handle();
    print $out_fh "\n";
    $self->_treat_words( $self->interpolate(shift) );
    #print $out_fh "\n";
  } else {
    # no-op
  }
  return;
}

#--------------------------------------------------------------------------

sub interior_sequence {
  my $self = shift;
  my $command = shift;

  return '' if $command eq 'X' or $command eq 'Z';

  local $_ = shift;

  # Expand escapes into the actual character now, carping if invalid.
  if ($command eq 'E') {
    my $it = e2char($_);
    if(defined $it) {
      return $it;
    } else {
      carp "Unknown escape: E<$_>";
      return "E<$_>";
    }
  }

  # For all the other sequences, empty content produces no output.
  return if $_ eq '';

  if ($command eq 'B' or $command eq 'I' or $command eq 'S') {
    $_;
  } elsif ($command eq 'C' or $command eq 'F') {
    # don't lose word-boundaries
    my $out = '';
    $out .= ' ' if s/^\s+//s;
    my $append;
    $append = 1 if s/\s+$//s;
    $out .= '_' if length $_;
     # which, if joined to another word, will set off the Perl-token alarm
    $out .= ' ' if $append;
    $out;
  } elsif ($command eq 'L') {
    return $1 if m/^([^|]+)\|/s;
    '';
  } else {
    carp "Unknown sequence $command<$_>"
  }
}

#==========================================================================
# The guts:

sub _treat_words {
  my $p = shift;
  # Count the things in $_[0]
  DEBUG > 1 and print "Content: <", $_[0], ">\n";

  my $stopwords = $p->{'spell_stopwords'};
  my $word;
  $_[0] =~ tr/\xA0\xAD/ /d;
    # i.e., normalize non-breaking spaces, and delete soft-hyphens
  
  my $out = '';
  
  my($leading, $trailing);
  while($_[0] =~ m<(\S+)>g) {
    # Trim normal English punctuation, if leading or trailing.
    next if length $1 > MAXWORDLENGTH;
    $word = $1;
    if( $word =~ s/^([\`\"\'\(\[])//s )
     { $leading = $1 } else { $leading = '' }
    
    if( $word =~ s/([\)\]\'\"\.\:\;\,\?\!]+)$//s )
     { $trailing = $1 } else { $trailing = '' }
    
    if($word =~ m/^[\&\%\$\@\:\<\*\\\_]/s
           # if it looks like it starts with a sigil, etc.
       or $word =~ m/[\%\^\&\#\$\@\_\<\>\(\)\[\]\{\}\\\*\:\+\/\=\|\`\~]/
            # or contains anything strange
    ) {
      DEBUG and print "rejecting {$word}\n" unless $word eq '_';
      next;
    } else {
      if(exists $stopwords->{$word} or exists $stopwords->{lc $word}) {
        DEBUG and print " [Rejecting \"$word\" as a stopword]\n";
      } else {
        $out .= "$leading$word$trailing ";
      }
    }
  }

  if(length $out) {
    my $out_fh = $p->output_handle();
    print $out_fh wrap('','',$out), "\n\n";
  }

  return;
}

#--------------------------------------------------------------------------

1;
__END__

=head1 NAME

Pod::Spell -- a formatter for spellchecking Pod

=head1 SYNOPSIS

  % podspell Thing.pm | ispell
 or if you don't have a podspell:
  % perl -MPod::Spell -e "Pod::Spell->new->parse_from_file(shift)" Thing.pm |spell |fmt

 or:
  % perl -MPod::Spell -e "Pod::Spell->new->parse_from_filehandle"
  ...which takes POD on STDIN and sends formatted text to STDOUT

...or instead of piping to spell or ispell, use C<E<gt>temp.txt>, and open
F<temp.txt> in your word processor for spell-checking.


=head1 DESCRIPTION

Pod::Spell is a Pod formatter whose output is good for
spellchecking.  Pod::Spell rather like L<Pod::Text|Pod::Text>, except that
it doesn't put much effort into actual formatting, and it suppresses things
that look like Perl symbols or Perl jargon (so that your spellchecking
program won't complain about mystery words like "C<$thing>" 
or "C<Foo::Bar>" or "hashref").

This class provides no new public methods.  All methods of interest are
inherited from L<Pod::Parser|Pod::Parser> (which see).  The especially
interesting ones are C<parse_from_filehandle> (which without arguments
takes from STDIN and sends to STDOUT) and C<parse_from_file>.  But you
can probably just make do with the examples in the synopsis though.

This class works by filtering out words that look like Perl or any
form of computerese (like "C<$thing>" or "C<NE<gt>7>" or
"C<@{$foo}{'bar','baz'}>", anything in CE<lt>...E<gt> or FE<lt>...E<gt>
codes, anything in verbatim paragraphs (codeblocks), and anything
in the stopword list.  The default stopword list for a document starts
out from the stopword list defined by L<Pod::Wordlist|Pod::Wordlist>,
and can be supplemented (on a per-document basis) by having 
C<"=for stopwords"> / C<"=for :stopwords"> region(s) in a document.


=head1 ADDING STOPWORDS

You can add stopwords on a per-document basis with
C<"=for stopwords"> / C<"=for :stopwords"> regions, like so:

  =for stopwords  plok Pringe zorch   snik !qux
  foo bar baz quux quuux 

This adds every word in that paragraph after "stopwords" to the
stopword list, effective for the rest of the document.  In such a
list, words are whitespace-separated.  (The amount of whitespace
doesn't matter, as long as there's no blank lines in the middle
of the paragraph.)  Words beginning with "!" are
I<deleted> from the stopword list -- so "!qux" deletes "qux" from the
stopword list, if it was in there in the first place.  Note that if
a stopword is all-lowercase, then it means that it's okay in I<any>
case; but if the word has any capital letters, then it means that
it's okay I<only> with I<that> case.  So a wordlist entry of "perl"
would permit "perl", "Perl", and (less interestingly) "PERL", "pERL",
"PerL", et cetera.  However, a wordlist entry of "Perl" catches
only "Perl", not "perl".  So if you wanted to make sure you said
only "Perl", never "perl", you could add this to the top of your
document:

  =for stopwords !perl Perl

Then all instances of the word "Perl" would be weeded out of the
Pod::Spell-formatted version of your document, but any instances of
the word "perl" would be left in (unless they were in a CE<lt>...> or 
FE<lt>...> style).

You can have several "=for stopwords" regions in your document.  You
can even express them like so:

  =begin stopwords

  plok Pringe zorch

  snik !qux

  foo bar
  baz quux quuux 

  =end stopwords

If you want to use EE<lt>...> sequences in a "stopwords" region, you
have to use ":stopwords", as here:

  =for :stopwords
  virtE<ugrave>

...meaning that you're adding a stopword of "virtE<ugrave>".  If
you left the ":" out, that'd mean you were adding a stopword of
"virtEE<lt>ugrave>" (with a literal E, a literal <, etc), which
will have no effect, since  any occurrences of virtEE<lt>ugrave>
don't look like a normal human-language word anyway, and so would
be screened out before the stopword list is consulted anyway.


=head1 USING Pod::Spell

My personal advice:

=over

=item *

Write your documentation in Pod.  Pod is described in
L<perlpod|perlpod>.  And L<perlmodstyle|perlmodstyle> has some
advice on content.  This is the stage where you want to make sure
you say everything you should, have good and working examples,
and have coherent grammar.

=item *

Run it through podchecker.  This will report all sorts of problems with
your Pod; you may choose to ignore some of these problems.  Some, like
"*** WARNING: Unknown entity EE<lt>qacute>...", you should pay attention
to.

=item *

Once podchecker errors have been tended to, spellcheck the pod by
running it through podspell / Pod::Spell.  For any misspellings that are
reported in the Pod::Spell-formatted text, fix them in the
original.  Repeat until there's no complaints.

=item *

Run it through podchecker again just for good measure.

=back


=head1 SEE ALSO

L<Pod::Wordlist|Pod::Wordlist>

L<Pod::Parser|Pod::Parser>

L<podchecker|podchecker> also known as L<Pod::Checker|Pod::Checker>

L<perlpod|perlpod>, L<perlpodspec|perlpodspec>



=head1 HINT

If you feed output of Pod::Spell into your word processor and run a
spell-check, make sure you're I<not> also running a grammar-check -- because
Pod::Spell drops words that it thinks are Perl symbols, jargon, or
stopwords, this means you'll have ungrammatical sentences, what with
words being missing and all.  And you don't need a grammar checker
to tell you that.



=head1 COPYRIGHT AND DISCLAIMER

Copyright (c) 2001 Sean M. Burke. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

The programs and documentation in this dist are distributed in
the hope that they will be useful, but without any warranty; without
even the implied warranty of merchantability or fitness for a
particular purpose.

=head1 AUTHOR

Sean M. Burke C<sburke@cpan.org>

=cut