[PATCH] batch mode and cmd-line option treatment

Dennis Preiser <[email protected]> Fri, 17 Jul 2009 20:48:15 +0200
Newsgroups gmane.network.tin.devel
Message-ID <[email protected]>
Hello,

regarding batch-mode and cmd-line option treatment the attached patch  
does the following:

- '-s', '-m' and '-G' cmd-line switches no longer changes the  
corresponding tinrc values implicitly. A new struct 'cmdline' is used  
which holds the given cmd-line options and a bitmap which indicates  
which options were given via cmd-line. The former cmdline_nntpserver  
is incorporated in this struct as well as use_color ('-a') (needed to  
decide in read_config_file() whether to toggle tinrc.use_color or  
not). cmd-line mail/savedir has higher priority as attributes and  
tinrc values. Now, if '-s' was given when saving for later reading ('- 
S -s dirname') the same savedir must be given when reading these  
saved news ('-R -s dirname').

- batch mode (!verbose) was not really quiet (txt_reading_config_file  
and an additional newline was shiped out, not useful for scripting).  
See tin -Z. Now, batch mode is quiet. I moved read_cmd_line_options()  
before read_config_file() in main.c to make batch_mode available in  
read_config_file() (needed to be suppress the wait_message()). This  
also avoids reading the config files in case of '-h'/'-H' or when tin  
giveup() in read_cmd_line_options().

- batch mode (verbose) was not really verbose (some of the startup  
messages were printed and some not). See tin vs. tin -vZ. Now, tin  
prints all startup messages in verbose batch mode. If this is not  
useful, I can change this to a subset of the startup messages.

- I removed write_config_file() after create_mail_save_dirs() in  
main.c. (no changes during startup -> no need to write the config file)

- When maildir starts with '=' tin hangs after 's'aving an article to  
a mailbox. When savedir starts with '+' tin hangs after 's'aving an  
article to a file. This happens while expanding the leading character  
again and again in misc.c:_strfpath(). Now, '+' and '=' are only  
expanded in case of a filename (expand_all == TRUE).

- The group->attribute->savefile update in feed.c:get_save_filename()  
is deactivated now. If we want to update the value we have to adjust  
the scope, but I'm not sure whether this update is needed here. I  
think it's better to leave the attributes untouched except the user  
changes them via the attributes menu.

- misc.c:_strfpath() has returned '1' (path is a mailbox) in case of  
'=' within a file or pathname (e.g., 'sample=name'). '1' should be  
returned only when the filename starts with '='. Fixed.

- '-w' now suggests the first given cmd-line group as default group  
to post to. In case of a wildcarded groupname the first match is  
used. I decided to use only the first group because a wildcarded  
group can result in a huge list (e.g., comp.*) which cannot be  
reasonably handled.

- group.c:prompt_getart_limit() (GROUP_TOGGLE_GET_ARTICLES_LIMIT  
('G')) has returned '0' if one cancels the prompt ('ESC'). Not  
useful, because the former value is lost and tinrc.getart_limit is  
set to '0'. Now, the old value is kept in case of cancelling the prompt.

other changes:

- tin no longer writes the attributes file in batch mode (no changes - 
 > no need to write the file).

- filter.c:write_filter_file(): deactivated the computation of  
filter_file_offset in batch_mode.

- Insert a ClearScreen() in select.c:select_quit() to make the  
following (scrolling) messages looks nicer (I guess this is only  
noticeable on a slow terminal).

If these changes are acceptable, I will send in another patch wich  
updates the man-page (e.g., '-w' and cmd-line groups, impact on '- 
S'/'-R'...).

Dennis
20090717.diff.gz (application/x-gzip, 8.5 KB) - not displayed