summaryrefslogtreecommitdiff
path: root/Source/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Library')
-rw-r--r--Source/Library/Common/BasicString.class.cpp5
-rw-r--r--Source/Library/Common/BasicString.class.h2
-rw-r--r--Source/Library/Common/String.class.cpp5
-rw-r--r--Source/Library/Common/String.class.h2
4 files changed, 8 insertions, 6 deletions
diff --git a/Source/Library/Common/BasicString.class.cpp b/Source/Library/Common/BasicString.class.cpp
index 58fa926..ddb4e2c 100644
--- a/Source/Library/Common/BasicString.class.cpp
+++ b/Source/Library/Common/BasicString.class.cpp
@@ -173,9 +173,10 @@ Vector< BasicString<T> > BasicString<T>::split(T sep) const {
}
template <typename T>
-BasicString<T> BasicString<T>::substr(s32int start, u32int size) {
+BasicString<T> BasicString<T>::substr(s32int start, s32int size) {
+ if (size == 0) return BasicString<T>();
if (start < 0) start = m_length - start;
- if (size == 0) size = m_length - start;
+ if (size == -1) size = m_length - start;
BasicString<T> ret;
ret.m_string = new T[size + 1];
ret.m_length = size;
diff --git a/Source/Library/Common/BasicString.class.h b/Source/Library/Common/BasicString.class.h
index be74cf3..03d82c1 100644
--- a/Source/Library/Common/BasicString.class.h
+++ b/Source/Library/Common/BasicString.class.h
@@ -46,7 +46,7 @@ class BasicString {
bool contains(const T& chr) const;
Vector< BasicString<T> > split(T sep) const;
- BasicString<T> substr(s32int start, u32int size = 0);
+ BasicString<T> substr(s32int start, s32int size = -1);
};
#include "BasicString.class.cpp"
diff --git a/Source/Library/Common/String.class.cpp b/Source/Library/Common/String.class.cpp
index da2b93e..fe851bd 100644
--- a/Source/Library/Common/String.class.cpp
+++ b/Source/Library/Common/String.class.cpp
@@ -191,9 +191,10 @@ Vector<String> String::split(WChar c) const {
return ret;
}
-String String::substr(s32int start, u32int size) {
+String String::substr(s32int start, s32int size) {
+ if (size == 0) return String();
if (start < 0) start = m_length - start;
- if (size == 0) size = m_length - start;
+ if (size == -1) size = m_length - start;
String ret;
ret.m_string = new WChar[size + 1];
ret.m_length = size;
diff --git a/Source/Library/Common/String.class.h b/Source/Library/Common/String.class.h
index 473624b..b623fb2 100644
--- a/Source/Library/Common/String.class.h
+++ b/Source/Library/Common/String.class.h
@@ -43,7 +43,7 @@ class String : public BasicString<WChar> {
Vector<String> split(WChar c) const;
- String substr(s32int start, u32int size = 0);
+ String substr(s32int start, s32int size = -1);
};
#endif