🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #83810

Re: docheckgroups et al

#83810
From: Julien ÉLIE
Date: Thu, 06 Jan 2011 22:39
88 lines
3863 bytes
Hi Russ,

> The mawk Debian package description includes:
> 
>   Mawk is smaller and much faster than gawk. It has some compile-time
>   limits such as NF = 32767 and sprintf buffer = 1020.
> 
> I suspect one of those limits or some other compile-time limit has
> something to do with it.

Oh, yes, it must be that.  Thanks for having found that limitation.



> I unfortunately don't know enough awk to tell you whether that change
> would work.  At the point where I have to start writing awk like that, I
> usually switch to Perl.  :)

:-)


I have just made a new version (still not committed) which seems to
work fine.

Example of changes:


BEFORE:

cat | ${AWK} '{ if ($1 !~ /'"${2:-^#}"'/ && $1) { print $0 } }' >${T}/$$msg


NOW:

cat | ${PERL} -e 'while (<STDIN>) { my @fields = split();
    print $_ if ((scalar(@fields) > 0) && ($fields[0] !~ /'${2:-^#}'/)
    && ($fields[0] !~ /^#/)); }' > ${T}/$$msg





BEFORE:

${AWK} '{ if (($1 ~ /'"${1:-.}"'/) && ($1 ~ /'"${PATS}"'/) && ($0 ~ / m$/)) { print $1 } }' ${ACTIVE} | ${SORT} >${T}/$$amod.all


NOW:

cat ${ACTIVE} | ${PERL} -e 'while (<STDIN>) { my @fields = split();
    print $fields[0]."\n" if ((scalar(@fields) > 0) && ($fields[0] =~ /'${1:-.}'/)
    && ($fields[0] =~ /'${PATS}'/) && ($_ =~ / m$/)); }' | ${SORT} > ${T}/$$amod.all





BEFORE:

${AWK} -F'\t' '{if (length($1) < 8) {print $1"\t\t\t"$2} \
    else {if (length($1) < 16) {print $1"\t\t"$2} \
    else {print $1"\t"$2}}}' >${NEWSGROUPS}


NOW:

${PERL} -e 'while (<STDIN>) { my @fields = split("\t", $_, 2);
    next if (scalar(@fields) == 0);
    my $length = length("$fields[0]");
    my $desc;
    if (scalar(@fields) == 2) { $desc = "$fields[1]"; } else { $desc = ""; }
    if ($length < 8) { print $fields[0]."\t\t\t".$desc; }
    elsif ($length < 16) { print $fields[0]."\t\t".$desc; }
    else { print $fields[0]."\t".$desc; } }' > ${NEWSGROUPS}




In case you see something suspicious, do not hesitate to tell.

(Maybe I could have used "perl -ne" to avoid the while() loop, or even
"perl -ane" to avoid the split(), but it looked clearer this way to
debug and better see what is going on in the script.)

-- 
Julien ÉLIE

« Medicina animi. »
Technical Details
Message-ID: <8omulnFbgoU1@mid.individual.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <ie88v7$hg8$1@n102.xanadu-bbs.net> <ifb38e$2m6$1@puck.litech.org> <ifcmdj$h2p$1@n102.xanadu-bbs.net> <87ipydiwys.fsf@windlord.stanford.edu> <ifri8f$4jg$1@puck.litech.org> <ifs1r4$rjh$1@n102.xanadu-bbs.net> <8oejprF38fU1@mid.individual.net> <ifth0a$92v$1@n102.xanadu-bbs.net> <8of2b7FqphU1@mid.individual.net> <ifvkrk$tqg$1@n102.xanadu-bbs.net> <87r5csmuwk.fsf@windlord.stanford.edu> <ig05m5$2ij$1@n102.xanadu-bbs.net> <8ok9csFl0pU1@mid.individual.net> <878vyzvssp.fsf@windlord.stanford.edu>

Show Full Headers
Complete Article Headers
Message-ID: <8omulnFbgoU1@mid.individual.net>
Subject: Re: docheckgroups et al
Date: Thu, 06 Jan 2011 23:39:50 +0100
From: Julien ÉLIE <iulius@nom-de-mon-site.com.invalid>
References: <ie88v7$hg8$1@n102.xanadu-bbs.net> <ifb38e$2m6$1@puck.litech.org> <ifcmdj$h2p$1@n102.xanadu-bbs.net> <87ipydiwys.fsf@windlord.stanford.edu> <ifri8f$4jg$1@puck.litech.org> <ifs1r4$rjh$1@n102.xanadu-bbs.net> <8oejprF38fU1@mid.individual.net> <ifth0a$92v$1@n102.xanadu-bbs.net> <8of2b7FqphU1@mid.individual.net> <ifvkrk$tqg$1@n102.xanadu-bbs.net> <87r5csmuwk.fsf@windlord.stanford.edu> <ig05m5$2ij$1@n102.xanadu-bbs.net> <8ok9csFl0pU1@mid.individual.net> <878vyzvssp.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
Newsgroups: news.software.nntp
Organization: TrigoFACILE -- http://www.trigofacile.com/
Lines: 88
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net zgB7h/Fa/HBE4oiqMPJdmgqEtSbDQbtHqPM93o+zM1Dhr0OEw=
Cancel-Lock: sha1:JLIn+jkx1UUs8BPH+5b0BR0+mbA=
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; fr;
In-Reply-To: <878vyzvssp.fsf@windlord.stanford.edu>
X-Original-Bytes: 3653