🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #42699

Re: Problem with s-lang macro

#42699
From: 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!
Technical Details
Message-ID: <slrn6t28r2.8kr.bluemoon@ux6.cso.uiuc.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!not-for-mail
References: <slrn6t1nu9.o5.xcitor@axel.bonzoid.com>

Show Full Headers
Complete Article Headers
Message-ID: <slrn6t28r2.8kr.bluemoon@ux6.cso.uiuc.edu>
Subject: Re: Problem with s-lang macro
Date: Wed, 12 Aug 1998 00:00:00 +0000
From: blue...@ux6.cso.uiuc.edu (Dawn Owens-Nicholson)
References: <slrn6t1nu9.o5.xcitor@axel.bonzoid.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!not-for-mail
X-Deja-AN: 380297547
Organization: University of Illinois at Urbana-Champaign
Newsgroups: alt.lang.s-lang,news.software.readers