pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Removed the experimental --klic...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/afc3a3ee9ad1
branches:  trunk
changeset: 548662:afc3a3ee9ad1
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Oct 20 10:56:18 2008 +0000

description:
Removed the experimental --klickibunti option and everything that was
only there to support this option. Maybe I will reinvent the advanced
autofix code someday, hopefully in a programming language that provides
more error checking than Perl.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  391 +-------------------------------------
 1 files changed, 8 insertions(+), 383 deletions(-)

diffs (truncated from 500 to 300 lines):

diff -r 12310844c91d -r afc3a3ee9ad1 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Mon Oct 20 10:19:18 2008 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Mon Oct 20 10:56:18 2008 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.777 2008/10/20 10:10:28 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.778 2008/10/20 10:56:18 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -168,7 +168,6 @@
                print_summary_and_exit
                set_explain set_gcc_output_format
                get_show_source_flag set_show_source_flag
-               get_klickibunti_flag set_klickibunti_flag
        );
        import PkgLint::Util qw(
                false true
@@ -188,7 +187,6 @@
 my $errors             = 0;
 my $warnings           = 0;
 my $gcc_output_format  = false;
-my $klickibunti_flag   = false;
 my $explain_flag       = false;
 my $show_source_flag   = false;
 
@@ -270,8 +268,6 @@
 
 sub set_explain()              { $explain_flag = true; }
 sub set_gcc_output_format()    { $gcc_output_format = true; }
-sub get_klickibunti_flag()     { return $klickibunti_flag; }
-sub set_klickibunti_flag()     { $klickibunti_flag = true; }
 sub get_show_source_flag()     { return $show_source_flag; }
 sub set_show_source_flag()     { $show_source_flag = true; }
 
@@ -373,43 +369,6 @@
 }
 
 #==========================================================================
-# A StringMatch is the result of applying a regular expression to a String.
-# It can return the range and the text of the captured groups.
-#==========================================================================
-package PkgLint::StringMatch;
-
-use enum qw(STRING STARTS ENDS);
-
-sub new($$) {
-       my ($class, $string, $starts, $ends) = @_;
-       my ($self) = ([$string, [@{$starts}], [@{$ends}]]);
-       bless($self, $class);
-       return $self;
-}
-
-sub string($)          { return shift(@_)->[STRING]; }
-
-sub text($$) {
-       my ($self, $n) = @_;
-
-       my $start = $self->[STARTS]->[$n];
-       my $end = $self->[ENDS]->[$n];
-       return $self->string->substring($start, $end - $start)->text;
-}
-
-sub range($$) {
-       my ($self, $n) = @_;
-
-       return ($self->[STARTS]->[$n], $self->[ENDS]->[$n]);
-}
-
-sub highlight($$) {
-       my ($self, $n) = @_;
-
-       $self->string->highlight(0, $self->[STARTS]->[$n], $self->[ENDS]->[$n]);
-}
-
-#==========================================================================
 # When files are read in by pkglint, they are interpreted in terms of
 # lines. For Makefiles, line continuations are handled properly, allowing
 # multiple physical lines to end in a single logical line. For other files
@@ -623,233 +582,6 @@
 
 #== End of PkgLint::Line ==================================================
 
-package PkgLint::String;
-#==========================================================================
-# In pkglint, a String is a part of a Line that contains exact references
-# to the locations of its substrings in the physical lines of the file from
-# which it has been read. This makes it possible for diagnostics to be
-# marked at character level instead of logical line level.
-#
-# Implementation notes:
-#
-# A String consists of three components:
-# * a reference to a logical line,
-# * a list of Parts, which, when concatenated, form the text of the String.
-#   A Part is either a literal string or an array of the form [$lineno,
-#   $startcol, $endcol], which is used as a reference into the physical
-#   lines array (without and local additions) of the logical line.
-# * a list of highlighting intervals, which are used in the
-#   show_highlighted() method to mark up certain parts of the string.
-#==========================================================================
-
-BEGIN {
-       import PkgLint::Util qw(
-               false true
-               min max
-       );
-}
-
-use enum qw(LINE PARTS MARKUPS);
-
-# The structure fields of a Part of a String
-use enum qw(:P_ LINENO STARTCOL ENDCOL);
-
-# The structure fields of a MarkupPoint of a String
-use enum qw(:MP_ LINENO COLNO TEXT);
-
-sub new($$@) {
-       my ($class, $line, @parts) = @_;
-       my ($self) = ([$line, \@parts]);
-       bless($self, $class);
-       $self->compress();
-       return $self;
-}
-
-sub line($)            { return shift(@_)->[LINE]; }
-sub parts($)           { return shift(@_)->[PARTS]; }
-
-sub text($) {
-       my ($self) = @_;
-       my ($text);
-
-       $text = "";
-       foreach my $part (@{$self->[PARTS]}) {
-               if (ref($part) eq "") {
-                       $text .= $part;
-               } else {
-                       $text .= $self->line->substring($part->[P_LINENO], $part->[P_STARTCOL], $part->[P_ENDCOL] - $part->[P_STARTCOL]);
-               }
-       }
-       return $text;
-}
-
-sub substring($$$) {
-       my ($self, $from, $len) = @_;
-       my (@nparts, $skip, $take, $physlines);
-
-       # XXX: This code is slow, but simple.
-
-       $physlines = $self->[LINE]->[PkgLint::Line::PHYSLINES];
-
-       $skip = $from;
-       $take = defined($len) ? $len : 0x7fff_ffff;
-       foreach my $part (@{$self->[PARTS]}) {
-               if (ref($part) eq "") {
-                       my $p = "";
-
-                       my $nskipped = min($skip, strlen($part));
-                       $skip -= $nskipped;
-                       $part = substr($part, $nskipped);
-
-                       my $ntaken = min($take, strlen($part));
-                       $take -= $ntaken;
-                       $p .= substr($part, 0, $ntaken);
-                       $part = substr($part, $ntaken);
-
-                       push(@nparts, $p);
-               } else {
-                       my $line = $part->[P_LINENO];
-                       my $col = $part->[P_STARTCOL];
-                       my $tocol = $part->[P_ENDCOL];
-                       my $linelen = length($physlines->[$line]->[1]);
-
-                       my $nskipped = max(0, min($skip, min($tocol - $col, $linelen - $col)));
-                       $skip -= $nskipped;
-                       $col += $nskipped;
-
-                       my $start = $col;
-
-                       my $ntaken = max(0, min($take, min($tocol - $col, $linelen - $col)));
-                       $take -= $ntaken;
-                       $col += $ntaken;
-
-                       my $end = $col;
-                       push(@nparts, [$line, $start, $end]);
-               }
-       }
-       return PkgLint::String->new($self->[LINE], @nparts);
-}
-
-sub match($$) {
-       my ($self, $re) = @_;
-       my ($m);
-
-       if ($self->text !~ $re) {
-               return false;
-       }
-
-       # @- and @+ are very special arrays, so we better copy them
-       # before doing anything with them.
-       my @starts = @-;
-       my @ends = @+;
-       return PkgLint::StringMatch->new($self, \@starts, \@ends);
-}
-
-sub match_all($$) {
-       my ($self, $re) = @_;
-       my ($mm, $rest, $lastpos);
-
-       $mm = [];
-       $rest = $self->text;
-       $lastpos = 0;
-       pos(undef);
-       while ($rest =~ m/$re/gc) {
-               my @starts = @-;
-               my @ends = @+;
-
-               $lastpos = $ends[0];
-
-               push(@{$mm}, PkgLint::StringMatch->new($self, \@starts, \@ends));
-       }
-       return ($mm, substr($rest, $lastpos));
-}
-
-sub compress($) {
-       my ($self) = @_;
-       my ($parts, @nparts);
-
-       $parts = $self->[PARTS];
-
-       # Copy all but empty parts into nparts.
-       foreach my $part (@{$parts}) {
-               if (ref($part) eq "") {
-                       if ($part ne "") {
-                               push(@nparts, $part);
-                       }
-               } else {
-                       if ($part->[P_STARTCOL] != $part->[P_ENDCOL]) {
-                               push(@nparts, $part);
-                       }
-               }
-       }
-       $self->[PARTS] = \@nparts;
-
-       # TODO: Merge adjacent parts
-}
-
-# FIXME: lineno should not be needed here.
-sub highlight($$$$) {
-       my ($self, $lineno, $startcol, $endcol) = @_;
-
-       push(@{$self->[MARKUPS]}, [$lineno, $startcol, $endcol]);
-}
-
-sub show_highlighted($$) {
-       my ($self) = @_;
-       my ($physlines, @points, $curpoint, $maxpoint, $text, $physline, $col);
-
-       return unless (PkgLint::Logging::get_show_source_flag() && PkgLint::Logging::get_klickibunti_flag());
-
-       foreach my $m (@{$self->[MARKUPS]}) {
-               push(@points, [$m->[P_LINENO], $m->[P_STARTCOL], "\x1B[33m\x1B[1m"]);
-               push(@points, [$m->[P_LINENO], $m->[P_ENDCOL], "\x1B[0m"]);
-       }
-
-       @points = sort {
-               $a->[MP_LINENO] <=> $b->[MP_LINENO]
-               || $a->[MP_COLNO] <=> $b->[MP_COLNO];
-       } (@points);
-
-       $physlines = $self->line->[PkgLint::Line::PHYSLINES];
-       $curpoint = 0;
-       $maxpoint = $#points + 1;
-       foreach my $lineno (0..$#{$physlines}) {
-               while ($curpoint < $maxpoint && $points[$curpoint]->[MP_LINENO] < $lineno) {
-                       $curpoint++;
-               }
-
-               $text = "";
-               $col = 0;
-               $physline = $physlines->[$lineno];
-               while ($curpoint < $maxpoint && $points[$curpoint]->[MP_LINENO] == $lineno) {
-                       $text .= substr($physline->[1], $col, $points[$curpoint]->[MP_COLNO] - $col);
-                       $text .= $points[$curpoint]->[MP_TEXT];
-                       $col = $points[$curpoint]->[MP_COLNO];
-                       $curpoint++;
-               }
-               $text .= substr($physline->[1], $col);
-               print("> $text");
-       }
-}
-
-# TODO: Rewrite the code of log_warning to be shorter. After that is
-# done, add the other log_* methods.
-
-sub log_warning($$) {
-       my ($self, $msg) = @_;
-
-       if (PkgLint::Logging::get_show_source_flag()) {
-               if (PkgLint::Logging::get_klickibunti_flag()) {



Home | Main Index | Thread Index | Old Index