aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorreduz2014-02-28 14:53:01 -0200
committerreduz2014-02-28 14:53:01 -0200
commit219818075f0fd1cc052f104f7617bd1701620553 (patch)
treec5913da92cbdcd3a8394cb165a5ef3b0d622aca8 /core
parentb657d2df901fc88aa232962ff3281ece14a72abe (diff)
parent61789718733ea30c6b6844b1804920289dda3919 (diff)
downloadgodot-219818075f0fd1cc052f104f7617bd1701620553.tar.gz
godot-219818075f0fd1cc052f104f7617bd1701620553.tar.zst
godot-219818075f0fd1cc052f104f7617bd1701620553.zip
Merge pull request #147 from vinzenz/string-improvements
begins_with string version fix
Diffstat (limited to 'core')
-rw-r--r--core/ustring.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index b0f06c6ab..2384ce5bd 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -2491,19 +2491,21 @@ bool String::begins_with(const String& p_string) const {
const CharType *src=&p_string[0];
const CharType *str=&operator[](0);
- for (int i=0;i<l;i++) {
+ int i = 0;
+ for (;i<l;i++) {
if (src[i]!=str[i])
return false;
}
- return true;
+ // only if i == l the p_string matches the beginning
+ return i == l;
}
bool String::begins_with(const char* p_string) const {
int l=length();
- if (l==0)
+ if (l==0||!p_string)
return false;
const CharType *str=&operator[](0);