From fae32f4a71e23a5f04393be69c792cdbed641620 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sat, 16 Aug 2008 08:08:55 +0000 Subject: [PATCH] Update ReactOS Calc to Version 1.10. svn path=/trunk/; revision=35367 --- reactos/base/applications/calc/calc.h | 7 +- reactos/base/applications/calc/calc.rbuild | 4 +- reactos/base/applications/calc/convert.c | 1 - reactos/base/applications/calc/rpn.c | 6 +- reactos/base/applications/calc/rpn_mpfr.c | 4 +- reactos/base/applications/calc/whatsnew.txt | 11 +++ reactos/base/applications/calc/winmain.c | 83 ++++++--------------- 7 files changed, 49 insertions(+), 67 deletions(-) diff --git a/reactos/base/applications/calc/calc.h b/reactos/base/applications/calc/calc.h index 36e8febcfdb..177e38e7362 100644 --- a/reactos/base/applications/calc/calc.h +++ b/reactos/base/applications/calc/calc.h @@ -42,7 +42,9 @@ #define IDC_STATIC ((DWORD)-1) #endif -#define CALC_VERSION TEXT("1.09") +#define CALC_VERSION TEXT("1.10") + +#define MAX_CALC_SIZE 256 /*#define USE_KEYBOARD_HOOK*/ @@ -144,7 +146,8 @@ typedef struct { #endif HWND hWnd; DWORD layout; - TCHAR buffer[256]; + TCHAR buffer[MAX_CALC_SIZE]; + TCHAR source[MAX_CALC_SIZE]; TCHAR *ptr; calc_number_t code; calc_number_t prev; diff --git a/reactos/base/applications/calc/calc.rbuild b/reactos/base/applications/calc/calc.rbuild index 0c9be44f64b..72739c62183 100644 --- a/reactos/base/applications/calc/calc.rbuild +++ b/reactos/base/applications/calc/calc.rbuild @@ -2,13 +2,13 @@ . - 1 + 1 0x0501 user32 gdi32 kernel32 about.c - convert.c + convert.c function.c rpn.c utl.c diff --git a/reactos/base/applications/calc/convert.c b/reactos/base/applications/calc/convert.c index 06107c81d4d..d281d444603 100644 --- a/reactos/base/applications/calc/convert.c +++ b/reactos/base/applications/calc/convert.c @@ -561,4 +561,3 @@ void ConvInit(HWND hWnd) ConvAdjust(hWnd, 0); } - diff --git a/reactos/base/applications/calc/rpn.c b/reactos/base/applications/calc/rpn.c index 241464673bf..1435e8065ab 100644 --- a/reactos/base/applications/calc/rpn.c +++ b/reactos/base/applications/calc/rpn.c @@ -310,6 +310,8 @@ void run_operator(calc_node_t *result, operator_list[operation].op_p(&dc, &da, &db); } else operator_list[operation].op_f(&dc, &da, &db); + if (_finite(dc.f) == 0) + calc.is_nan = TRUE; } else { operator_list[operation].op_i(&dc, &da, &db); /* apply final limitator to result */ @@ -331,7 +333,6 @@ static void evalStack(calc_number_t *number) stack_node_t *op, ip; unsigned int prec; - percent_mode = FALSE; op = pop(); ip = *op; prec = operator_list[ip.node.operation].prec; @@ -373,6 +374,9 @@ int exec_infix2postfix(calc_number_t *number, unsigned int func) return 0; } + if (func == RPN_OPERATOR_PERCENT) + percent_mode = TRUE; + tmp.node.number = *number; tmp.node.base = calc.base; tmp.node.operation = func; diff --git a/reactos/base/applications/calc/rpn_mpfr.c b/reactos/base/applications/calc/rpn_mpfr.c index a6e8d70df20..d5dc95c805b 100644 --- a/reactos/base/applications/calc/rpn_mpfr.c +++ b/reactos/base/applications/calc/rpn_mpfr.c @@ -311,7 +311,6 @@ static void evalStack(calc_number_t *number) unsigned int prec; mpfr_init(ip.node.number.mf); - percent_mode = FALSE; op = pop(); node_copy(&ip, op); prec = operator_list[ip.node.operation].prec; @@ -355,6 +354,9 @@ int exec_infix2postfix(calc_number_t *number, unsigned int func) return 0; } + if (func == RPN_OPERATOR_PERCENT) + percent_mode = TRUE; + mpfr_init(tmp.node.number.mf); rpn_copy(&tmp.node.number, number); tmp.node.operation = func; diff --git a/reactos/base/applications/calc/whatsnew.txt b/reactos/base/applications/calc/whatsnew.txt index b4b7f596d61..930ffb94eac 100644 --- a/reactos/base/applications/calc/whatsnew.txt +++ b/reactos/base/applications/calc/whatsnew.txt @@ -1,3 +1,14 @@ +1.10 (20080813) +======================= +* Added Norvegian and Korean translations. +* Fixed Polish and Slovak translations. +* Fixed percent mode. +* Fixed some unsignaled overflow errors. +* Fixed conversion method, now scientific notation is recognized too. +* Added compilation for UNICODE executables. +* Plain MINGW toolchain do not support wWinMain function, so I switched to old WinMain if it is not under ReactOS' build tree. +* Detect error if UNICODE version is launched into Win9x (avoid the lock). + 1.09 (20080630) ======================= * Fixed bug with Conversion function: "Category" type must be found like "from" and "to" because the combobox sorts its items alphabetically. diff --git a/reactos/base/applications/calc/winmain.c b/reactos/base/applications/calc/winmain.c index 86ffe56ad61..14b00ac0333 100644 --- a/reactos/base/applications/calc/winmain.c +++ b/reactos/base/applications/calc/winmain.c @@ -784,68 +784,18 @@ static void delete_stat_item(int n) static char *ReadConversion(const char *formula) { - unsigned int len = 256, n; - char *str; - char *code = NULL; - const char *p = formula; - char c; - calc_number_t x; - TCHAR buffer[SIZEOF(calc.buffer)]; -#ifdef UNICODE - char cbuffer[SIZEOF(calc.buffer)]; -#endif + int len = strlen(formula); + char *str = (char *)malloc(len+3); - str = (char *)malloc(len); if (str == NULL) return NULL; - /* prepare code string */ - rpn_alloc(&x); - convert_text2number(&x); - prepare_rpn_result(&x, - buffer, SIZEOF(buffer), - calc.base); - rpn_free(&x); - -#ifdef UNICODE - WideCharToMultiByte(CP_ACP, 0, buffer, -1, cbuffer, SIZEOF(cbuffer), NULL, NULL); -#endif - str[0] = '('; - n = 1; - while (1) { - if (code != NULL) { - c = *code++; - if (*code == '\0') - code = NULL; - } else - c = *p++; + memcpy(str+1, formula, len); + str[len+1] = ')'; + str[len+2] = '\0'; - if (c == '\0') { - str[n++] = ')'; - if (n >= len-1) { - str = (char *)realloc(str, len += 16); - if (str == NULL) - return NULL; - } - break; - } else - if (c == '$') { -#ifdef UNICODE - code = cbuffer; -#else - code = buffer; -#endif - continue; - } - str[n++] = c; - if (n >= len-1) { - str = (char *)realloc(str, len += 16); - if (str == NULL) - return NULL; - } - } - str[n] = '\0'; + _tcscpy(calc.source, (*calc.buffer == _T('\0')) ? _T("0") : calc.buffer); /* clear display content before proceeding */ calc.ptr = calc.buffer; @@ -991,6 +941,11 @@ static char *handle_sequence_input(HWND hwnd, sequence_t *seq) case 'Q': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_CANC, 0); break; case 'R': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MR, 0); break; } + } else + if (ch == '$') { + calc.ptr = + _tcscpy(calc.buffer, calc.source) + + _tcslen(calc.source); } else { for (x=0; x