Strange sorting
Derek Atkins
warlord at MIT.EDU
Thu Oct 7 09:25:10 EDT 2010
"Anthony Dardis" <adardis at gmail.com> writes:
> Speaking as an old young programmer, seems like it would be
> non-trivial for the "interpret as octal" hook to grab onto the
> transaction number field, since it appears to be a string. But stuff
> happens.
I don't understand why you think this is non-trivial. The 'order'
function has the following code in it:
/* otherwise, sort on number string */
na = atoi(ta->num);
nb = atoi(tb->num);
if (na < nb) return -1;
if (na > nb) return +1;
The problem is that the "convert string to number" function that was
used had an implicit "leading zero means interpret as octal" side-effect
(I believe it was using effectively strtol(x, NULL, 0)). The code
currently uses atoi() which should explicitly be decimal, but perhaps we
should change it to an explicit strtol(ta->num, NULL, 10). Regardless,
any change will not go into the never-being-touched-again 2.2 branch,
because we don't plan on a 2.2.10 release.
-derek
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord at MIT.EDU PGP key available
More information about the gnucash-user
mailing list