[lintian] 01/06: Revert "c/cruft: Rewrite "strip comments" regex"
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 780c20552063940298c449a005d991f227440b5c
Author: Niels Thykier <niels@thykier.net>
Date: Sun Sep 6 11:42:20 2015 +0200
Revert "c/cruft: Rewrite "strip comments" regex"
This reverts commit 0803b0c032ab01197c7b5a2c2ef01b15b6f50496.
---
checks/cruft.pm | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/checks/cruft.pm b/checks/cruft.pm
index 96afcf8..f2ed334 100644
--- a/checks/cruft.pm
+++ b/checks/cruft.pm
@@ -971,23 +971,14 @@ sub _linelength_test {
my $strip = substr($block,0,8192);
# strip indention
$strip =~ s/^\s+//g;
- # Based on the "strip comments" from the Perl FAQ
- # (rewritten a bit)
- $strip =~ s{
- # Part 1) Strip /* */ comments
- /\* [^*]*+\*++ (?:[^/*][^*]*+\*++)*+ /
- # Part 2) Strip // comments (C++-style)
- | // (?:[^\\]++|[^\n][\n]?)*? (?=\n)
- # Part 3) Retain any non-comment (capture)
- | (
- # Part 3a) Non-string content
- .[^/"'\\]*+
- # Part 3b) ""-strings
- | "(?:\\.|[^"\\]++)*+"
- # Part 3c) ''-blocks
- | '(?:\\.|[^'\\]++)*+'
- )
- }{defined $1 ? $1 : ""}xgse;
+ # from perl faq strip comments (split into 3 and rewritten a bit)
+ # - Part 1) Strip /* */ comments
+ $strip =~ s# /\* [^*]*+\*++ (?:[^/*][^*]*+\*++)*+ / ##xgs;
+ # - Part 2) Strip // comments (allowing "\\\n" line continuation)
+ $strip =~ s# // (?:[^\\]++|[^\n][\n]?)*? (?=\n)##xgs;
+ # - Part 3) "De-stringify" elements ("foo" => foo)
+ $strip
+ =~ s#("(\\.|[^"\\]++)*"|'(\\.|[^'\\]++)*'|.[^/"'\\]*+)#defined $1 ? $1 : ""#xgse;
# strip empty line
$strip =~ s/^\s*\n//mg;
# remove last \n
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: