From bbd563317b955984ae9bd3173b3677ae70266c65 Mon Sep 17 00:00:00 2001 From: Barrie Slaymaker Date: Fri, 11 May 2001 21:28:10 -0400 Subject: [PATCH] (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 --- lib/Pod/Text.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- 2.7.4