mptext.c: Fix hopeless incorrectness in raw base conversions.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 1 Sep 2011 23:49:10 +0000 (00:49 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 1 Sep 2011 23:52:30 +0000 (00:52 +0100)
commit572b324afecc0a7cb2654caf1967e18c8bd813ec
tree7ef341aeccd66d1f82411ce98f1cbc772fc4b011
parent5b7e2ea2181af13a916ea67203552c479d6b9c67
mptext.c: Fix hopeless incorrectness in raw base conversions.

Both mp_write and mp_read are broken.  The former would write a digit
`0' for a zero input, and attempt to prefix its output with a `-' sign
on negative input, both of which are impossible to decode unambiguously.
The latter would skip leading whitespace characters, which makes
encodings beginning with certain bytes decode incorrectly.

Include tests for these cases, and fix the bugs.
mptext.c
tests/mptext