Hang caused by clicking backspace with single neg number
galculator is a scientific calculator in algebraic mode and RPN
Brought to you by:
chimaira
Explicitly entering a negative number will cause an (infinite?) hang when backspace is clicked. For example, if the number -369 is entered (3, 6, 9, +/-), then the 6 and 9 are correctly removed by backspace, but the final -3 will cause the hang. Decimal points are also correctly removed - so it seems the problem is related to the number of characters rather than the actual value of the number.
If the number is the product of a sum (eg. 2 - 5), then the backspace correctly turns the -3 into zero.
I've found the fix but i don't know how to submit it
i'm a beginner
in display.c :
in display_result_backspace(int number_base_status) :
else if ((strlen(current_entry) == 2) && (*current_entry == '-')) current_entry = "0\0";
should be changed to :
else if ((strlen(current_entry) == 2) && (*current_entry == '-')) strcpy(current_entry, "0\0");
EDIT :
should be changed to :
else if ((strlen(current_entry) == 2) && (*current_entry == '-'))
strcpy(current_entry, "0");
(no need for null termination then)
Thanks for your bug report. Your proposed fix is correct and I have applied it to current SVN. It will be part of upcoming version 2.0. best