diff options
author | Tomasz Chabora <kobewi4e@gmail.com> | 2019-05-03 14:21:04 +0200 |
---|---|---|
committer | Tomasz Chabora <kobewi4e@gmail.com> | 2019-05-03 19:46:56 +0200 |
commit | 0b8a785539ce7823855944aeff33aad3773aad6a (patch) | |
tree | 4b461230087794549720f500580cabfdf32afff6 /core/ustring.cpp | |
parent | 913620a9b804b10a880f6274df1d8ef44c27cb54 (diff) | |
download | redot-engine-0b8a785539ce7823855944aeff33aad3773aad6a.tar.gz |
Make second parameter of substr optional
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r-- | core/ustring.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 78feddb229..902976751f 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2292,6 +2292,9 @@ String String::insert(int p_at_pos, const String &p_string) const { } String String::substr(int p_from, int p_chars) const { + if (p_chars == -1) + p_chars = length() - p_from; + if (empty() || p_from < 0 || p_from >= length() || p_chars <= 0) return ""; |