From 0b8a785539ce7823855944aeff33aad3773aad6a Mon Sep 17 00:00:00 2001 From: Tomasz Chabora Date: Fri, 3 May 2019 14:21:04 +0200 Subject: Make second parameter of substr optional --- core/ustring.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core/ustring.cpp') 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 ""; -- cgit v1.2.3