vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r17666: LJSUP-7318: get rid of $& in code

Committer: vsukhanov
LJSUP-7318: get rid of $& in code
U   trunk/cgi-bin/Apache/LiveJournal.pm
U   trunk/cgi-bin/LJ/SynSuck.pm
U   trunk/cgi-bin/accountcodes.pl
U   trunk/cgi-bin/cleanhtml.pl
U   trunk/cgi-bin/ljfeed.pl
U   trunk/cgi-bin/weblib.pl
Modified: trunk/cgi-bin/Apache/LiveJournal.pm
===================================================================
--- trunk/cgi-bin/Apache/LiveJournal.pm	2010-11-11 03:46:06 UTC (rev 17665)
+++ trunk/cgi-bin/Apache/LiveJournal.pm	2010-11-11 05:43:48 UTC (rev 17666)
@@ -277,7 +277,8 @@
     my $args = LJ::Request->args;
     my $args_wq = $args ? "?$args" : "";
     my $host = LJ::Request->header_in("Host");
-    my $hostport = ($host =~ s/:\d+$//) ? $& : "";
+    $host =~ s/(:\d+)$//;
+    my ($hostport) = $1 || "";
     $host =~ s/\.$//; ## 'www.livejournal.com.' is a valid DNS hostname
 
     $host = $LJ::DOMAIN_WEB unless LJ::Request::request->{r}->is_initial_req;

Modified: trunk/cgi-bin/LJ/SynSuck.pm
===================================================================
--- trunk/cgi-bin/LJ/SynSuck.pm	2010-11-11 03:46:06 UTC (rev 17665)
+++ trunk/cgi-bin/LJ/SynSuck.pm	2010-11-11 05:43:48 UTC (rev 17666)
@@ -132,7 +132,7 @@
     # XML::Parser doesn't include Windows-1252, but we put it in cgi-bin/XML/* for it
     # to find.
     my $encoding;
-    if ($content =~ /<\?xml.+?>/ && $& =~ /encoding=([\"\'])(.+?)\1/) {
+    if ($content =~ /(<\?xml.+?>)/ && $1 =~ /encoding=([\"\'])(.+?)\1/) {
         $encoding = lc($2);
     }
     if (! $encoding && ! LJ::is_utf8($content)) {

Modified: trunk/cgi-bin/accountcodes.pl
===================================================================
--- trunk/cgi-bin/accountcodes.pl	2010-11-11 03:46:06 UTC (rev 17665)
+++ trunk/cgi-bin/accountcodes.pl	2010-11-11 05:43:48 UTC (rev 17666)
@@ -42,8 +42,8 @@
     my $num = 0;
     my $place = 0;
     while ($acid) {
-        return 0 unless ($acid =~ s/[$digits]$//o);
-        $num += $val{$&} * (30 ** $place++);
+        return 0 unless ($acid =~ s/([$digits])$//o);
+        $num += $val{$1} * (30 ** $place++);
     }
     return $num;
 }

Modified: trunk/cgi-bin/cleanhtml.pl
===================================================================
--- trunk/cgi-bin/cleanhtml.pl	2010-11-11 03:46:06 UTC (rev 17665)
+++ trunk/cgi-bin/cleanhtml.pl	2010-11-11 05:43:48 UTC (rev 17666)
@@ -1114,7 +1114,7 @@
                 };
                 ## URL is http://anything-here-but-space-and-quotes/and-last-symbol-isn't-space-comma-period-etc
                 ## like this (http://example.com) and these: http://foo.bar, http://bar.baz.
-                $token->[1] =~ s!https?://[^\s\'\"\<\>]+[^\s\'\"\<\>\.\,\?\:\)]! $match->($&); !ge;
+                $token->[1] =~ s!(https?://[^\s\'\"\<\>]+[^\s\'\"\<\>\.\,\?\:\)])! $match->($1); !ge;
             }
 
             # escape tags in text tokens.  shouldn't belong here!
@@ -1125,7 +1125,7 @@
 
             # put <wbr> tags into long words, except inside <pre> and <textarea>.
             if ($wordlength && !$opencount{'pre'} && !$opencount{'textarea'}) {
-                $token->[1] =~ s/\S{$wordlength,}/break_word($&,$wordlength)/eg;
+                $token->[1] =~ s/(\S{$wordlength,})/break_word($1,$wordlength)/eg;
             }
 
             # auto-format things, unless we're in a textarea, when it doesn't make sense
@@ -1463,7 +1463,7 @@
 
     # fast path:  no markup or URLs to linkify, and no suspend message needed
     if ($$ref !~ /\<|\>|http/ && ! $opts->{preformatted} && !$opts->{suspend_msg}) {
-        $$ref =~ s/\S{$wordlength,}/break_word($&,$wordlength)/eg if $wordlength;
+        $$ref =~ s/(\S{$wordlength,})/break_word($1,$wordlength)/eg if $wordlength;
         $$ref =~ s/\r?\n/<br \/>/g;
         return;
     }
@@ -1507,7 +1507,7 @@
 
     # fast path:  no markup or URLs to linkify
     if ($$ref !~ /\<|\>|http/ && ! $opts->{preformatted}) {
-        $$ref =~ s/\S{40,}/break_word($&,40)/eg;
+        $$ref =~ s/(\S{40,})/break_word($1,40)/eg;
         $$ref =~ s/\r?\n/<br \/>/g;
         return 0;
     }

Modified: trunk/cgi-bin/ljfeed.pl
===================================================================
--- trunk/cgi-bin/ljfeed.pl	2010-11-11 03:46:06 UTC (rev 17665)
+++ trunk/cgi-bin/ljfeed.pl	2010-11-11 05:43:48 UTC (rev 17666)
@@ -240,10 +240,10 @@
 
                 # assume the first paragraph is terminated by two <br> or a </p>
                 # valid XML tags should be handled, even though it makes an uglier regex
-                if ($event =~ m!((<br\s*/?\>(</br\s*>)?\s*){2})|(</p\s*>)!i) {
+                if ($event =~ m!(.*)(((<br\s*/?\>(</br\s*>)?\s*){2})|(</p\s*>))!i) {
                     # everything before the matched tag + the tag itself
                     # + a link to read more
-                    $event = $` . $& . $readmore;
+                    $event = $1 . $2 . $readmore;
                 }
             }
 

Modified: trunk/cgi-bin/weblib.pl
===================================================================
--- trunk/cgi-bin/weblib.pl	2010-11-11 03:46:06 UTC (rev 17665)
+++ trunk/cgi-bin/weblib.pl	2010-11-11 05:43:48 UTC (rev 17666)
@@ -118,7 +118,7 @@
             return "<a href='$str'>$str</a>";
         }
     };
-    $str =~ s!https?://[^\s\'\"\<\>]+[a-zA-Z0-9_/&=\-]! $match->($&); !ge;
+    $str =~ s!(https?://[^\s\'\"\<\>]+[a-zA-Z0-9_/&=\-])! $match->($1); !ge;
     return $str;
 }
 

Tags: livejournal, pl, pm, vadvs
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments