🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
1 messages
1 total messages Started by blue... Dawn Owens-Nicholson Wed, 12 Aug 1998 00:00
Re: Problem with s-lang macro
#42699
Author: blue... Dawn Owens-Nicholson
Date: Wed, 12 Aug 1998 00:00
44 lines
2324 bytes
xcitor <xci...@pobox.com> wrote:
> define article_mode_hook ()
>      {
>         variable signature_file = ".signature";

Here, I suggest getting the signature from the configured value instead of
supplying one -- a slrnrc file is more likely to be thought of months from
now if you want to change this value or distribute your code to someone
else:

          variable signature_file = get_variable_value ("signature");

>         if (0 == strncmp (current_newsgroup (), "pets", 5))
>           signature_file = ".sig-generic";

I suggest:

   if (string_match (strlow (current_newsgroup ()), "pets", 1))
     signature_file = make_home_filename (".sig_generic");

instead.  strlow() converts the newsgroup name to the same case as "pets"
(so we get a case-insensitive comparison). make_home_filename() returns the
string relative to your homedir (I think on non-homedir systems this
degrades to something reasonable like the dir you started slrn in, but I'm
not sure because I too use slrn on Unix).

> My best guess as to what's going on is that "pets" is not matching the
> newsgroup properly.

The first 5 characters are not matching precisely, so strcmp() & strncmp()
are giving you a lexicographic comparison (I don't see the documentation on
how it handles a 5-character comparison given only 4 characters in the
string "pets", but that's beside the point).  However, regular expressions
are (in my opinion) better for what you're doing--basically asking "does the
current_newsgroup() contain the string `pets'?".

> Any pointers appreciated... TIA

The S-Lang distribution's doc/ directory comes with function documentation
in a variety of formats.

Hope this helps!
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads