https://git.reactos.org/?p=reactos.git;a=commitdiff;h=30b40247a303365acd83b21cae417344c079f070

commit 30b40247a303365acd83b21cae417344c079f070
Author:     Carlo Bramini <[email protected]>
AuthorDate: Sun Nov 10 17:01:34 2024 +0100
Commit:     GitHub <[email protected]>
CommitDate: Sun Nov 10 17:01:34 2024 +0100

    [CALC] Fix copy command when output is NaN (#7496)
    
    CORE-19745
---
 base/applications/calc/winmain.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/base/applications/calc/winmain.c b/base/applications/calc/winmain.c
index b2ab16cd0e2..54025b64999 100644
--- a/base/applications/calc/winmain.c
+++ b/base/applications/calc/winmain.c
@@ -1015,10 +1015,16 @@ static void handle_copy_command(HWND hWnd)
     TCHAR display[MAX_CALC_SIZE];
     UINT  n;
 
+    // Read current text from output display
     n = GetDlgItemText(hWnd, IDC_TEXT_OUTPUT, display, SIZEOF(display));
 
-    if (calc.base == IDC_RADIO_DEC && _tcschr(calc.buffer, _T('.')) == NULL)
-        display[n - calc.sDecimal_len] = _T('\0');
+    // Check if result is a true number
+    if (!calc.is_nan)
+    {
+        // Remove trailing decimal point if no decimal digits exist
+        if (calc.base == IDC_RADIO_DEC && _tcschr(calc.buffer, _T('.')) == 
NULL)
+            display[n - calc.sDecimal_len] = _T('\0');
+    }
 
     CopyMemToClipboard(display);
 }

Reply via email to