diff --git a/Jupiter/CString_Imp.h b/Jupiter/CString_Imp.h index c588e94..ccb73dd 100644 --- a/Jupiter/CString_Imp.h +++ b/Jupiter/CString_Imp.h @@ -442,7 +442,7 @@ template Jupiter::CString_Loose::CString_Loose(const T *in) : Jup { Jupiter::String_Type::length = Jupiter::strlen(in); Jupiter::CString_Loose::strSize = getPowerTwo32(Jupiter::String_Type::length + 1); - if (Jupiter::CString_Loose::strSize < 8) Jupiter::CString_Loose::strSize = 8; + if (Jupiter::CString_Loose::strSize < Jupiter::CString_Loose::start_size) Jupiter::CString_Loose::strSize = Jupiter::CString_Loose::start_size; Jupiter::Shift_String_Type::base = new T[Jupiter::CString_Loose::strSize]; Jupiter::String_Type::str = Jupiter::Shift_String_Type::base; Jupiter::strcpy(Jupiter::String_Type::str, in); @@ -495,7 +495,7 @@ template Jupiter::CString_Loose Jupiter::CString_Loose::Format template Jupiter::CString_Loose Jupiter::CString_Loose::substring(size_t pos) const { - return Jupiter::CString_Loose::substring(*this, pos, Jupiter::String_Type::length - pos); + return Jupiter::CString_Loose::substring(*this, pos); } template Jupiter::CString_Loose Jupiter::CString_Loose::substring(size_t pos, size_t length) const @@ -507,10 +507,8 @@ template Jupiter::CString_Loose Jupiter::CString_Loose::substr { if (pos > in.size()) return Jupiter::CString_Loose(); Jupiter::CString_Loose r = Jupiter::CString_Loose(in.size() - pos); - size_t index; - for (index = pos; pos + index != in.size() && in.get(index) != 0; index++) r.str[index - pos] = in.get(index); - r.str[index - pos] = 0; - r.length = index; + for (r.length = 0; pos + r.length != in.size() && in.get(r.length) != 0; r.length++) r.str[r.length] = in.get(pos + r.length); + r.str[r.length] = 0; return r; }