🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #24095

slrn sort-by-score patches

#24095
From: Olly Betts
Date: Sat, 13 Jul 1996 00:00
232 lines
6930 bytes
In article <slrn4ud54j.8e.gjohnson@dream.season.com>, Reality is a point of view wrote:
> +---- cbbrowne@dantzig.nodomain.nowhere wrote (12 Jul 1996 06:14:51 GMT):
> | I personally have found it annoying when newsreaders have neglected
> | to permit me to order my news in whatever logical fashion I prefer.
>
>I'm still hoping for article sorting by score.

I sent John some patches for doing that, but I guess he's not had time to
integrate them yet.  Anyway, here they are.  They were written for a older
version, but patch applies them to 0.8.8.3 without any problems (I've not
upgraded to 0.8.8.4 yet).  ESC s v in article mode switches to a view
sorted-by-score.

Olly

====
(Message outbox:3545)
To: davis@space.mit.edu
Subject: slrn patches for sort-by-score
Date: Fri, 21 Jun 1996 14:51:26 +0100
From: Olly Betts <olly@mantis.co.uk>

Hi John.

Here's some patches to allow display of articles by score value.  If
threaded, the "score" for a thread is taken as the highest score of an
article in that thread.

BTW, I don't like the way ESC-s currently works: "threaded" is orthogonal to
sorting by server#/subject/score/etc, but the user interface doesn't make
this at all clear.

Cheers,
Olly

--- art.c.orig	Thu Jun 13 05:35:33 1996
+++ art.c	Wed Jun 19 17:49:42 1996
@@ -74,9 +74,15 @@
  *   1 sort by threads
  *   2 sort by subject
  *   3 sort by subject and threads
+ *   4 sort by score
+ *   5 sort by score and threads
+ *   6/7 unused
  */
 #define SORT_BY_THREADS  1
 #define SORT_BY_SUBJECT  2
+#ifdef SLRN_HAS_SORT_BY_SCORE
+# define SORT_BY_SCORE   4
+#endif
 int Slrn_Sorting_Mode = 3;
 
 #define ALL_THREAD_FLAGS (FAKE_PARENT | FAKE_CHILDREN | FAKE_HEADER_HIGH_SCORE)
@@ -2474,8 +2480,10 @@
 }
 #endif
 
+typedef int (*header_cmp_func)(Slrn_Header_Type **, Slrn_Header_Type **);
 
-static void sort_by_subject (void)
+/* sort headers using the given function */
+static void sort_by ( header_cmp_func cmp_func )
 {
    Slrn_Header_Type **header_list, *h;
    unsigned int i, nheaders;
@@ -2515,7 +2523,7 @@
      }
    header_list[nheaders] = NULL;
    
-   (*qsort_fun) ((char *) header_list, nheaders, sizeof (Slrn_Header_Type *), header_subj_cmp);
+   (*qsort_fun) ((char *) header_list, nheaders, sizeof (Slrn_Header_Type *), cmp_func );
    
    /* What to do now depends upon the current threading state. */
    
@@ -2567,6 +2575,26 @@
      }
 }
 
+static void sort_by_subject (void)
+{
+   sort_by( header_subj_cmp );
+}
+	   
+#ifdef SLRN_HAS_SORT_BY_SCORE
+static int header_score_cmp (Slrn_Header_Type **a, Slrn_Header_Type **b)
+{
+   /* sort by *descending* score */
+   int cmp = (*b)->thread_score - (*a)->thread_score;
+   if (!cmp) return (*a)->number - (*b)->number;
+   return cmp;
+}
+
+static void sort_by_score (void)
+{
+   sort_by( header_score_cmp );
+}
+#endif
+
 static void sort_by_server_number (void)
 {
    Slrn_Header_Type *h;
@@ -2609,8 +2637,12 @@
 
 static void toggle_sort (void)
 {
+#ifdef SLRN_HAS_SORT_BY_SCORE
+   char rsp = slrn_get_response ("tTsSvVNnCc", "Sorting method: T-hreads, S-ubject, score V-alue, N-one, C-ancel");
+#else
    char rsp = slrn_get_response ("tTsSNnCc", "Sorting method: T-hreads, S-ubject, N-one, C-ancel");
-   
+#endif
+
    switch (rsp | 0x20)
      {
       case 'n':
@@ -2625,8 +2657,15 @@
 	
       case 's':
 	sort_by_subject ();
-	Slrn_Sorting_Mode |= SORT_BY_SUBJECT;
+	Slrn_Sorting_Mode = (Slrn_Sorting_Mode & SORT_BY_THREADS) | SORT_BY_SUBJECT;
+	break;
+
+#ifdef SLRN_HAS_SORT_BY_SCORE
+      case 'v':
+	sort_by_score ();
+	Slrn_Sorting_Mode = (Slrn_Sorting_Mode & SORT_BY_THREADS) | SORT_BY_SCORE;
 	break;
+#endif
 	
       default:
 	return;
@@ -2642,6 +2681,11 @@
    
    if (Slrn_Sorting_Mode & SORT_BY_SUBJECT)
      sort_by_subject ();
+
+#ifdef SLRN_HAS_SORT_BY_SCORE
+   if (Slrn_Sorting_Mode & SORT_BY_SCORE)
+     sort_by_score ();
+#endif
 }
 
 
@@ -2924,11 +2968,22 @@
 	     next = h->next;
 	     while ((next != NULL) && (next->parent != NULL))
 	       {
+#ifdef SLRN_HAS_SORT_BY_SCORE
+		  if (next->flags & HEADER_HIGH_SCORE)
+		    {
+		       h->flags |= FAKE_HEADER_HIGH_SCORE;
+		    }
+		  if (next->score > h->thread_score)
+		    {
+		       h->thread_score = next->score;
+		    }
+#else
 		  if (next->flags & HEADER_HIGH_SCORE)
 		    {
 		       h->flags |= FAKE_HEADER_HIGH_SCORE;
 		       break;
 		    }
+#endif
 		  next = next->next;
 	       }
 	  }
@@ -3356,6 +3411,9 @@
 	     kill_cross_references (h);
 	  }
      }
+#ifdef SLRN_HAS_SORT_BY_SCORE
+   h->thread_score = h->score = score;
+#endif
    return h;
 }
 
@@ -5093,7 +5151,6 @@
      A_KEY("pagedn", header_pagedn),
      A_KEY("next_same_subject", next_header_same_subject),
      A_KEY("next_high_score", next_high_score),
-     A_KEY("next_high_score", next_high_score),
      A_KEY("locate_header_by_msgid", locate_header_by_msgid),
      A_KEY(NULL, NULL)
 };
@@ -5768,6 +5825,16 @@
 		      h->number);
      }
    else
+#ifdef SLRN_HAS_SORT_BY_SCORE
+   if (Slrn_Sorting_Mode & SORT_BY_SCORE)
+     {
+	SLsmg_printf ("%c %5d ",
+		      ((flags & HEADER_READ) ? 'D': '-'),
+		      ((h->child != NULL) && (h->child->flags & HEADER_HIDDEN))
+		      ? h->thread_score : h->score);
+     }
+   else
+#endif
      SLsmg_printf ("%c%5d:",
 		   ((flags & HEADER_READ) ? 'D': '-'),
 		   h->lines);
--- art.h.orig	Thu Jun 13 05:35:34 1996
+++ art.h	Wed Jun 19 17:51:57 1996
@@ -52,6 +52,9 @@
 #define FAKE_CHILDREN 0x100
 #define FAKE_HEADER_HIGH_SCORE 0x200
    unsigned int tag_number;
+#ifdef SLRN_HAS_SORT_BY_SCORE
+   int score, thread_score;
+#endif
 #define MAX_TREE_SIZE 24
    unsigned char tree[MAX_TREE_SIZE];
 } Slrn_Header_Type;
--- features.h.orig	Thu Jun 13 05:35:32 1996
+++ features.h	Wed Jun 19 16:15:21 1996
@@ -11,6 +11,7 @@
 
 #define SLRN_HAS_SPOILERS	1
 #define SLRN_HAS_MIME		1
+#define SLRN_HAS_SORT_BY_SCORE	1
 
 #ifdef VMS
 # define SLRN_HAS_PIPING	0


-- 
cool wet grass  cool wet grass  cool wet grass  cool wet grass  cool wet grass


Technical Details
Message-ID: <4s87be$23h@sunforest.mantis.co.uk>
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: <slrn44ubl6u.d10.jollie@worf.netins.net> <slrn4ubr0i.9d.cbbrowne@dantzig.nodomain.nowhere> <slrn4ud54j.8e.gjohnson@dream.season.com>

Show Full Headers
Complete Article Headers
Message-ID: <4s87be$23h@sunforest.mantis.co.uk>
Subject: slrn sort-by-score patches
Date: Sat, 13 Jul 1996 00:00:00 +0000
From: olly@mantis.co.uk (Olly Betts)
References: <slrn44ubl6u.d10.jollie@worf.netins.net> <slrn4ubr0i.9d.cbbrowne@dantzig.nodomain.nowhere> <slrn4ud54j.8e.gjohnson@dream.season.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
X-Deja-AN: 168184464
Content-type: text/plain; charset=iso-8859-1
Organization: Mantis Consultants Ltd, Cambridge. UK.
Mime-version: 1.0
Newsgroups: news.software.readers