summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarrie Slaymaker <barries@slaysys.com>2001-05-11 21:28:10 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2001-05-14 12:32:44 +0000
commitbbd563317b955984ae9bd3173b3677ae70266c65 (patch)
tree68f9fef3648ff71cc8c77023a0bc1b14455f71ef
parente8fac18776ead9df1e47e1b139606bde4e393d42 (diff)
downloadperl-bbd563317b955984ae9bd3173b3677ae70266c65.tar.gz
(Retracted by #10104.)
Subject: [PATCH bleadperl Pod::Text] avoid overquoting [Was: rand(0) is rand(1)] Message-ID: <20010512012810.B26358@jester.slaysys.com> p4raw-id: //depot/perl@10094
-rw-r--r--lib/Pod/Text.pm13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Pod/Text.pm b/lib/Pod/Text.pm
index a0dab2d6d2..da21ef5304 100644
--- a/lib/Pod/Text.pm
+++ b/lib/Pod/Text.pm
@@ -472,7 +472,18 @@ sub seq_b { return $_[0]{alt} ? "``$_[1]''" : $_[1] }
sub seq_f { return $_[0]{alt} ? "\"$_[1]\"" : $_[1] }
sub seq_i { return '*' . $_[1] . '*' }
sub seq_c {
- return $_[0]{alt} ? "``$_[1]''" : "$_[0]{LQUOTE}$_[1]$_[0]{RQUOTE}"
+ return $_[0]{alt}
+ ? "``$_[1]''"
+ : $_[0]{LQUOTE} eq '"' &&
+ $_[1] =~ /^\s*(?: # Some heuristics to avoid some overquoting
+ (['`"]).*\1 # already quoted
+ |\$+[\^#]?\S(\[.*\]|\{.*\})? # control or punct var?
+ |[\$#\@%&*]+[:'\w]+(\[.*\]|\{.*\})? # a "plain" var or func?
+ |[\$#\@%&*]*[:'\w]+(->)?\(\s*[^\s,]\s*\) # a call, 0 or 1 args?
+ |[:'\w]+ # a word
+ )\s*\z/x
+ ? $_[1]
+ : "$_[0]{LQUOTE}$_[1]$_[0]{RQUOTE}"
}
# The complicated one. Handle links. Since this is plain text, we can't