summaryrefslogtreecommitdiff
path: root/lib/Pod/ParseUtils.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Pod/ParseUtils.pm')
-rw-r--r--lib/Pod/ParseUtils.pm65
1 files changed, 33 insertions, 32 deletions
diff --git a/lib/Pod/ParseUtils.pm b/lib/Pod/ParseUtils.pm
index 13d66ab8d2..f3c7ef4677 100644
--- a/lib/Pod/ParseUtils.pm
+++ b/lib/Pod/ParseUtils.pm
@@ -8,9 +8,10 @@
#############################################################################
package Pod::ParseUtils;
+use strict;
use vars qw($VERSION);
-$VERSION = 1.35; ## Current version of this package
+$VERSION = '1.36'; ## Current version of this package
require 5.005; ## requires this Perl version or later
=head1 NAME
@@ -252,7 +253,7 @@ sub new {
}
else {
# called with L<> contents
- return undef unless($self->parse($_[0]));
+ return unless($self->parse($_[0]));
}
}
return $self;
@@ -293,14 +294,14 @@ sub parse {
# strip leading/trailing whitespace
if(s/^[\s\n]+//) {
- $self->warning("ignoring leading whitespace in link");
+ $self->warning('ignoring leading whitespace in link');
}
if(s/[\s\n]+$//) {
- $self->warning("ignoring trailing whitespace in link");
+ $self->warning('ignoring trailing whitespace in link');
}
unless(length($_)) {
- _invalid_link("empty link");
- return undef;
+ _invalid_link('empty link');
+ return;
}
## Check for different possibilities. This is tedious and error-prone
@@ -313,68 +314,68 @@ sub parse {
# to point to an internal funtion...
my $page_rx = '[\w.-]+(?:::[\w.-]+)*(?:[(](?:\d\w*|)[)]|)';
# page name only
- if(m!^($page_rx)$!o) {
+ if(/^($page_rx)$/o) {
$page = $1;
$type = 'page';
}
# alttext, page and "section"
- elsif(m!^(.*?)\s*[|]\s*($page_rx)\s*/\s*"(.+)"$!o) {
+ elsif(m{^(.*?)\s*[|]\s*($page_rx)\s*/\s*"(.+)"$}o) {
($alttext, $page, $node) = ($1, $2, $3);
$type = 'section';
$quoted = 1; #... therefore | and / are allowed
}
# alttext and page
- elsif(m!^(.*?)\s*[|]\s*($page_rx)$!o) {
+ elsif(/^(.*?)\s*[|]\s*($page_rx)$/o) {
($alttext, $page) = ($1, $2);
$type = 'page';
}
# alttext and "section"
- elsif(m!^(.*?)\s*[|]\s*(?:/\s*|)"(.+)"$!) {
+ elsif(m{^(.*?)\s*[|]\s*(?:/\s*|)"(.+)"$}) {
($alttext, $node) = ($1,$2);
$type = 'section';
$quoted = 1;
}
# page and "section"
- elsif(m!^($page_rx)\s*/\s*"(.+)"$!o) {
+ elsif(m{^($page_rx)\s*/\s*"(.+)"$}o) {
($page, $node) = ($1, $2);
$type = 'section';
$quoted = 1;
}
# page and item
- elsif(m!^($page_rx)\s*/\s*(.+)$!o) {
+ elsif(m{^($page_rx)\s*/\s*(.+)$}o) {
($page, $node) = ($1, $2);
$type = 'item';
}
# only "section"
- elsif(m!^/?"(.+)"$!) {
+ elsif(m{^/?"(.+)"$}) {
$node = $1;
$type = 'section';
$quoted = 1;
}
# only item
- elsif(m!^\s*/(.+)$!) {
+ elsif(m{^\s*/(.+)$}) {
$node = $1;
$type = 'item';
}
# non-standard: Hyperlink with alt-text - doesn't remove protocol prefix, maybe it should?
- elsif(m!^ \s* (.*?) \s* [|] \s* (\w+:[^:\s] [^\s|]*?) \s* $!ix) {
+ elsif(/^ \s* (.*?) \s* [|] \s* (\w+:[^:\s] [^\s|]*?) \s* $/ix) {
($alttext,$node) = ($1,$2);
$type = 'hyperlink';
}
# non-standard: Hyperlink
- elsif(m!^(\w+:[^:\s]\S*)$!i) {
+ elsif(/^(\w+:[^:\s]\S*)$/i) {
$node = $1;
$type = 'hyperlink';
}
# alttext, page and item
- elsif(m!^(.*?)\s*[|]\s*($page_rx)\s*/\s*(.+)$!o) {
+ elsif(m{^(.*?)\s*[|]\s*($page_rx)\s*/\s*(.+)$}o) {
($alttext, $page, $node) = ($1, $2, $3);
$type = 'item';
}
# alttext and item
- elsif(m!^(.*?)\s*[|]\s*/(.+)$!) {
+ elsif(m{^(.*?)\s*[|]\s*/(.+)$}) {
($alttext, $node) = ($1,$2);
}
# must be an item or a "malformed" section (without "")
@@ -388,7 +389,7 @@ sub parse {
# empty alternative text expands to node name
if(defined $alttext) {
if(!length($alttext)) {
- $alttext = $node | $page;
+ $alttext = $node || $page;
}
}
else {
@@ -398,10 +399,10 @@ sub parse {
if($page =~ /[(]\w*[)]$/) {
$self->warning("(section) in '$page' deprecated");
}
- if(!$quoted && $node =~ m:[|/]: && $type ne 'hyperlink') {
+ if(!$quoted && $node =~ m{[|/]} && $type ne 'hyperlink') {
$self->warning("node '$node' contains non-escaped | or /");
}
- if($alttext =~ m:[|/]:) {
+ if($alttext =~ m{[|/]}) {
$self->warning("alternative text '$node' contains non-escaped | or /");
}
$self->{-page} = $page;
@@ -479,7 +480,7 @@ that are marked up):
# The complete link's text
sub text {
- $_[0]->{_text};
+ return $_[0]->{_text};
}
=item $link-E<gt>warning()
@@ -530,7 +531,7 @@ sub page {
$_[0]->{-page} = $_[1];
$_[0]->_construct_text();
}
- $_[0]->{-page};
+ return $_[0]->{-page};
}
=item $link-E<gt>node()
@@ -545,7 +546,7 @@ sub node {
$_[0]->{-node} = $_[1];
$_[0]->_construct_text();
}
- $_[0]->{-node};
+ return $_[0]->{-node};
}
=item $link-E<gt>alttext()
@@ -560,7 +561,7 @@ sub alttext {
$_[0]->{-alttext} = $_[1];
$_[0]->_construct_text();
}
- $_[0]->{-alttext};
+ return $_[0]->{-alttext};
}
=item $link-E<gt>type()
@@ -589,8 +590,8 @@ sub link {
my $link = $self->page() || '';
if($self->node()) {
my $node = $self->node();
- $text =~ s/\|/E<verbar>/g;
- $text =~ s:/:E<sol>:g;
+ $node =~ s/\|/E<verbar>/g;
+ $node =~ s{/}{E<sol>}g;
if($self->type() eq 'section') {
$link .= ($link ? '/' : '') . '"' . $node . '"';
}
@@ -604,10 +605,10 @@ sub link {
if($self->alttext()) {
my $text = $self->alttext();
$text =~ s/\|/E<verbar>/g;
- $text =~ s:/:E<sol>:g;
+ $text =~ s{/}{E<sol>}g;
$link = "$text|$link";
}
- $link;
+ return $link;
}
sub _invalid_link {
@@ -616,7 +617,7 @@ sub _invalid_link {
#eval { die "$msg\n" };
#chomp $@;
$@ = $msg; # this seems to work, too!
- undef;
+ return;
}
#-----------------------------------------------------------------------------
@@ -686,7 +687,7 @@ sub find_page {
return $_;
}
}
- undef;
+ return;
}
package Pod::Cache::Item;
@@ -808,7 +809,7 @@ sub find_node {
return $_->[1]; # id
}
}
- undef;
+ return;
}
=item $cacheitem-E<gt>idx()