diff options
author | rillig <rillig@pkgsrc.org> | 2006-01-06 21:06:06 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2006-01-06 21:06:06 +0000 |
commit | 6bf7eb18c8cab5338385c806966b1be17d8c7d52 (patch) | |
tree | 78e358cffb1fa6ba0625e8ffa69d7a7da262d781 /pkgtools/pkglint | |
parent | f0e28d39b841b6960b04f84eea803c2ee2a0d431 (diff) | |
download | pkgsrc-6bf7eb18c8cab5338385c806966b1be17d8c7d52.tar.gz |
- Moved the code for checking macro names in patch lines into its own
subroutine, as it has no code that is specific to patch files.
Diffstat (limited to 'pkgtools/pkglint')
-rw-r--r-- | pkgtools/pkglint/files/pkglint.pl | 99 |
1 files changed, 52 insertions, 47 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl index 5456ae63d9c..df78ab72e90 100644 --- a/pkgtools/pkglint/files/pkglint.pl +++ b/pkgtools/pkglint/files/pkglint.pl @@ -1,5 +1,5 @@ #! @PERL@ -w -# $NetBSD: pkglint.pl,v 1.452 2006/01/06 18:02:05 rillig Exp $ +# $NetBSD: pkglint.pl,v 1.453 2006/01/06 21:06:06 rillig Exp $ # # pkglint - static analyzer and checker for pkgsrc packages @@ -1612,6 +1612,56 @@ sub checkline_spellcheck($) { } } +sub checkline_cpp_macro_names($$) { + my ($line, $text) = @_; + my ($rest); + + use constant good_macros => PkgLint::Util::array_to_hash(qw( + __STDC__ + + __GNUC__ __GNUC_MINOR__ + __SUNPRO_C + + __i386 + __mips + __sparc + + __APPLE__ + __bsdi__ + __CYGWIN__ + __DragonFly__ + __FreeBSD__ __FreeBSD_version + __INTERIX + __linux__ + __MINGW32__ + __NetBSD__ __NetBSD_Version__ + __OpenBSD__ + __SVR4 + __sun + + __GLIBC__ + )); + use constant bad_macros => { + "__sparc__" => "__sparc", + "__sun__" => "__sun", + "__svr4__" => "__SVR4", + }; + + $rest = $text; + while ($rest =~ s/defined\((__[\w_]+)\)//) { + my ($macro) = ($1); + + if (exists(good_macros->{$macro})) { + $line->log_debug("Found good macro \"${macro}\"."); + } elsif (exists(bad_macros->{$macro})) { + $line->log_warning("The macro \"${macro}\" is unportable. Please use \"".bad_macros->{$macro}."\" instead."); + $line->explain("See the pkgsrc guide, section \"CPP defines\" for details."); + } else { + $line->log_info("Found unknown macro \"${macro}\"."); + } + } +} + sub checkline_mk_text($$) { my ($line, $text) = @_; my ($rest, $state, $vartools); @@ -3078,52 +3128,7 @@ sub checkfile_patch($) { } if ($text =~ qr"^\+") { - use constant good_macros => PkgLint::Util::array_to_hash(qw( - __STDC__ - - __GNUC__ __GNUC_MINOR__ - __SUNPRO_C - - __i386 - __mips - __sparc - - __APPLE__ - __bsdi__ - __CYGWIN__ - __DragonFly__ - __FreeBSD__ __FreeBSD_version - __INTERIX - __linux__ - __MINGW32__ - __NetBSD__ __NetBSD_Version__ - __OpenBSD__ - __SVR4 - __sun - - __GLIBC__ - )); - use constant bad_macros => { - "__sparc__" => "__sparc", - "__sun__" => "__sun", - "__svr4__" => "__SVR4", - }; - my $rest = $line->text; - my $re_ifdef = qr"defined\((__[\w_]+)\)"; - - while ($rest =~ s/$re_ifdef//) { - my ($macro) = ($1); - - if (exists(good_macros->{$macro})) { - $line->log_debug("Found good macro \"${macro}\"."); - } elsif (exists(bad_macros->{$macro})) { - $line->log_warning("The macro \"${macro}\" is unportable. Please use \"".bad_macros->{$macro}."\" instead."); - $line->explain("See the pkgsrc guide, section \"CPP defines\" for details."); - } else { - $line->log_info("Found unknown macro \"${macro}\"."); - } - } - + checkline_cpp_macro_names($line, substr($text, 1)); checkline_spellcheck($line); } } |