After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 520525 - (5+3)/2 reports "Malformed expression" in arithmetic precedence mode.
(5+3)/2 reports "Malformed expression" in arithmetic precedence mode.
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
5.21.x
Other Linux
: Normal major
: ---
Assigned To: Sami Pietilä
gcalctool maintainers
Depends on:
Blocks:
 
 
Reported: 2008-03-05 14:49 UTC by Rich Burridge
Modified: 2008-03-11 23:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Correctly clears the display to blank (276 bytes, patch)
2008-03-11 03:19 UTC, Robert Ancell
committed Details | Review
Makes usable_num() understand empty expressions (473 bytes, patch)
2008-03-11 03:37 UTC, Robert Ancell
committed Details | Review

Description Rich Burridge 2008-03-05 14:49:40 UTC
Steps to reproduce.

1/ Start gcalctool, in arithmetic precedence mode, Decimal base
   and scientific mode.
2/ Enter:
   (
   5
   +
   3
   )
   /
   2
   Return

Expected results: 4
Actual results: "Malformed expression" in the status bar.

Works correctly in left-to-right precedence mode.
(Note I also tried: ((5+3)/2) there to not force the calculation
 until the last matching right bracket had been entered.
Comment 1 Rich Burridge 2008-03-10 19:50:23 UTC
Sami, now that we've branched for GNOME 2.23, 
could you please take a look at this one.

Thanks!
Comment 2 Sami Pietilä 2008-03-10 20:19:45 UTC
Hi,

I am unable to reproduce the problem.

Please try to run "make clean" and then "make". Does this help?

----

However, there seems to be regression (in expression editing) from previously released stable version. If I trite "(" to a cleared screen, the result is "0(" when it should be "(". 

I suggest that Robers checks that the rewritten editing logic (do_expression) is functionally equivalent to the previous one.
Comment 3 Rich Burridge 2008-03-10 21:09:41 UTC
> Please try to run "make clean" and then "make". Does this help?

Nope. Still fails. This is with latest Ubuntu Hardy (almost GNOME 2.22).

Robert, what do you get with this one?
Comment 4 Robert Ancell 2008-03-11 03:13:03 UTC
I can confirm the regression where the 0 remains in the display, it occurrs since 5.21.3 (works fine in 5.21.2). Patch attached and committed to SVN head.

In terms of the initially described bug it only occurs for me in 5.21.3 onwards due to the 0 still remaining in the display, i.e. the performing the steps leads to "0(5+3)/2" in the display which is an invalid expression (though this should probably be interpreted as 0*(5+3)/2).
Comment 5 Robert Ancell 2008-03-11 03:19:30 UTC
Created attachment 107030 [details] [review]
Correctly clears the display to blank
Comment 6 Rich Burridge 2008-03-11 03:24:19 UTC
If I apply the patch, then indeed the "0(..." problem goes away
and so does the "(5+3)/2" one. Unfortunately, gcalctool initially
comes up with "No sane value to convert" and the error icon in the
status bar.

Yes I did do a "make clean" followed by a "make" first.
Comment 7 Robert Ancell 2008-03-11 03:36:50 UTC
I'll try to describe what happened here...

The way gcalctool works (and as do most physical calculators I've used) is that
when the calculation is empty (i.e. cleared) instead of nothing being in the
display zero is displayed in the appropriate format. When the user starts a
calculation this zero is replaced the first number/function entered.

In gcalctool 5.21.2 this was achieved using a flag called "ghost_zero". When
ghost_zero == TRUE the display was cleared when the next number/function was
entered and ghost_zero set to FALSE. When the display was cleared ghost_zero
was set to TRUE and the calculation set to "Ans" with register value 0.

From gcalctool 2.21.3 onwards this variable was removed and the logic changed
to "if the calculation is empty display 0 in its place".
Comment 8 Robert Ancell 2008-03-11 03:37:33 UTC
Created attachment 107032 [details] [review]
Makes usable_num() understand empty expressions
Comment 9 Robert Ancell 2008-03-11 03:37:57 UTC
Rich, just noticed that too, see additional patch.
Comment 10 Rich Burridge 2008-03-11 14:30:29 UTC
Fix looks good. I suggest it be also committed to the "gnome-2-22" branch. 

Thanks!
Comment 11 Robert Ancell 2008-03-11 23:57:51 UTC
Fixed on branch, closing.