Debian Codegraph @

devel/grep-pod-X-newline.pl

raw symbols SCIP
1 #!/usr/bin/perl -w
2
3 # Copyright 2012 Kevin Ryde
4
5 # This file is part of Perl-Critic-Pulp.
6 #
7 # Perl-Critic-Pulp is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as published
9 # by the Free Software Foundation; either version 3, or (at your option) any
10 # later version.
11 #
12 # Perl-Critic-Pulp is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15 # Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.
19
20 # /usr/share/perl/5.14.2/pod/perlfaq9.pod
21 # "How do I find out my hostname, domainname"
22
23 use 5.006scip-perl cpan Perl-Critic-Pulp 100 `5.006`/;
24 use strictscip-perl cpan Perl-Critic-Pulp 100 strict/;
25 use warningsscip-perl cpan Perl-Critic-Pulp 100 warnings/;
26 use FindBinscip-perl cpan Perl-Critic-Pulp 100 FindBin/;
27 use Perl6::Slurpscip-perl cpan Perl-Critic-Pulp 100 Perl6/Slurp/;
28
29 use lib::absscip-perl cpan Perl-Critic-Pulp 100 lib/abs/ '.';
30 use MyLocatePerlscip-perl cpan Perl-Critic-Pulp 100 MyLocatePerl/;
31 use MyStuffscip-perl cpan Perl-Critic-Pulp 100 MyStuff/;
32
33 # uncomment this to run the ### lines
34 # use Smart::Comments;
35
36 my $verbose = 0;
37
38 sub zap_to_first_podscip-perl cpan Perl-Critic-Pulp 100 main/zap_to_first_pod(). {
39 my ($str) = @_scip-perl cpan Perl-Critic-Pulp 100 main/`@_`.;
40
41 if ($str =~ /^=/) {
42 return $str;
43 }
44
45 my $pos = indexscip-perl cpan Perl-Critic-Pulp 100 main/index(). ($str, "\n\n=");
46 if ($pos < 0) {
47 return $str;
48 }
49 my $pre = substrscip-perl cpan Perl-Critic-Pulp 100 main/substr().($str,0,$pos);
50 my $post = substrscip-perl cpan Perl-Critic-Pulp 100 main/substr().($str,$pos);
51 $pre =~ tr/\n//cd;
52
53 ### $pre
54 return $pre.$post;
55 }
56 ### zap: zap_to_first_pod("blah\nblah\n\n\n=pod")
57
58 sub zap_pod_verbatimscip-perl cpan Perl-Critic-Pulp 100 main/zap_pod_verbatim(). {
59 my ($str) = @_scip-perl cpan Perl-Critic-Pulp 100 main/`@_`.;
60 $str =~ s/^ .*//mg;
61 return $str;
62 }
63
64 my $X_re = qr/X<+([^>]|E<[^>]*>)*?>/; # $1=contained text
65
66 sub grep_X_newlinescip-perl cpan Perl-Critic-Pulp 100 main/grep_X_newline(). {
67 my ($filename, $str) = @_scip-perl cpan Perl-Critic-Pulp 100 main/`@_`.;
68 $str = zap_to_first_podscip-perl cpan Perl-Critic-Pulp 100 main/zap_to_first_pod().($str);
69 $str = zap_pod_verbatimscip-perl cpan Perl-Critic-Pulp 100 main/zap_pod_verbatim().($str);
70 ### $str
71
72 while ($str =~ /($X_re)/osg) {
73 my $pos = posscip-perl cpan Perl-Critic-Pulp 100 main/pos().($str);
74 my $X = $1scip-perl cpan Perl-Critic-Pulp 100 main/$1.;
75 if ($X =~ /\n/) {
76 my ($linenum, $colnum) = MyStuff::pos_to_line_and_columnscip-perl cpan Perl-Critic-Pulp 100 MyStuff/pos_to_line_and_column().
77 ($str, $pos-lengthscip-perl cpan Perl-Critic-Pulp 100 main/length().($X));
78 printscip-perl cpan Perl-Critic-Pulp 100 main/print(). "$filename:$linenum:$colnum: $X\n",
79 MyStuff::line_at_posscip-perl cpan Perl-Critic-Pulp 100 MyStuff/line_at_pos().($str, $pos);
80 }
81 }
82 }
83
84 if (1) {
85 requirescip-perl cpan Perl-Critic-Pulp 100 main/require(). File::Slurp;
86 my $filename = "$FindBin::Bin/$FindBin::Script";
87 $filename = "$ENV{HOME}/p/path/lib/Math/PlanePath/SquareSpiral.pm";
88 $filename = "/usr/share/perl/5.14.2/pod/perltoc.pod";
89 my $str = Perl6::Slurp::slurpscip-perl cpan Perl-Critic-Pulp 100 Perl6/Slurp/slurp().($filename);
90 grep_X_newlinescip-perl cpan Perl-Critic-Pulp 100 main/grep_X_newline(). ($filename, $str);
91 exitscip-perl cpan Perl-Critic-Pulp 100 main/exit(). 0;
92 }
93
94 my $l = MyLocatePerl->newscip-perl cpan Perl-Critic-Pulp 100 MyLocatePerl/new(). (include_pod => 1,
95 exclude_t => 1);
96 while (my ($filename, $str) = $l->nextscip-perl cpan Perl-Critic-Pulp 100 MyLocatePerl/next().) {
97 # next if $filename =~ m{/perltoc\.pod$};
98 if ($verbose) { printscip-perl cpan Perl-Critic-Pulp 100 main/print(). "look at $filename\n"; }
99 grep_X_newlinescip-perl cpan Perl-Critic-Pulp 100 main/grep_X_newline(). ($filename, $str);
100 }
101
102 exitscip-perl cpan Perl-Critic-Pulp 100 main/exit(). 0;
103
104 # X<Y
105
106 =head1 SEE ALSO
107
108 X<Foo,
109 Bar>,
110 X<Foo>