mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
Update ReactOS Calc to Version 1.10.
svn path=/trunk/; revision=35367
This commit is contained in:
parent
1a6f168245
commit
fae32f4a71
7 changed files with 49 additions and 67 deletions
|
@ -42,7 +42,9 @@
|
||||||
#define IDC_STATIC ((DWORD)-1)
|
#define IDC_STATIC ((DWORD)-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CALC_VERSION TEXT("1.09")
|
#define CALC_VERSION TEXT("1.10")
|
||||||
|
|
||||||
|
#define MAX_CALC_SIZE 256
|
||||||
|
|
||||||
/*#define USE_KEYBOARD_HOOK*/
|
/*#define USE_KEYBOARD_HOOK*/
|
||||||
|
|
||||||
|
@ -144,7 +146,8 @@ typedef struct {
|
||||||
#endif
|
#endif
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
DWORD layout;
|
DWORD layout;
|
||||||
TCHAR buffer[256];
|
TCHAR buffer[MAX_CALC_SIZE];
|
||||||
|
TCHAR source[MAX_CALC_SIZE];
|
||||||
TCHAR *ptr;
|
TCHAR *ptr;
|
||||||
calc_number_t code;
|
calc_number_t code;
|
||||||
calc_number_t prev;
|
calc_number_t prev;
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||||
<module name="calc" type="win32gui" installbase="system32" installname="calc.exe" allowwarnings="true" unicode="yes">
|
<module name="calc" type="win32gui" installbase="system32" installname="calc.exe" allowwarnings="true" unicode="yes">
|
||||||
<include base="calc">.</include>
|
<include base="calc">.</include>
|
||||||
<define name="DISABLE_HTMLHELP_SUPPORT">1</define>
|
<define name="DISABLE_HTMLHELP_SUPPORT">1</define>
|
||||||
<define name="_WIN32_WINNT">0x0501</define>
|
<define name="_WIN32_WINNT">0x0501</define>
|
||||||
<library>user32</library>
|
<library>user32</library>
|
||||||
<library>gdi32</library>
|
<library>gdi32</library>
|
||||||
<library>kernel32</library>
|
<library>kernel32</library>
|
||||||
<file>about.c</file>
|
<file>about.c</file>
|
||||||
<file>convert.c</file>
|
<file>convert.c</file>
|
||||||
<file>function.c</file>
|
<file>function.c</file>
|
||||||
<file>rpn.c</file>
|
<file>rpn.c</file>
|
||||||
<file>utl.c</file>
|
<file>utl.c</file>
|
||||||
|
|
|
@ -561,4 +561,3 @@ void ConvInit(HWND hWnd)
|
||||||
ConvAdjust(hWnd, 0);
|
ConvAdjust(hWnd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -310,6 +310,8 @@ void run_operator(calc_node_t *result,
|
||||||
operator_list[operation].op_p(&dc, &da, &db);
|
operator_list[operation].op_p(&dc, &da, &db);
|
||||||
} else
|
} else
|
||||||
operator_list[operation].op_f(&dc, &da, &db);
|
operator_list[operation].op_f(&dc, &da, &db);
|
||||||
|
if (_finite(dc.f) == 0)
|
||||||
|
calc.is_nan = TRUE;
|
||||||
} else {
|
} else {
|
||||||
operator_list[operation].op_i(&dc, &da, &db);
|
operator_list[operation].op_i(&dc, &da, &db);
|
||||||
/* apply final limitator to result */
|
/* apply final limitator to result */
|
||||||
|
@ -331,7 +333,6 @@ static void evalStack(calc_number_t *number)
|
||||||
stack_node_t *op, ip;
|
stack_node_t *op, ip;
|
||||||
unsigned int prec;
|
unsigned int prec;
|
||||||
|
|
||||||
percent_mode = FALSE;
|
|
||||||
op = pop();
|
op = pop();
|
||||||
ip = *op;
|
ip = *op;
|
||||||
prec = operator_list[ip.node.operation].prec;
|
prec = operator_list[ip.node.operation].prec;
|
||||||
|
@ -373,6 +374,9 @@ int exec_infix2postfix(calc_number_t *number, unsigned int func)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (func == RPN_OPERATOR_PERCENT)
|
||||||
|
percent_mode = TRUE;
|
||||||
|
|
||||||
tmp.node.number = *number;
|
tmp.node.number = *number;
|
||||||
tmp.node.base = calc.base;
|
tmp.node.base = calc.base;
|
||||||
tmp.node.operation = func;
|
tmp.node.operation = func;
|
||||||
|
|
|
@ -311,7 +311,6 @@ static void evalStack(calc_number_t *number)
|
||||||
unsigned int prec;
|
unsigned int prec;
|
||||||
|
|
||||||
mpfr_init(ip.node.number.mf);
|
mpfr_init(ip.node.number.mf);
|
||||||
percent_mode = FALSE;
|
|
||||||
op = pop();
|
op = pop();
|
||||||
node_copy(&ip, op);
|
node_copy(&ip, op);
|
||||||
prec = operator_list[ip.node.operation].prec;
|
prec = operator_list[ip.node.operation].prec;
|
||||||
|
@ -355,6 +354,9 @@ int exec_infix2postfix(calc_number_t *number, unsigned int func)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (func == RPN_OPERATOR_PERCENT)
|
||||||
|
percent_mode = TRUE;
|
||||||
|
|
||||||
mpfr_init(tmp.node.number.mf);
|
mpfr_init(tmp.node.number.mf);
|
||||||
rpn_copy(&tmp.node.number, number);
|
rpn_copy(&tmp.node.number, number);
|
||||||
tmp.node.operation = func;
|
tmp.node.operation = func;
|
||||||
|
|
|
@ -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)
|
1.09 (20080630)
|
||||||
=======================
|
=======================
|
||||||
* Fixed bug with Conversion function: "Category" type must be found like "from" and "to" because the combobox sorts its items alphabetically.
|
* Fixed bug with Conversion function: "Category" type must be found like "from" and "to" because the combobox sorts its items alphabetically.
|
||||||
|
|
|
@ -784,68 +784,18 @@ static void delete_stat_item(int n)
|
||||||
|
|
||||||
static char *ReadConversion(const char *formula)
|
static char *ReadConversion(const char *formula)
|
||||||
{
|
{
|
||||||
unsigned int len = 256, n;
|
int len = strlen(formula);
|
||||||
char *str;
|
char *str = (char *)malloc(len+3);
|
||||||
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
|
|
||||||
|
|
||||||
str = (char *)malloc(len);
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return 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] = '(';
|
str[0] = '(';
|
||||||
n = 1;
|
memcpy(str+1, formula, len);
|
||||||
while (1) {
|
str[len+1] = ')';
|
||||||
if (code != NULL) {
|
str[len+2] = '\0';
|
||||||
c = *code++;
|
|
||||||
if (*code == '\0')
|
|
||||||
code = NULL;
|
|
||||||
} else
|
|
||||||
c = *p++;
|
|
||||||
|
|
||||||
if (c == '\0') {
|
_tcscpy(calc.source, (*calc.buffer == _T('\0')) ? _T("0") : calc.buffer);
|
||||||
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';
|
|
||||||
|
|
||||||
/* clear display content before proceeding */
|
/* clear display content before proceeding */
|
||||||
calc.ptr = calc.buffer;
|
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 'Q': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_CANC, 0); break;
|
||||||
case 'R': PostMessage(hwnd, WM_COMMAND, (WPARAM)IDC_BUTTON_MR, 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 {
|
} else {
|
||||||
for (x=0; x<SIZEOF(key2code); x++) {
|
for (x=0; x<SIZEOF(key2code); x++) {
|
||||||
if (!(key2code[x].mask & BITMASK_IS_ASCII) ||
|
if (!(key2code[x].mask & BITMASK_IS_ASCII) ||
|
||||||
|
@ -1650,13 +1605,15 @@ static LRESULT CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case WM_HANDLE_FROM:
|
case WM_HANDLE_FROM:
|
||||||
if (handle_sequence_input(hWnd, &calc.Convert[0]) == NULL) {
|
if (calc.is_nan)
|
||||||
|
break;
|
||||||
|
if (handle_sequence_input(hWnd, &calc.Convert[0]) == NULL)
|
||||||
PostMessage(hWnd, WM_START_CONV, 0,
|
PostMessage(hWnd, WM_START_CONV, 0,
|
||||||
MAKELPARAM(0x0001, WM_HANDLE_TO));
|
MAKELPARAM(0x0001, WM_HANDLE_TO));
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case WM_HANDLE_TO:
|
case WM_HANDLE_TO:
|
||||||
handle_sequence_input(hWnd, &calc.Convert[1]);
|
if (!calc.is_nan)
|
||||||
|
handle_sequence_input(hWnd, &calc.Convert[1]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
calc.action = IDC_STATIC;
|
calc.action = IDC_STATIC;
|
||||||
|
@ -1692,7 +1649,11 @@ static LRESULT CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__REACTOS__)
|
||||||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||||
|
#else
|
||||||
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
|
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
DWORD dwLayout;
|
DWORD dwLayout;
|
||||||
|
@ -1715,7 +1676,9 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
|
||||||
else
|
else
|
||||||
dwLayout = IDD_DIALOG_STANDARD;
|
dwLayout = IDD_DIALOG_STANDARD;
|
||||||
|
|
||||||
CreateDialog(hInstance, MAKEINTRESOURCE(dwLayout), NULL, (DLGPROC)DlgMainProc);
|
/* This call will always fail if UNICODE for Win9x */
|
||||||
|
if (NULL == CreateDialog(hInstance, MAKEINTRESOURCE(dwLayout), NULL, (DLGPROC)DlgMainProc))
|
||||||
|
break;
|
||||||
|
|
||||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||||
#ifndef USE_KEYBOARD_HOOK
|
#ifndef USE_KEYBOARD_HOOK
|
||||||
|
|
Loading…
Reference in a new issue