🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #42933

Re: [slrn] Could extract_article_header() return # of lines?

#42933
From: Lloyd Zusman
Date: Sun, 30 Aug 1998 00:00
86 lines
3951 bytes
bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) writes:

> Lloyd Zusman <ljz@asfast.com> wrote:
> > Hmmm ... how would I do that?  Here's some sample code that
> > illustrates how I'm traversing all the articles in a given newsgroup.
> 
> You could make a wrapper for extract_article_header() that will work around
> the bugs or include similar code in your function, I'll demonstrate both
> ways.  [ ... ]
> 
> The workaround:

Thanks ... this shows the answer I was looking for: to call
"select_article" to grab each article.

And I think that your function could be speeded up by eliminating the
dual calls to `extract_article_header', as follows:

% Bugfix for slrn's extract_article_header()             % -*- slang -*-
%
% Fixes extract_article_header() for known problem areas:
%   Message-ID -- remove leading (and trailing, if any) whitespace.
%   Lines      -- return as an integer after selecting/deselecting article.

define bugfix_extract_article_header_2 (header) {

   if (is_group_mode ())
     error (_function_name () + "doesn\'t work in group mode");

   switch (header)
     { case ("Message-ID") :
         return (strtrim (extract_article_header (retval)));
     }
     { case ("Lines")      :
	variable article_was_visible = is_article_visible ();
	call ("select_article");
	!if (article_was_visible) call ("hide_article");
	return (integer (strtrim (extract_article_header (header))));
     }
     { return (extract_article_header (header)); }
}
 
> [ ... ]

> Or you can put this in your code:
> 
> [ ... etc. ... ]

This second example (deleted to save space) illustrates another way
to grab the appropriate article: to call "scroll_dn" when looking
for "Lines" (and using `is_article_visible()' and "hide_article"
as required).

> [ ... ]
>
> By the way, the "variable" calls inside the loop will fail in S-Lang 1.x if
> the do-while loop executes more than once--you'll be declaring a variable
> that already exists and that's an error in S-Lang.  You'll need to move
> those declarations before the loop.  What you've got works in S-Lang prior
> to 1.x, however.  I don't know what version of S-Lang you're using, so I
> thought I'd mention it.

Thanks.  In my example, I had taken some code that was resident in a
subroutine and explicitly stuck it in the outer loop ... that's where
the `variable' calls came from.  In "real life", this problem wouldn't
have occurred.  But I hadn't thought about how these `variable'
declarations work, so I'll check the rest of my S-Lang macros, which
might contain one or more of these `variable' calls within loops.

> Hope this helps!

It does.  Thanks again.

Also, I applied my patch to `slrn_extract_header' in art.c, and it
works great.  With this patch, there would be no need for the S-Lang
`extract_article_header()' workaround, and everything runs faster.

I'm doing more work within `slrn_extract_header' to handle trimming
problems with "Message-Id" and elsewhere.  I'll post the updated patch
when I'm finished.

-- 
 Lloyd Zusman
 ljz@asfast.com

Technical Details
Message-ID: <ltlno6nk3g.fsf@asfast.com>
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
References: <slrn6uha35.l0.ljz@sunspot.tiac.net> <slrn6uj1m0.ff1.bluemoon@ux6.cso.uiuc.edu> <lt1zpypadr.fsf@asfast.com> <slrn6ujg18.89l.bluemoon@ux6.cso.uiuc.edu>

Show Full Headers
Complete Article Headers
Message-ID: <ltlno6nk3g.fsf@asfast.com>
Subject: Re: [slrn] Could extract_article_header() return # of lines?
Date: Sun, 30 Aug 1998 00:00:00 +0000
From: Lloyd Zusman <ljz@asfast.com>
References: <slrn6uha35.l0.ljz@sunspot.tiac.net> <slrn6uj1m0.ff1.bluemoon@ux6.cso.uiuc.edu> <lt1zpypadr.fsf@asfast.com> <slrn6ujg18.89l.bluemoon@ux6.cso.uiuc.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: 386266273
X-Complaints-To: newsabuse@supernews.com
X-Trace: 904518691 NHG18.M.GE264CCFD usenet44.supernews.com
Organization: http://www.supernews.com, The World's Usenet: Discussions Start Here
Newsgroups: news.software.readers