Article View: news.software.readers
Article #29023Re: Netscape 4 hitting the streets
From: Tom Christiansen
Date: Wed, 08 Jan 1997 00:00
Date: Wed, 08 Jan 1997 00:00
128 lines
4623 bytes
4623 bytes
[courtesy cc of this posting sent to cited author via email]
In news.software.readers,
Greg Berigan <gberigan@cse.unl.edu> writes:
:>I don't suppose you see the irony in telling me this in a message that
:>tagged the included text from the previous article using "|" at the front
:>rather than ">"? And for which the previous poster did the same thing?
:
:That's not necessarily the case. Some people replace all instances of
:^>* with ^|* to defeat their line counters.
We have the technology to catch this crap. For example:
#!/usr/local/bin/perl -w
#
# cfoq: check fascistly overquoted by tchrist@mox.perl.com
# (wants perl 5.0 or better; developed under 5.002)
#
# INPUT: a news article
# OUTPUT: if -v, then shows how much it found and where
#
# OPTIONS: -v for verbose flag
# -t NN to change tolerance percentage from 50%
# -m for minimum lines that get subject to percentage counting;
# otherwise, it just checks for ANY new lines. This way
# short little 6-line messages with 4 lines of quoting don't
# get hassled
#
# EXIT: 2 (bad failure) if no new lines
# 1 (failure) if tolerance exceeded
# 0 (success) otherwise
# 5.0 might work, but I developed it under 5.002
require 5.002;
use strict;
use vars qw{
$MINLINES $opt_m
$VERBOSE $opt_v
$TOLERANCE $opt_t
};
use Getopt::Std;
getopts("vt:m:") || die "usage: $0 [-v] [-t tolerance] [-m minlines] [input_file]\n";
my (
$total, # total number of lines, minus sig and attribution
$quoted_lines, # how many lines were quoted
$percent, # what percentage this in
$pcount, # how many in this paragraph were counted
$match_part, # holding space for current match
$gotsig, # is this the sig paragraph?
);
$total = $quoted_lines = $pcount = $percent = 0;
$MINLINES = $opt_m || 20;
$VERBOSE = $opt_v;
$TOLERANCE = $opt_t || 50;
$/ = ''; # set record reading to paragraph mode
<ARGV>; # consume and discard header of message
while (<ARGV>) {
# strip sig line, remember we found it
$gotsig = s/^-- \n.*//ms;
# strip attribution, possibly multiline
if ($. == 2) { s/\A.*?(<.*?>|\@).*?:\n//s }
# toss trailing blank lines into one single line
s/\n+\Z/\n/;
# now reduce miswrapped lines from idiotic broken PC newsreaders
# into what they should have been
s/(>.*)\n\s*([a-zA-Z])/$1 $2/g;
# count lines in this paragraph
$total++ while /^./mg;
# is it a single line, quoted in the customary fashion?
if ( /^(>+).*\n\Z/ ) {
$quoted_lines++;
print " 1 line quoted with $1\n" if $VERBOSE;
next;
}
# otherwise, it's a multiline block, which may be quoted
# with any leading repeated string that's neither alphanumeric
# nor string
while (/^(([^\w\s]+).*\n)(\2.*\n)+/mg) { # YANETUT
$quoted_lines += $pcount = ($match_part = $&) =~ tr/\n//;
printf "%2d lines quoted with $2\n", $pcount if $VERBOSE;
}
last if $gotsig;
}
$percent = int($quoted_lines / $total * 100);
print "$quoted_lines lines quoted out of $total: $percent%\n"
if $VERBOSE;
if ($total == $quoted_lines) {
print "All $total lines were quoted lines!\n" if $VERBOSE;
exit(2);
}
if ($percent > $TOLERANCE) {
if ($total < $MINLINES) {
print "but since $total is less than $MINLINES lines, that's ok\n"
if $VERBOSE;
exit 0;
} else {
exit 1;
}
} else {
exit 0;
}
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
"We all agree on the necessity of compromise. We just can't agree on
when it's necessary to compromise."
--Larry Wall in <1991Nov13.194420.28091@netlabs.com>
Technical Details
Message-ID:
<5b0g14$ft5$1@csnews.cs.colorado.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<59rvoh$i5d@epimetheus.algonet.se> <link-ya02408000R0601970221130001@news.uit.no> <5assf3$i56@fugue.clari.net> <5aua51$1s4@crcnis3.unl.edu>Show Full Headers
Complete Article Headers
Message-ID: <5b0g14$ft5$1@csnews.cs.colorado.edu> Subject: Re: Netscape 4 hitting the streets Date: Wed, 08 Jan 1997 00:00:00 +0000 From: Tom Christiansen <tchrist@mox.perl.com> References: <59rvoh$i5d@epimetheus.algonet.se> <link-ya02408000R0601970221130001@news.uit.no> <5assf3$i56@fugue.clari.net> <5aua51$1s4@crcnis3.unl.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 208450607 Content-type: text/plain; charset=ISO-8859-1 Organization: Perl Consulting and Training Reply-to: tchrist@mox.perl.com (Tom Christiansen) Newsgroups: news.software.readers Originator: tchrist@mox.perl.com