Hi Vadim Thanks for both your patches - I'll be looking to do a wrap-up release this week with those and a couple of other minor fixes. Wrt. Ion-Mihai's comments (thanks) will attempt to address those suggestions as well.
Cheers mick > Hello again, > > Here is another trivial patch to a dspam tool, this time to fix the > broken > command line parsing in dspam_train. It suffered from 2 problems: > > 1. The username, documented as optional in the man page, was required > and > you couldn't run just "dspam_train spam_dir ham_dir" > > 2. The check that "spam_dir" and "ham_dir" were directories in the > beginning of the script wasn't done at all because "!=" (which can't > be > used to compare string in Perl) was used instead of "ne". > > This patch fixes these 2 problems and also slightly updates the man > page > (the description of "-i index" option still would need to be added > ideally...). > > As before, please let me know if you have any questions about this > patch, > thanks, > VZ > > diff -r b2246e7d9208 man/dspam_train.1 > --- a/man/dspam_train.1 Tue Apr 15 04:16:53 2008 +0200 > +++ b/man/dspam_train.1 Tue Apr 15 04:16:56 2008 +0200 > @@ -20,11 +20,10 @@ dspam_train - train a corpus of mail > .BI \ username \fR > ] > [\c > -.BI \ spam_dir \fR > +.BI \ --client \fR > ] > -[\c > -.BI \ nonspam_dir \fR > -] > +.BI spam_dir \fR > +.BI nonspam_dir \fR > > .ad > .SH DESCRIPTION > @@ -46,18 +45,23 @@ of a particular corpus against dspam in > > .n3 3 > .TP > -.BI [username]\c > -Specifies the user to train. > +.BI --client\c > +If specified, dspam is used in client-server mode. > > .n3 3 > .TP > -.BI [spam_dir]\c > +.BI username\c > +Specifies the user to train, if omitted the current user name is used. > + > +.n3 3 > +.TP > +.BI spam_dir\c > Specifies the pathname to the directory containing the corpus of spam. > Each > message should be separate in its own file. > > .n3 3 > .TP > -.BI [nonspam_dir]\c > +.BI nonspam_dir\c > Specifies the pathname to the directory containing the corpus of > nonspam. Each > message should be separate in its own file. > > diff -r b2246e7d9208 src/tools/dspam_train.in > --- a/src/tools/dspam_train.in Tue Apr 15 04:16:53 2008 +0200 > +++ b/src/tools/dspam_train.in Tue Apr 15 04:16:56 2008 +0200 > @@ -18,7 +18,9 @@ if ($SPAM_CORPUS eq "--client" || $SPAM_ > $NONSPAM_CORPUS = shift; > > if ($NONSPAM_CORPUS eq "") { > - usage(); > + # we were wrong about the first argument, it was the spam corpus > and not > + # the user name in fact > + ($USER, $NONSPAM_CORPUS, $SPAM_CORPUS) = ((getpwuid($<))[0], > $SPAM_CORPUS, $USER) > } > > sub usage { > @@ -26,7 +28,7 @@ sub usage { > exit(-1); > } > > -if ($SPAM_CORPUS != "-i" && (! -d $SPAM_CORPUS || ! -d > $NONSPAM_CORPUS)) { > +if ($SPAM_CORPUS ne "-i" && (! -d $SPAM_CORPUS || ! -d > $NONSPAM_CORPUS)) { > print STDERR "ERROR: " . ((-d $SPAM_CORPUS) ? "nonspam" : > "spam" ) . "corpus must be path to maildir directory\n"; > usage(); > } >