[ros-diffs] [dreimer] 35367: Update ReactOS Calc to Version 1.10.

dreimer at svn.reactos.org dreimer at svn.reactos.org
Sat Aug 16 10:08:55 CEST 2008


Author: dreimer
Date: Sat Aug 16 03:08:55 2008
New Revision: 35367

URL: http://svn.reactos.org/svn/reactos?rev=35367&view=rev
Log:
Update ReactOS Calc to Version 1.10.

Modified:
    trunk/reactos/base/applications/calc/calc.h
    trunk/reactos/base/applications/calc/calc.rbuild
    trunk/reactos/base/applications/calc/convert.c
    trunk/reactos/base/applications/calc/rpn.c
    trunk/reactos/base/applications/calc/rpn_mpfr.c
    trunk/reactos/base/applications/calc/whatsnew.txt
    trunk/reactos/base/applications/calc/winmain.c

Modified: trunk/reactos/base/applications/calc/calc.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/calc/calc.h?rev=35367&r1=35366&r2=35367&view=diff
==============================================================================
--- trunk/reactos/base/applications/calc/calc.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/calc/calc.h [iso-8859-1] Sat Aug 16 03:08:55 2008
@@ -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 @@
 #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;

Modified: trunk/reactos/base/applications/calc/calc.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/calc/calc.rbuild?rev=35367&r1=35366&r2=35367&view=diff
==============================================================================
--- trunk/reactos/base/applications/calc/calc.rbuild [iso-8859-1] (original)
+++ trunk/reactos/base/applications/calc/calc.rbuild [iso-8859-1] Sat Aug 16 03:08:55 2008
@@ -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>

Modified: trunk/reactos/base/applications/calc/convert.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/calc/convert.c?rev=35367&r1=35366&r2=35367&view=diff
==============================================================================
--- trunk/reactos/base/applications/calc/convert.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/calc/convert.c [iso-8859-1] Sat Aug 16 03:08:55 2008
@@ -561,4 +561,3 @@
     ConvAdjust(hWnd, 0);
 }
 
-

Modified: trunk/reactos/base/applications/calc/rpn.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/calc/rpn.c?rev=35367&r1=35366&r2=35367&view=diff
==============================================================================
--- trunk/reactos/base/applications/calc/rpn.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/calc/rpn.c [iso-8859-1] Sat Aug 16 03:08:55 2008
@@ -310,6 +310,8 @@
             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 @@
     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 @@
         return 0;
     }
 
+    if (func == RPN_OPERATOR_PERCENT)
+        percent_mode = TRUE;
+
     tmp.node.number = *number;
     tmp.node.base = calc.base;
     tmp.node.operation = func;

Modified: trunk/reactos/base/applications/calc/rpn_mpfr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/calc/rpn_mpfr.c?rev=35367&r1=35366&r2=35367&view=diff
==============================================================================
--- trunk/reactos/base/applications/calc/rpn_mpfr.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/calc/rpn_mpfr.c [iso-8859-1] Sat Aug 16 03:08:55 2008
@@ -311,7 +311,6 @@
     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 @@
         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;

Modified: trunk/reactos/base/applications/calc/whatsnew.txt
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/calc/whatsnew.txt?rev=35367&r1=35366&r2=35367&view=diff
==============================================================================
--- trunk/reactos/base/applications/calc/whatsnew.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/calc/whatsnew.txt [iso-8859-1] Sat Aug 16 03:08:55 2008
@@ -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.

Modified: trunk/reactos/base/applications/calc/winmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/calc/winmain.c?rev=35367&r1=35366&r2=35367&view=diff
==============================================================================
--- trunk/reactos/base/applications/calc/winmain.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/calc/winmain.c [iso-8859-1] Sat Aug 16 03:08:55 2008
@@ -784,68 +784,18 @@
 
 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
-
-    str = (char *)malloc(len);
+    int len = strlen(formula);
+    char *str = (char *)malloc(len+3);
+
     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++;
-
-        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';
+    memcpy(str+1, formula, len);
+    str[len+1] = ')';
+    str[len+2] = '\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 @@
         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 @@
         }
         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 @@
     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 @@
         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



More information about the Ros-diffs mailing list