summaryrefslogtreecommitdiffstats
path: root/perl_checker
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-11-06 15:59:11 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-11-06 15:59:11 +0000
commit5cec90b983f3a4c2d20525637689f787045d26c1 (patch)
tree42441303f4bcf0f96be68d4bb7c58c5ddfe9c35d /perl_checker
parent38179ca84eeed2ad75093f0292f9321d5d93a899 (diff)
downloadperl-MDK-Common-5cec90b983f3a4c2d20525637689f787045d26c1.tar
perl-MDK-Common-5cec90b983f3a4c2d20525637689f787045d26c1.tar.gz
perl-MDK-Common-5cec90b983f3a4c2d20525637689f787045d26c1.tar.bz2
perl-MDK-Common-5cec90b983f3a4c2d20525637689f787045d26c1.tar.xz
perl-MDK-Common-5cec90b983f3a4c2d20525637689f787045d26c1.zip
- warn about one-character long functions (esp. for &N and &_)
- warn when N("...") is misused
Diffstat (limited to 'perl_checker')
-rwxr-xr-xperl_checker20
1 files changed, 15 insertions, 5 deletions
diff --git a/perl_checker b/perl_checker
index 2e18fb3..0c309c2 100755
--- a/perl_checker
+++ b/perl_checker
@@ -80,10 +80,13 @@ while (@ARGV) {
get_exports();
- while (/(^|[^\$@\w:>]) # first a char
+ while (/(^|[^\$@\w:>\\]) # first a char
((\w|:)*\w) # function name
(?=\() # a open parenthesis (zero-width lookahead)
- /gx) { add_call($2) unless /$2\(s\)/ } # special case xxxx(s) excluded cuz' of strings containing it
+ /gx) {
+ my $f = $2;
+ add_call($f) if !/$f\(s\)/; # special case xxxx(s) excluded cuz' of strings containing it
+ }
while (/&([\w:]+)/g) { add_call($1); }
@@ -107,8 +110,8 @@ sub drop_strings_and_regexps {
s/"[^"]*"/"foo"/g; #"
s/'[^']*'/'foo'/g; #'
s/\bqq\([^)]*\)/'foo'/g;
- s/\bm\b(.)(.*?)\1/m!foo!/g; # m// operator: "m/re/", "m|re|", ...
- s/\bs\b(.)(.*?)\1(.*?)\1/s!foo!bar!/g; # s/// operator: "s/re/.../", "s|re|...|", ...
+ s/\bm\b([\/|!,])(.*?)\1/m!foo!/g; # m// operator: "m/re/", "m|re|", ...
+ s/\bs\b([\/|!,])(.*?)\1(.*?)\1/s!foo!bar!/g; # s/// operator: "s/re/.../", "s|re|...|", ...
s|\(/.*?/|(/foo/|g; # m// operator: "(/re/"
s{([!=]~|\bif\b)\s*/.*?/}{$1 /foo/}g; # m// operator: "if /re/", "=~ /re/", "!~ /re/"
@@ -206,6 +209,13 @@ sub syntax_warnings {
if (/=.*:\s*\$\w+\s*=/) {
err(q(do not use ``cond ? $v1 = XX1 : $v2 = XX2'' which is parsed as ``(cond ? $v1 = XX1 : $v2) = XX2''), info());
}
+
+ if (my ($f, $s) = /(N_?)\((.*)/) {
+ $s =~ s/\\"//g;
+ $s =~ s/"([^"]*)($|".*)/$1/ or err(qq($f must be used as $f("xxx") for xgettext to work correctly (hint: use translate instead)), info());
+ $s =~ s/\\[\$@]//g;
+ $s !~ /[\$@]/ or err(qq(don't use interpolated translated string, use %s or %d instead), info());
+ }
}
sub syntax_warnings_after_removing_strings_and_regexps {
@@ -354,7 +364,7 @@ sub end {
exists $export_tags{$k}->{$_}->{$func} and next here; # ok, exported by $k in tag $_
}
}
- err("$func_verbatim undefined", $call_info{$package}->{$func_verbatim}) if length $func_verbatim > 1;
+ err("$func_verbatim undefined", $call_info{$package}->{$func_verbatim}) if $func_verbatim ne 'q';
}
}
$ERR and exit $ERR;