[tin-dev] [PATCH] to note unsubscribed cmd-line groups with -[zZSN]

Urs Janßen urs at tin.org
Tue Aug 8 09:31:48 CEST 2023


The following patch treats unsubscribed groups given on the cmd-line
for -z/-Z/-S/-N as they were subscribed groups via temporary missusing
the read_during_session field. This addresses

| o  batch mode has several bugs
|   - -Z and giving a cmd-line group the cmd-line group is not displayed in
|     the statistics nor taken into account for the 'any unread news' status.

and somehow (but different)

| o  should 'tin -z foo.bar' only start up if there is any unread news in
|    foo.bar?
|   [20040325 Urs Janssen <urs at tin.org>]

Comments? Useful?


=== modified file 'include/proto.h'
--- old/include/proto.h	2023-06-27 01:46:29 +0000
+++ new/include/proto.h	2023-08-08 07:01:31 +0000
@@ -622,7 +622,7 @@
 extern void compose_mail_text_plain(const char *filename, struct t_group *group);
 
 /* save.c */
-extern int check_start_save_any_news(int function, t_bool catchup);
+extern int check_start_save_any_news(int function, t_bool catchup, int num_cmd_line_groups);
 extern t_bool create_path(const char *path);
 extern t_bool post_process_files(t_function proc_type_func, t_bool auto_delete);
 extern t_bool save_and_process_art(t_openartinfo *artinfo, t_bool is_mailbox, const char *inpath, int max, t_bool post_process);

=== modified file 'src/main.c'
--- old/src/main.c	2023-07-19 23:58:32 +0000
+++ new/src/main.c	2023-08-08 07:09:53 +0000
@@ -396,10 +396,10 @@
 	 * Check/start if any new/unread articles
 	 */
 	if (check_any_unread)
-		tin_done(check_start_save_any_news(CHECK_ANY_NEWS, catchup), NULL);
+		tin_done(check_start_save_any_news(CHECK_ANY_NEWS, catchup, num_cmd_line_groups), NULL);
 
 	if (start_any_unread) {
-		if ((start_groupnum = check_start_save_any_news(START_ANY_NEWS, catchup)) == -1)
+		if ((start_groupnum = check_start_save_any_news(START_ANY_NEWS, catchup, num_cmd_line_groups)) == -1)
 			tin_done(EXIT_SUCCESS, NULL);
 	}
 
@@ -413,7 +413,7 @@
 	 *       for speed reasons?
 	 */
 	if (mail_news || save_news) {
-		check_start_save_any_news(mail_news ? MAIL_ANY_NEWS : SAVE_ANY_NEWS, catchup);
+		check_start_save_any_news(mail_news ? MAIL_ANY_NEWS : SAVE_ANY_NEWS, catchup, num_cmd_line_groups);
 		tin_done(EXIT_SUCCESS, NULL);
 	}
 
@@ -1161,6 +1161,7 @@
 							my_strncpy(tinrc.default_post_newsgroups, active[i].name, sizeof(tinrc.default_post_newsgroups) - 1);
 							break;
 						}
+						active[i].read_during_session = TRUE; /* missuse for "-[zZMN] grp" */
 					}
 				}
 			}

=== modified file 'src/save.c'
--- old/src/save.c	2023-07-19 23:58:32 +0000
+++ new/src/save.c	2023-08-08 07:25:09 +0000
@@ -132,7 +132,8 @@
 int
 check_start_save_any_news(
 	int function,
-	t_bool catchup)
+	t_bool catchup,
+	int num_cmd_line_groups)
 {
 	FILE *artfp, *savefp;
 	FILE *fp_log = (FILE *) 0;
@@ -142,7 +143,7 @@
 	char logfile[PATH_LEN], savefile[PATH_LEN];
 	char subject[HEADER_LEN];
 	int group_count = 0;
-	int i, j;
+	int i, j, k;
 	int art_count, hot_count;
 	int saved_arts = 0;					/* Total # saved arts */
 	struct t_article *art;
@@ -183,6 +184,7 @@
 			break;
 	}
 
+	k = num_cmd_line_groups;
 	/*
 	 * For each group we subscribe to...
 	 */
@@ -197,10 +199,19 @@
 		 */
 		selmenu.curr = i;
 
-		/* TODO: also log with verbose > 1? */
-		if (group->bogus || !group->subscribed)
+		/*
+		 * read_during_session is missued as indicator for a cmdline group
+		 *
+		 * TODO: also log with verbose > 1? 
+		 */
+		if (group->bogus || (!k && !group->subscribed) || (k && !group->read_during_session))
 			continue;
 
+		if (group->read_during_session && k) {
+			k--; /* just to make the test above faster once we've done the cmd-line grpups */
+			group->read_during_session = FALSE; /* reset in case we do NOT enter the group later */
+		}
+
 		if (function == MAIL_ANY_NEWS || function == SAVE_ANY_NEWS) {
 			if (!group->attribute->batch_save) { /* TODO: string -> lang.c */
 				if (verbose > 1 && function == MAIL_ANY_NEWS)




More information about the tin-dev mailing list