[I set the followup-to header to news.software.readers since not all
servers carry alt.lang.s-lang]
On Tue, 5 Feb 2013 17:23:03 +0100, Ignatios Souvatzis <
u50...@beverly.kleinbus.org>
wrote:
> This is supposed to cycle through the Newsgroups the current article
> was posted to that are available on the server.
[...]
>
> Any idea how I'd find out what's wrong?
The simplest way is to run slrn using the --debug option. Errors will
be written to the log file.
Your bug is caused by the way you are calling the "uncollapse_thread".
You are treating it as if it returns a value but it returns nothing.
This will generate a stack-underflow error. You see it only sometimes
because "group_search" does return a value, which you leave on the
stack.
My suggested changes are below:
> define switchto ()
>{
> variable msgid;
> variable cgroup;
> variable groupstr, grouparr, grouplen;
> variable i;
> variable foundit;
>
> call("article_bob");
>
> msgid = extract_article_header("Message-ID");
>
> cgroup = current_newsgroup();
>
> groupstr = extract_article_header("Newsgroups");
> grouparr = strtok(groupstr, ", \t\n");
> grouplen = length(grouparr);
>
> if (is_group_mode() == 0)
> call("quit");
>
I would rewrite the next three blocks of code:
> for (i=0; i<grouplen; i++) {
> if (grouparr[i] == cgroup) {
> foundit = i;
> break;
> }
> }
>
> for(i = (foundit+1) mod grouplen;
> i != foundit;
> i = (i+1) mod grouplen) {
> if (group_search(grouparr[i])) {
> break;
> }
> }
>
> if (i == foundit) {
> group_search(cgroup);
> }
more simply as:
#v+
grouparr = [grouparr[where(grouparr != cgroup)], cgroup];
foreach cgroup (grouparr)
if (group_search (cgroup))
break;
#v-
>
> () = select_group();
> () = locate_header_by_msgid(msgid, 1);
> () = uncollapse_thread();
As mentioned earler, the last line should be written as just
uncollapse_thread ();
> call("article_bob");
>}
>
Here is my version of your function:
#v+
define switchto ()
{
variable
msgid = extract_article_header("Message-ID"),
cgroup = current_newsgroup(),
grouparr = strtok (extract_article_header("Newsgroups"), ", \t\n");
if (is_group_mode() == 0)
call("quit");
grouparr = [grouparr[where(grouparr != cgroup)], cgroup];
foreach cgroup (grouparr)
if (group_search (cgroup))
break;
() = select_group();
() = locate_header_by_msgid(msgid, 1);
uncollapse_thread();
call("article_bob");
}
#v-
I hope this helps.
Good luck, --John