From 0f2ac5b110bd8bd971b91c3a92eaba5660431f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 22 Apr 2020 14:57:39 +0200 Subject: [PATCH] [escher/text_field] Fix std::min use --- apps/code/python_text_area.cpp | 2 +- escher/src/text_field.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/code/python_text_area.cpp b/apps/code/python_text_area.cpp index 180e5aa0d..e1fe0a923 100644 --- a/apps/code/python_text_area.cpp +++ b/apps/code/python_text_area.cpp @@ -188,7 +188,7 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char line, UTF8Helper::GlyphOffsetAtCodePoint(text, autocompleteStart), autocompleteStart, - minPointer(text + byteLength, autocompleteEnd) - autocompleteStart, + std::min(text + byteLength, autocompleteEnd) - autocompleteStart, AutocompleteColor, BackgroundColor, nullptr, diff --git a/escher/src/text_field.cpp b/escher/src/text_field.cpp index aa1d128b7..da9109d55 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -122,7 +122,7 @@ void TextField::ContentView::reinitDraftTextBuffer() { bool TextField::ContentView::insertTextAtLocation(const char * text, char * location, int textLen) { assert(m_isEditing); - int textLength = textLen < 0 ? strlen(text) : textLen; + size_t textLength = textLen < 0 ? strlen(text) : (size_t)textLen; if (m_currentDraftTextLength + textLength >= m_draftTextBufferSize || textLength == 0) { return false; } @@ -130,7 +130,7 @@ bool TextField::ContentView::insertTextAtLocation(const char * text, char * loca memmove(location + textLength, location, (s_draftTextBuffer + m_currentDraftTextLength + 1) - location); // Caution! One byte will be overridden by the null-terminating char of strlcpy - size_t copySize = std::min(textLength + 1, (s_draftTextBuffer + m_draftTextBufferSize) - location); + size_t copySize = std::min(textLength + 1, static_cast((s_draftTextBuffer + m_draftTextBufferSize) - location)); char * overridenByteLocation = location + copySize - 1; char overridenByte = *overridenByteLocation; strlcpy(location, text, copySize);