From: Barrie Slaymaker Date: Sat, 12 May 2001 01:28:10 +0000 (-0400) Subject: (Retracted by #10104.) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bbd563317b955984ae9bd3173b3677ae70266c65;p=p5sagit%2Fp5-mst-13.2.git (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 --- diff --git a/lib/Pod/Text.pm b/lib/Pod/Text.pm index a0dab2d..da21ef5 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