cvs commit: ALFS/nALFS/src bufsize.h init.c nalfs.c options.c

Kevin P. Fleming kpfleming at
Wed Nov 5 18:37:15 PST 2003

Neven Has wrote:

> You're right, it's better that everything goes through Nprints then.
> And we can always create another function instead of nprint_text
> (those "E:"s and "I:"s are things that I dislike in initialization
> phase, but no need to worry about that now).

OK, I had some time to think about this on the way home... this is a bit 
long, so bear with me...

The "priority" scheme won't work, because it would be a bear to 
implement. For example:

   nALFS --option1 --rcfile <file1> --option2 --rcfile <file2>

In this case, options from <file1> need higher priority than option1, 
but lower priority than option2 or options from <file2>. Processing the 
rcfiles after all the command line options would be a big pain.

Instead, I can create "nprint_init". This will do only the stdout/stderr 
stuff that nprint_text does, no messing with prefix characters, log 
files, etc. In addition, nalfs.c would contain two variables, "static 
int init_errors = 0;" and "static int init_warnings = 0;". Each time 
nprint_init gets called with T_ERR, it increments init_errors; each time 
it gets called with T_WAR, it increments init_warnings. nalfs.c/main() 
sets nprint to nprint_init until after all initialization tasks are 
done, then to nprint_text (and on to nprint_curses if interactive mode 
is in use).

Now, all initialization steps use Nprint for all their error/warning 
messages, _AND_ (here's the important part) no errors or warnings 
actually _stop_ the initialization process. After all initialization 
steps have been completed as best they can be, nalfs.c/main() checks 
init_errors; if it's non-zero, it does exit(EXIT_FAILURE). If not, then 
checks init_warnings; if it's non-zero, it does a simple getc() or 
whatever to make the program pause until the user acknowledges that the 
warning messages were seen (or maybe they press ^C and just quit at that 

This means that we can go ahead and parse_rc_file() each --rcfile 
argument as we see it, and the options get applied in the order the user 
asked for them. rcfile parsing errors would not cause the initialization 
process to stop, though, so the user gets to see all the errors found in 
all rcfiles/options/etc., including "No profiles specified" if that ends 
up being the case.

Finally, I'll remove the pre-scanning for --rcfile options to suppress 
reading /etc/nALFSrc and ~/.nALFSrc; those will always be read, and 
--rcfile <file> would just override the options found.


More information about the alfs-log mailing list