DeskCalc: Improve removal of newlines of dropped files

Thanks to Adrien for the pointers.
This commit is contained in:
Humdinger
2017-11-23 18:18:01 +01:00
parent eb81dec460
commit 4d87bc24d4
+5 -5
View File
@@ -775,14 +775,14 @@ CalcView::Paste(BMessage* message)
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
if (message->FindRef("refs", i, &ref) == B_OK) { if (message->FindRef("refs", i, &ref) == B_OK) {
if (file.SetTo(&ref, B_READ_ONLY) == 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) if (read <= 0)
continue; continue;
BString expression(buffer); BString expression(buffer);
while (expression.Length() > 0 int32 j = expression.Length();
&& expression[expression.Length() - 1] == '\n') { while (j > 0 && expression[j - 1] == '\n')
expression.RemoveLast("\n"); j--;
} expression.Truncate(j);
if (expression.Length() > 0) if (expression.Length() > 0)
fExpressionTextView->Insert(expression.String()); fExpressionTextView->Insert(expression.String());
} }