Hello again John,

i wrote
 |[email protected] (John Dodson) wrote:
 ||For my problem, see,
 ||
 ||        http://sourceforge.net/p/nail/mailman/nail-devel/t\
 ||        hread/[email protected]/
 ||
 ||Still not fixed I think. So it's been broken for a long time.
 ||Where it is in s-nail (after a discussion with Steffen years ago).

Does the attached commit message and diff (against S-nail v14.8.4)
looks sane to you?  It restores substring matching capabilities
that the original BSD code provided, which is what you really
ment, right?  And even with *showname* set you will be able to
match against an address, even though you won't see it in the
header overview (POSIX says "any address as shown in a header
summary shall be matchable in this form").  (With POSIX *allnet*
set we match against addresses only, too, thus...)

 |Thanks for mentioning this again, i didn't get that right in 2012!

Oh yes, interesting thread back then.  Quite off-topic from my
side of the road :o)

--steffen
commit 20716fe (refs/remotes/origin/next, refs/heads/next)
Author: Steffen (Daode) Nurpmeso <[email protected]>
Date:   2015-08-24 20:08:26 +0200

    [-] Fix "address" message specifications (John Dodson)..
    
    right after i "took maintainership" John Dodson contacted me and
    linked a nail-devel@ thread[1] where he reports the problem that
    the plain "address" message specification was originally ment as
    a "any substring matches" implementation.  This was lost along the
    way, the final Heirloom mailx implementation supports POSIX
    *allnet* and works respecting *showname*, but it requires
    a full rather than a substring match.
    
      [1] http://sourceforge.net/p/nail/mailman/nail-devel/thread/[email protected]/
    
    Unfortunately it seems i didn't listen in 2012.  At all.
    So restore the ability to match any substring and, with
    *showname*, repeat once for a plain per-address match.
    Thanks, John Dodson.
---
 list.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 50 insertions(+), 11 deletions(-)

diff --git a/list.c b/list.c
index 413c491..72d8357 100644
--- a/list.c
+++ b/list.c
@@ -847,24 +847,63 @@ scaninit(void)
 static bool_t
 _matchsender(struct message *mp, char const *str, bool_t allnet)
 {
+   char const *str_base, *np_base, *np;
+   char sc, nc;
    bool_t rv;
    NYD_ENTER;
 
-   if (allnet) {
-      char *cp = nameof(mp, 0);
+   /* Empty string doesn't match */
+   if (*(str_base = str) == '\0') {
+      rv = FAL0;
+      goto jleave;
+   }
 
-      do {
-         if ((*cp == '@' || *cp == '\0') && (*str == '@' || *str == '\0')) {
-            rv = TRU1;
-            goto jleave;
+   /* *allnet* is POSIX and, since it explicitly mentions login and user names,
+    * most likely case-sensitive.  XXX Still allow substr matching, though
+    * XXX possibly the first letter should be case-insensitive, then? */
+   if (allnet) {
+      np_base = np = nameof(mp, 0);
+      for (;;) {
+         if ((sc = *str++) == '@')
+            sc = '\0';
+         if ((nc = *np++) == '@' || nc == '\0')
+            break;
+         if (sc != nc) {
+            np = ++np_base;
+            str = str_base;
          }
-         if (*cp != *str)
+      }
+      rv = (sc == '\0');
+   } else {
+      char const *real_base = name1(mp, 0);
+      bool_t again = ok_blook(showname);
+
+      /* TODO POSIX says ~"match any address as shown in header overview",
+       * TODO but a normalized match would be more sane i guess.
+       * TODO struct name should gain a comparison method, normalize realname
+       * TODO content (in TODO) and thus match as likewise
+       * TODO "Buddy (Today) <here>" and "(Now) Buddy <here>" */
+jagain:
+      np_base = np = again ? realname(real_base) : skin(real_base);
+      for (;;) {
+         sc = *str++;
+         if ((nc = *np++) == '\0' || sc == '\0')
             break;
-      } while (++cp, *str++ != '\0');
-      rv = FAL0;
-      goto jleave;
+         sc = upperconv(sc);
+         nc = upperconv(nc);
+         if (sc != nc) {
+            np = ++np_base;
+            str = str_base;
+         }
+      }
+
+      /* And really if i want to match 'on@' then i want it to match even if
+       * *showname* is set! */
+      if (!(rv = (sc == '\0')) && again) {
+         again = FAL0;
+         goto jagain;
+      }
    }
-   rv = !strcmp(str, (*(ok_blook(showname) ? &realname : &skin))(name1(mp, 0)));
 jleave:
    NYD_LEAVE;
    return rv;
------------------------------------------------------------------------------
_______________________________________________
nail-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nail-devel

Reply via email to