summaryrefslogtreecommitdiffstats
path: root/core/ustring.cpp
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2019-01-04 16:01:54 +0000
committerHein-Pieter van Braam <hp@tmm.cx>2019-01-04 17:48:03 +0000
commitac99ed3cda12abe155f16a96ac0c716b2dbe6231 (patch)
tree2bae704d3f5852b415555b8393ec8eddf3b00500 /core/ustring.cpp
parent1504c961125c76f007bc2ff061c3854effbe3e56 (diff)
downloadredot-engine-ac99ed3cda12abe155f16a96ac0c716b2dbe6231.tar.gz
String[size()] should return a default constructed CharType
As per the C++ standard 21.3.4.1 for std::string: Returns: If pos < size(), returns data()[pos]. Otherwise, if pos == size(), the const version returns charT(). Otherwise, the behavior is undefined. Since the behavior is undefined Godot now does the same thing for const and non-const versions of operator[]. This fixes #21242 and fixes #22221.
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r--core/ustring.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 23ea3f3617..0ff5cc77a4 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -58,6 +58,9 @@
#define IS_DIGIT(m_d) ((m_d) >= '0' && (m_d) <= '9')
#define IS_HEX_DIGIT(m_d) (((m_d) >= '0' && (m_d) <= '9') || ((m_d) >= 'a' && (m_d) <= 'f') || ((m_d) >= 'A' && (m_d) <= 'F'))
+const char CharString::_null = 0;
+const CharType String::_null = 0;
+
bool is_symbol(CharType c) {
return c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t' || c == ' ');
}