[MPlayer-dev-eng] octal and hex surprise and perplex
Alan Curry
pacman at TheWorld.com
Fri Jun 9 09:44:13 CEST 2006
Take a look at the error the results from mplayer dvd://08
Playing dvd://08.
The hostname option must be an integer: 08
Struct dvd, field hostname parsing error: 08
Could an inexperienced user possibly understand what that means?
It fails to make sense on several levels. First of all, the field that
specifies a DVD track number is called "hostname", and referred to as such in
a user-visible message. I suppose this is because the URL-parsing
infrastructure expects a hostname to follow the "://" and I'm not even going
to try to fix that. I don't even think URL syntax belongs here.
The other source of confusion is mplayer's allegation that 08 isn't an
integer, which can only make sense to a C programmer. In the rest of the
known universe, leading zeros are ignored.
Rather than remove the highly useful ability to specify DVD tracks by octal
number (which would inevitably lead to a huge debate over which _other_
integers should be decimal-only on the command line and/or in a config file)
I suggest only the addition of a possibly helpful message which would appear
in the middle of the insanity, like this:
Playing dvd://08.
The hostname option must be an integer: 08
Don't start a number with zero unless you intend it to be octal
Struct dvd, field hostname parsing error: 08
Index: m_option.c
===================================================================
--- m_option.c (revision 18651)
+++ m_option.c (working copy)
@@ -146,6 +146,11 @@
tmp_int = strtol(param, &endptr, 0);
if (*endptr) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "The %s option must be an integer: %s\n",name, param);
+ /* Extra hint for the mortals, who may not know about octal */
+ if(*param=='0' && (*endptr=='8' || *endptr=='9')) {
+ mp_msg(MSGT_CFGPARSER, MSGL_HINT,
+ "Don't start a number with zero unless you intend it to be octal\n");
+ }
return M_OPT_INVALID;
}
More information about the MPlayer-dev-eng
mailing list