diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-08 15:38:44 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-08 15:38:44 +0200 |
commit | 0e75aba7c39c7a2d3b0becc2416aa0e251d62070 (patch) | |
tree | 19bc08a69423db6ab1c6669c06eaab81f494a564 /Libraries/LibGUI/GTextEditor.cpp | |
parent | 567551bc12945c25b49c65579ceb545668dbb7eb (diff) | |
download | serenity-0e75aba7c39c7a2d3b0becc2416aa0e251d62070.zip |
StringView: Rename characters() to characters_without_null_termination().
This should make you think twice before trying to use the const char* from
a StringView as if it's a null-terminated string.
Diffstat (limited to 'Libraries/LibGUI/GTextEditor.cpp')
-rw-r--r-- | Libraries/LibGUI/GTextEditor.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibGUI/GTextEditor.cpp b/Libraries/LibGUI/GTextEditor.cpp index 225e942c70..3feb6d6d78 100644 --- a/Libraries/LibGUI/GTextEditor.cpp +++ b/Libraries/LibGUI/GTextEditor.cpp @@ -68,7 +68,7 @@ void GTextEditor::create_actions() void GTextEditor::set_text(const StringView& text) { - if (is_single_line() && text.length() == m_lines[0]->length() && !memcmp(text.characters(), m_lines[0]->characters(), text.length())) + if (is_single_line() && text.length() == m_lines[0]->length() && !memcmp(text.characters_without_null_termination(), m_lines[0]->characters(), text.length())) return; m_selection.clear(); @@ -783,14 +783,14 @@ void GTextEditor::Line::clear() void GTextEditor::Line::set_text(const StringView& text) { - if (text.length() == length() && !memcmp(text.characters(), characters(), length())) + if (text.length() == length() && !memcmp(text.characters_without_null_termination(), characters(), length())) return; if (text.is_empty()) { clear(); return; } m_text.resize(text.length() + 1); - memcpy(m_text.data(), text.characters(), text.length() + 1); + memcpy(m_text.data(), text.characters_without_null_termination(), text.length() + 1); } int GTextEditor::Line::width(const Font& font) const @@ -844,7 +844,7 @@ void GTextEditor::Line::truncate(int length) bool GTextEditor::write_to_file(const StringView& path) { - int fd = open(path.characters(), O_WRONLY | O_CREAT | O_TRUNC, 0666); + int fd = open(String(path).characters(), O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd < 0) { perror("open"); return false; |