Wrong output instead of error message on -o -o
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
I'm running bogofilter 0.10.3.1-1 from Debian. Here's some
shell dialogue:
lobus:~/Procmail> bogofilter -2 -o 0.44 -v <
/tmp/spam.rmail
X-Bogosity: Yes, tests=bogofilter, spamicity=0.512495,
version=0.10.3.1
lobus:~/Procmail> bogofilter -2 -o -o 0.44 -v <
/tmp/spam.rmail
X-Bogosity: No, tests=bogofilter, spamicity=0.512495,
version=0.10.3.1
lobus:~/Procmail>
I don't know how bogofilter interpreted "-o -o" in the
second
command, so I don't know why the answer changed
from "Yes" to "No". I would have preferred to get an
error message instead of some unknown interpretation of
"-o -o".
Logged In: YES
user_id=2788
Bogofilter uses the atof(3) function to parse the argument
to -o, and as it's non-numeric, it probably has interpreted
the -o as 0.0.
Future versions will however see the 0.44 (which remains
unassigned) as additional argument that is not known how to
be interpreted and complain. Is that sufficient?
Logged In: YES
user_id=299187
Complaining about an extra 0.44 would clearly be an improvement.
Another possible improvement would be to use the strtod function
that, unlike atof, reports errors. The only reason I can see
not to use strtod is that perhaps atof is more commonly
available.
But the manual entry for strtod on my system says it's
part of ANSI C, so maybe it will be very commonly available.
Not a big deal in any case.
Logged In: YES
user_id=2788
I have added simple wrappers around strtol (for atoi) and
strtod (for atof) that further simplify checking for parse
errors, but I haven't yet had the time to fix all occasions
where we use atoi or atof, because I haven't yet had the
time to figure the optimal way to report errors found.
Configuration file parsing and the -o option have been
switched to the new xatof() though in CVS.
I'll worry about portability if someone reports a problem.
autoconf has AC_FUNC_STRTOD (I can still resort to sscanf in
that case), but the autoconf manual doesn't document what
operating systems lack strtod().
Fellow hackers, I'll leave this PR open until all
atoi()/atof() are gone.
Logged In: YES
user_id=2788
Should be fixed in CVS.