mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +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)
|
||||
#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;
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<module name="calc" type="win32gui" installbase="system32" installname="calc.exe" allowwarnings="true" unicode="yes">
|
||||
<include base="calc">.</include>
|
||||
<define name="DISABLE_HTMLHELP_SUPPORT">1</define>
|
||||
<define name="DISABLE_HTMLHELP_SUPPORT">1</define>
|
||||
<define name="_WIN32_WINNT">0x0501</define>
|
||||
<library>user32</library>
|
||||
<library>gdi32</library>
|
||||
<library>kernel32</library>
|
||||
<file>about.c</file>
|
||||
<file>convert.c</file>
|
||||
<file>convert.c</file>
|
||||
<file>function.c</file>
|
||||
<file>rpn.c</file>
|
||||
<file>utl.c</file>
|
||||
|
|
|
@ -561,4 +561,3 @@ void ConvInit(HWND hWnd)
|
|||
ConvAdjust(hWnd, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<SIZEOF(key2code); x++) {
|
||||
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;
|
||||
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,
|
||||
MAKELPARAM(0x0001, WM_HANDLE_TO));
|
||||
}
|
||||
return TRUE;
|
||||
case WM_HANDLE_TO:
|
||||
handle_sequence_input(hWnd, &calc.Convert[1]);
|
||||
if (!calc.is_nan)
|
||||
handle_sequence_input(hWnd, &calc.Convert[1]);
|
||||
return TRUE;
|
||||
case WM_CLOSE:
|
||||
calc.action = IDC_STATIC;
|
||||
|
@ -1692,7 +1649,11 @@ static LRESULT CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
|||
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)
|
||||
#endif
|
||||
{
|
||||
MSG msg;
|
||||
DWORD dwLayout;
|
||||
|
@ -1715,7 +1676,9 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
|
|||
else
|
||||
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)) {
|
||||
#ifndef USE_KEYBOARD_HOOK
|
||||
|
|
Loading…
Reference in a new issue