[haiku-commits] haiku: hrev51609 - src/apps/deskcalc

  • From: humdingerb@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 23 Nov 2017 18:18:27 +0100 (CET)

hrev51609 adds 1 changeset to branch 'master'
old head: eb81dec460ef5218228fd62fbe9df94bb46aea51
new head: 4d87bc24d46a6fa6096783af1ebd31ac0add19e5
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=4d87bc24d46a+%5Eeb81dec460ef

----------------------------------------------------------------------------

4d87bc24d46a: DeskCalc: Improve removal of newlines of dropped files
  
  Thanks to Adrien for the pointers.

                                        [ Humdinger <humdingerb@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev51609
Commit:      4d87bc24d46a6fa6096783af1ebd31ac0add19e5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=4d87bc24d46a
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Thu Nov 23 17:16:46 2017 UTC

----------------------------------------------------------------------------

1 file changed, 5 insertions(+), 5 deletions(-)
src/apps/deskcalc/CalcView.cpp | 10 +++++-----

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index c9579f4..a177589 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -775,14 +775,14 @@ CalcView::Paste(BMessage* message)
                for (int32 i = 0; i < count; i++) {
                        if (message->FindRef("refs", i, &ref) == B_OK) {
                                if (file.SetTo(&ref, B_READ_ONLY) == B_OK) {
-                                       read = file.Read(buffer, 255);
+                                       read = file.Read(buffer, sizeof(buffer) 
- 1);
                                        if (read <= 0)
                                                continue;
                                        BString expression(buffer);
-                                       while (expression.Length() > 0
-                                               && 
expression[expression.Length() - 1] == '\n') {
-                                               expression.RemoveLast("\n");
-                                       }
+                                       int32 j = expression.Length();
+                                       while (j > 0 && expression[j - 1] == 
'\n')
+                                               j--;
+                                       expression.Truncate(j);
                                        if (expression.Length() > 0)
                                                
fExpressionTextView->Insert(expression.String());
                                }


Other related posts:

  • » [haiku-commits] haiku: hrev51609 - src/apps/deskcalc - humdingerb