GNOME Bugzilla – Bug 332023
Problems with Bitwise Operators
Last modified: 2006-03-28 21:58:41 UTC
Forwarded from: https://launchpad.net/distros/ubuntu/+source/gcalctool/+bug/32200 The bitwise operators don't work when you use them with the result of a previous operation: 2 And 3 = 2 Leave the two there and press Or 5 = results in a malformed expression, while it should probably say 7. My version is 5.6.31.
I've just tested this with gcalctool v5.7.29. It does the correct thing (answer 7) in non-arithmetic operator precedence mode, but fails as you report, in arithmetic precedence mode. Transferring to Sami for further investigation.
This is a known issue. The explanation is that binary operators work only with integers and parser doesn't know if previous result is an integer (it could be a decimal number). Thus, parser does not allow the result of the previous calculation to be a parameter of an bitwise operation. However, there could be a way to change this. One approach would be for the arithmetic operation to do the check. I would need a IS_INTEGER() function in order to do the check, where boolean IS_INTEGER(a[MP_SIZE]) would return true or false depending if the parameter is an interger or not.
I'd like the arithmetic precedence mode to be as similar to the non-aritmetic precedence mode as possible, so please implement this. It's too later for GNOME 2.14, but it should go in for GNOME 2.15/16. The set_bit_panel() routine in gtk.c does a test like this for whether the bit panel items should be active or not. You're going to need something like: boolean IS_INTEGER(int MPNUM[MP_SIZE]) { int MPI[MPSIZE], MP2[MP_SIZE]; MPstr_to_num(MPNUM, v->base, MP1); mpcmim(MP1, MP2); return(mpeq(MP1, MP2)); }
Created attachment 60521 [details] [review] The Fix. Thanks for the IS_INTEGER! Using that, I made a patch, which hopefully fixes the problem.
Thanks Sami. As we are fast approaching the GNOME 2.14 hard freeze, I'll have a look at it once I've branched and apply it for GNOME 2.15/16.
Is the patch too intrusive to apply it before hard freeze? (I'm by no means pushing you, just curious.)
Unfortunately the changes introduce a new string and we went past the string freeze on February 13th.
The fix is applicable even without the string change. However, the patch changes quite a bit how the parser deals with bitwise operations. The patch actually simplifies the parser. I am not actually sure what kind of changes are allowed to gnome 2.14.1, but this patch would be a good candidate.
Changes checked into CVS HEAD. Version number in configure.in bumped to 5.8.5.
Does 5.8.5 mean that's GNOME 2.15 material?
Yes. As there are string changes in this fix, I don't believe it's acceptable to apply it to a 2.14 "dot" release.
Thanks a lot. I will pass on the message.