If I have a value of "0000008" that is being sent over
XMLRPC - the following error is returned:
argument to math function was an invalid octal number
The source of this is a generic test for number
formatting within the rpcvar::rpctype process --
specifically the following section:
} elseif {[string is double -strict $arg]} {
# See: http://www.w3.org/TR/xmlschema-2/#float
if {[expr {(abs($arg) > (pow(2,24)*pow(2,-149)))
&& (abs($arg) < (pow(2,24)*pow(2,104)))}]} {
set type "float"
} else {
set type "double"
}
Proposed change to the following to properly evaluate if
integers are integers and doubles are doubles:
} elseif {[string is integer -strict $arg]} {
if ![isOctalFmt $arg] {
set type "int"
} else {
set type "string"
}
} elseif {[isDouble $arg]} {
if ![isOctalFmt $arg] {
# See: http://www.w3.org/TR/xmlschema-
2/#float
if {[expr {(abs($arg) > (pow(2,24)*pow(2,-149)))
&& (abs($arg) < (pow(2,24)*pow(2,104)))}]} {
set type "float"
} else {
set type "double"
}
} else {
set type "string"
}
Also, add these supporting procedures:
proc ::rpcvar::isDouble { arg } {
if {![catch {format %f $arg}]} {
return 1
}
return 0
}
proc ::rpcvar::isOctalFmt { arg } {
return [regexp {^[0][0-9]+} $arg]
}