diff options
| author | Mattias Cibien | 2016-05-11 09:22:59 +0200 |
|---|---|---|
| committer | Rémi Verschelde | 2016-05-11 09:22:59 +0200 |
| commit | 49c473bb365054969687f14ed0b55bfe3b06e637 (patch) | |
| tree | afa4e7d4814639140ee42ed196caae8ca2594a28 /core/ustring.cpp | |
| parent | 98bff2f595beda46a35ce66ac4d714fbc41ba2ba (diff) | |
| download | godot-49c473bb365054969687f14ed0b55bfe3b06e637.tar.gz godot-49c473bb365054969687f14ed0b55bfe3b06e637.tar.zst godot-49c473bb365054969687f14ed0b55bfe3b06e637.zip | |
Diffstat (limited to 'core/ustring.cpp')
| -rw-r--r-- | core/ustring.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 730f7cfa3..1f0eadc03 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2867,25 +2867,29 @@ CharType String::ord_at(int p_idx) const { return operator[](p_idx); } -String String::strip_edges() const { +String String::strip_edges(bool left, bool right) const { int len=length(); int beg=0,end=len; - for (int i=0;i<length();i++) { + if(left) { + for (int i=0;i<len;i++) { - if (operator[](i)<=32) - beg++; - else - break; + if (operator[](i)<=32) + beg++; + else + break; + } } - for (int i=(int)(length()-1);i>=0;i--) { + if(right) { + for (int i=(int)(len-1);i>=0;i--) { - if (operator[](i)<=32) - end--; - else - break; + if (operator[](i)<=32) + end--; + else + break; + } } if (beg==0 && end==len) |
