From bdc33077f978c4fe10f2d2a4feb27d6709609faa Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 9 Jun 2008 18:52:09 +0000 Subject: [PATCH] GCC 4 fixes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25885 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/TermScrollView.cpp | 2 +- src/apps/terminal/TermView.cpp | 6 +++--- src/apps/terminal/TermWindow.cpp | 2 +- src/apps/terminal/TerminalBuffer.cpp | 6 ++---- src/apps/terminal/UTF8Char.h | 18 ++++++++++++++++++ 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/apps/terminal/TermScrollView.cpp b/src/apps/terminal/TermScrollView.cpp index a6de128a91..8d0a6f621f 100644 --- a/src/apps/terminal/TermScrollView.cpp +++ b/src/apps/terminal/TermScrollView.cpp @@ -24,7 +24,7 @@ public: virtual void ValueChanged(float newValue) { if (BView* target = Target()) - Target()->ScrollTo(0, newValue); + target->ScrollTo(0, newValue); } }; diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index 50725dcbb9..b151b28b85 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -689,7 +689,7 @@ void TermView::_InvalidateTextRange(TermPos start, TermPos end) { if (end < start) - swap(start, end); + std::swap(start, end); if (start.y == end.y) { _InvalidateTextRect(start.x, start.y, end.x, end.y); @@ -871,7 +871,7 @@ TermView::_DrawCursor() memcpy(buffer, character.bytes, bytes); buffer[bytes] = '\0'; - _DrawLinePart(fCursor.x * fFontWidth, _LineOffset(fCursor.y), + _DrawLinePart(fCursor.x * fFontWidth, (int32)_LineOffset(fCursor.y), attr, buffer, width, selected, true, this); } else { if (selected) @@ -1022,7 +1022,7 @@ TermView::Draw(BRect updateRect) continue; } - _DrawLinePart(fFontWidth * i, _LineOffset(j), + _DrawLinePart(fFontWidth * i, (int32)_LineOffset(j), attr, buf, count, insideSelection, false, this); i += count; if (i >= fTermColumns) diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 047aa24662..e8e12cfa41 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -487,7 +487,7 @@ TermWindow::MessageReceived(BMessage *message) font.SetSize(size); view->SetTermFont(&font); - PrefHandler::Default()->setInt32(PREF_HALF_FONT_SIZE, size); + PrefHandler::Default()->setInt32(PREF_HALF_FONT_SIZE, (int32)size); _ResizeView(view); break; diff --git a/src/apps/terminal/TerminalBuffer.cpp b/src/apps/terminal/TerminalBuffer.cpp index acf2d81658..8c73890f23 100644 --- a/src/apps/terminal/TerminalBuffer.cpp +++ b/src/apps/terminal/TerminalBuffer.cpp @@ -561,8 +561,7 @@ TerminalBuffer::Find(const char* _pattern, const TermPos& start, bool forward, while (*_pattern != '\0') { int32 charLen = UTF8Char::ByteCount(*_pattern); if (charLen > 0) { - pattern[patternLen].bytes = (char[]){ 0, 0, 0, 0 }; - memcpy(pattern[patternLen].bytes, _pattern, charLen); + pattern[patternLen].SetTo(_pattern, charLen); // if not case sensitive, convert to lower case if (!caseSensitive && charLen == 1) @@ -678,8 +677,7 @@ void TerminalBuffer::Insert(uchar* string, ushort attr) { // TODO: Remove! Use InsertChar instead! - UTF8Char character; - character.bytes = (char[]){ string[0], string[1], string[2], string[3] }; + UTF8Char character((const char*)string, 4); InsertChar(character, attr); } diff --git a/src/apps/terminal/UTF8Char.h b/src/apps/terminal/UTF8Char.h index bf494a59c5..6c5088fd96 100644 --- a/src/apps/terminal/UTF8Char.h +++ b/src/apps/terminal/UTF8Char.h @@ -21,6 +21,24 @@ struct UTF8Char { bytes[0] = c; } + UTF8Char(const char* c, int32 count) + { + SetTo(c, count); + } + + void SetTo(const char* c, int32 count) + { + bytes[0] = c[0]; + if (count > 1) { + bytes[1] = c[1]; + if (count > 2) { + bytes[2] = c[2]; + if (count > 3) + bytes[3] = c[3]; + } + } + } + static int32 ByteCount(char firstChar) { // Note, this does not recognize invalid chars