Bug 7795 - bugs in xcalc -rpn mode
bugs in xcalc -rpn mode
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: X11R6-contrib (Show other bugs)
6.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Preston Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-12-13 16:08 EST by redhat
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-02-14 15:21:57 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description redhat 1999-12-13 16:08:19 EST
xcalc, when running with the -rpn option, computes
the wrong answer when an operand is less than one.
For example, the result of
5 ENT 3 ENT 0.1 * -
is 2.7 whereas mathematically, this should be
5 - (3 * 0.1) = 4.7

Note that 5 ENT 3 ENT 2 * - gives the correct answer.

It appears that entering a number less than one corrupts
the stack, duplicating the previous operand (in the
example, 3 is used as an operand in the multiply and
the subtract).

Entry   Stack
5       0 0 0 ...
ENT     5 0 0 ...
3       5 0 0 ...
ENT     3 5 0 ...
0.1     3 3 5 ...  OOPS!
-       3 5 0 ...

In fact, if one types in the 0.1 and then uses the "<-"
key to erase the 0.1, the "3" is already duplicated on
the stack.
Comment 1 redhat 1999-12-14 15:22:59 EST
I think I found the fix for the bug #7795 I reported
yesterday.

I found that there was a difference between decf()
and eef() in math.c, and when I made the change,
the calculator seems to function properly.

The comment for lift_enabled on line 96 is not very
helpful, but I think it determines whether the stack
should be "lifted" when certain keys are pressed.

The diff is very simple:

krylov:contrib/programs/xcalc->diff math.c math.c.orig
400c400
<       if (rpn && lift_enabled)
---
>       if (rpn)
Comment 2 redhat 1999-12-14 15:50:59 EST
I found two more bugs in xcalc that I fixed.

1) From the man page:

  BUGS
       HP mode:  A bug report claims that the sequence of keys 5,
       ENTER, <- should clear the display, but it doesn't.

This is how _my_ HP calculator works.  Admittedly, it's an 11C
rather than the 10C that's supposedly being emulated, but I
think the behavior is the same.


2) If you use the backspace in rpn mode to erase a decimal
point, the flag that prevents two decimals in a number is
not cleared, so you can't enter the decimal point after
correcting it.


The complete diff for these and the original bug is below.

-Geoffrey



krylov:contrib/programs/xcalc->diff math.c math.c.orig
377,378c377
<       if (entered!=1) {
<         clearf();
---
>       if (entered!=1 || clrdisp)
380,385c379
<       }
<       if (clrdisp)
<         return;
<       if ((int) strlen(dispstr) > 0) {
<         if (dispstr[strlen(dispstr)-1] == '.')
<              Dpoint=0;
---
>       if ((int) strlen(dispstr) > 0)
387d380
<       }
407c400
<       if (rpn && lift_enabled)
---
>       if (rpn)
Comment 3 Preston Brown 2000-01-19 14:39:59 EST
fixed for next release.
Comment 4 Preston Brown 2000-01-19 14:47:59 EST
I've applied your patches to the X11R6 in rawhide.  However, this bug still
appears to persist.  If you have a chance, please look at the
X11R6-contrib-3.3.2-7 package in rawhide in the next couple of days and give me
your thoughts.
Comment 5 Preston Brown 2000-02-14 12:54:59 EST
closed due to lack of additional feedback.  Please reopen if you have more
information.
Comment 6 redhat 2000-02-14 14:49:59 EST
Apparently, I didn't submit all the diff's in my previous reports.
There are a few more lines below than in my last report.

% diff math.c math.c.orig
3d2
<  * $MIT: contrib/programs/xcalc/math.c,v 3.2 1999/12/14 18:53:00 gjcoram Exp$
18,19d16
<  *
<  *  Geoffrey Coram fixed most of the HP mode bugs.
316,317c313,314
<         entered = 2;
<         clrdisp++;
---
>       entered = 2;
>       clrdisp++;
325c322
<       clrdisp++;
---
>       clrdisp = 0;
330,331c327,328
<         entered = 2;
<         clrdisp++;
---
>       entered = 2;
>       clrdisp++;
369d365
<   memop = keynum;
381,382c377
<       if (entered!=1) {
<         clearf();
---
>       if (entered!=1 || clrdisp)
384,389c379
<       }
<       if (clrdisp)
<         return;
<       if ((int) strlen(dispstr) > 0) {
<         if (dispstr[strlen(dispstr)-1] == '.')
<              Dpoint=0;
---
>       if ((int) strlen(dispstr) > 0)
391d380
<       }
411c400
<       if (rpn && lift_enabled)
---
>       if (rpn)
814d802
<   memop = keynum;
Comment 7 redhat 2000-02-14 14:52:59 EST
Also, the man page should be updated, since the bug report
in the old man page has been fixed.

% diff xcalc.man xcalc.man.orig
425,426c425,426
< HP mode is not completely debugged.  In particular, the stack is
< not handled properly after errors.
---
> HP mode:  A bug report claims that the sequence of keys 5, ENTER, <-
> should clear the display, but it doesn't.
Comment 8 Preston Brown 2000-02-14 15:21:59 EST
fixed in rawhide, pkg. version X11R6-contrib-3.3.2-11 and later.

Note You need to log in before you can comment on or make changes to this bug.