thread_perc as a group attribute

Travis Brown <[email protected]>
Newsgroups gmane.network.tin.devel
Message-ID <[email protected]>
The attached patch adds a thread_perc group attribute with workings 
identical to the tinrc thread_perc.

Travis
thread_perc_attr.patch (text/plain, 5.4 KB)
diff -ur ./tin-1.7.9/doc/tin.5 /home/travis/projects/projects/tin/tin-1.7.9/doc/tin.5
--- tin-1.7.9/doc/tin.5	2005-06-29 02:36:04.000000000 -0700
+++ tin-1.7.9/doc/tin.5	2005-06-29 17:43:54.000000000 -0700
@@ -525,6 +525,9 @@
 .B thread_arts
 Identical to the tinrc variable \fBthread_articles\fP
 .TP
+.B thread_perc
+Identical to the tinrc variable \fBthread_perc\fP
+.TP
 .B x_body
 A piece of text that will be added at the start of a message body. If this
 string starts with a / or ~ then it is assumed to be the name of a file
Only in /home/travis/projects/projects/tin/tin-1.7.9/include: .svn
Only in /home/travis/projects/projects/tin/tin-1.7.9/include: autoconf.h
diff -ur ./tin-1.7.9/include/tin.h /home/travis/projects/projects/tin/tin-1.7.9/include/tin.h
--- tin-1.7.9/include/tin.h	2005-06-28 19:04:39.000000000 -0700
+++ tin-1.7.9/include/tin.h	2005-06-29 17:43:54.000000000 -0700
@@ -1532,7 +1532,8 @@
 	unsigned batch_save:1;			/* 0=none, 1=save -S/mail -M */
 	unsigned delete_tmp_files:1;		/* 0=leave, 1=delete */
 	unsigned show_only_unread:1;		/* 0=all, 1=only unread */
-	unsigned thread_arts:3;			/* 0=unthread, 1=subject, 2=refs, 3=both, 4=multipart*/
+	unsigned thread_arts:3;			/* 0=unthread, 1=subject, 2=refs, 3=both, 4=multipart, 5=percentage */
+	unsigned thread_perc:7;			/* percentage thrreading threshold */
 	unsigned show_author:2;			/* 0=none, 1=name, 2=addr, 3=both */
 	unsigned show_info:2;			/* 0=none, 1=lines, 2=score, 3=both */
 	unsigned sort_art_type:4;		/* 0=none, 1=subj descend, 2=subj ascend,
diff -ur ./tin-1.7.9/src/art.c /home/travis/projects/projects/tin/tin-1.7.9/src/art.c
--- tin-1.7.9/src/art.c	2005-06-28 01:31:23.000000000 -0700
+++ tin-1.7.9/src/art.c	2005-06-29 17:43:54.000000000 -0700
@@ -86,7 +86,7 @@
 static t_compfunc eval_sort_arts_func(unsigned int sort_art_type);
 static void sort_base(unsigned int sort_threads_type);
 static void thread_by_multipart(void);
-static void thread_by_percentage(void);
+static void thread_by_percentage(struct t_group *group);
 static void thread_by_subject(void);
 
 
@@ -730,12 +730,12 @@
  */
 static void
 thread_by_percentage(
-	void)
+	struct t_group *group)
 {
 	int i, j, k;
 	int root_num = 0; /* The index number of the root we are currently working on. */
 	int unmatched; /* This is the number of characters that don't match between the two strings */
-	unsigned int percentage = 100 - tinrc.thread_perc;
+	unsigned int percentage = 100 - group->attribute->thread_perc;
 	size_t slen;
 
 	/* First we need to sort art[] to simplify and speed up the matching. */
@@ -1094,7 +1094,7 @@
 			break;
 
 		case THREAD_PERC:
-			thread_by_percentage();
+			thread_by_percentage(group);
 			break;
 
 		default: /* not reached */
diff -ur ./tin-1.7.9/src/attrib.c /home/travis/projects/projects/tin/tin-1.7.9/src/attrib.c
--- tin-1.7.9/src/attrib.c	2005-06-28 01:31:21.000000000 -0700
+++ tin-1.7.9/src/attrib.c	2005-06-29 17:41:39.000000000 -0700
@@ -3,7 +3,7 @@
  *  Module    : attrib.c
  *  Author    : I. Lea
  *  Created   : 1993-12-01
- *  Updated   : 2005-05-07
+ *  Updated   : 2005-06-20
  *  Notes     : Group attribute routines
  *
  * Copyright (c) 1993-2005 Iain Lea <[email protected]>
@@ -65,6 +65,7 @@
 	ATTRIB_DELETE_TMP_FILES,
 	ATTRIB_SHOW_ONLY_UNREAD,
 	ATTRIB_THREAD_ARTS,
+	ATTRIB_THREAD_PERC,
 	ATTRIB_SHOW_AUTHOR,
 	ATTRIB_SHOW_INFO,
 	ATTRIB_SORT_ART_TYPE,
@@ -152,6 +153,7 @@
 	attributes->quick_select_expire = tinrc.default_filter_select_expire;
 	attributes->show_only_unread = tinrc.show_only_unread_arts;
 	attributes->thread_arts = tinrc.thread_articles;
+	attributes->thread_perc = tinrc.thread_perc;
 	attributes->sort_art_type = tinrc.sort_article_type;
 	attributes->sort_threads_type = tinrc.sort_threads_type;
 	attributes->show_info = tinrc.show_info;
@@ -355,6 +357,7 @@
 				case 't':
 					MATCH_BOOLEAN("tex2iso_conv=", ATTRIB_TEX2ISO_CONV);
 					MATCH_INTEGER("thread_arts=", ATTRIB_THREAD_ARTS, THREAD_MAX);
+					MATCH_INTEGER("thread_perc=", ATTRIB_THREAD_PERC, 100);
 					break;
 
 				case 'u':
@@ -509,6 +512,9 @@
 		case ATTRIB_THREAD_ARTS:
 			SET_INTEGER(thread_arts);
 
+		case ATTRIB_THREAD_PERC:
+			SET_INTEGER(thread_perc);
+
 		case ATTRIB_SHOW_AUTHOR:
 			SET_INTEGER(show_author);
 
@@ -670,6 +676,7 @@
 		fprintf(fp, "%d=%s, ", i, _(txt_threading[i]));
 	}
 	fprintf(fp, "\n");
+	fprintf(fp, _("#  thread_perc=NUM"));
 	fprintf(fp, _("#  show_author=NUM\n"));
 	fprintf(fp, "#    %d=%s, %d=%s, %d=%s, %d=%s\n",
 		SHOW_FROM_NONE, _(txt_show_from[SHOW_FROM_NONE]),
@@ -818,6 +825,7 @@
 #	endif /* HAVE_ISPELL */
 		fprintf(fp, "show_only_unread=%s\n", print_boolean(attr->show_only_unread));
 		fprintf(fp, "thread_arts=%d\n", attr->thread_arts);
+		fprintf(fp, "thread_perc=%d\n", attr->thread_perc);
 		fprintf(fp, "auto_select=%s\n", print_boolean(attr->auto_select));
 		fprintf(fp, "auto_save=%s\n", print_boolean(attr->auto_save));
 		fprintf(fp, "batch_save=%s\n", print_boolean(attr->batch_save));
@@ -910,6 +918,7 @@
 #		endif /* HAVE_ISPELL */
 		fprintf(stderr, "\tshow_only_unread=%s\n", print_boolean(group->attribute->show_only_unread));
 		fprintf(stderr, "\tthread_arts=%d\n", group->attribute->thread_arts);
+		fprintf(stderr, "\tthread_perc=%d\n", group->attribute->thread_perc);
 		fprintf(stderr, "\tauto_select=%s\n", print_boolean(group->attribute->auto_select));
 		fprintf(stderr, "\tauto_save=%s\n", print_boolean(group->attribute->auto_save));
 		fprintf(stderr, "\tbatch_save=%s\n", print_boolean(group->attribute->batch_save));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.