From 4a4f2479146aa33e235ed57cde311efda68d3c8f Mon Sep 17 00:00:00 2001 From: Hubert Jarosz Date: Wed, 9 Mar 2016 00:00:52 +0100 Subject: remove trailing whitespace --- core/ustring.cpp | 228 +++++++++++++++++++++++++++---------------------------- 1 file changed, 114 insertions(+), 114 deletions(-) (limited to 'core/ustring.cpp') diff --git a/core/ustring.cpp b/core/ustring.cpp index 1017fc0ca3..a9d0012ebe 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -67,14 +67,14 @@ void String::copy_from(const char *p_cstr) { len++; if (len==0) { - + resize(0); return; } - + resize(len+1); // include 0 - + CharType *dst = this->ptr(); for (int i=0;i=0 && len>p_clip_to) len=p_clip_to; - + if (len==0) { - + resize(0); return; } - + resize(len+1); set(len,0); - + CharType *dst = &operator[](0); - - + + for (int i=0;ireplace("_"," ").to_lower(); String cap; for (int i=0;i0) { - + slice[0]=_find_upper(slice[0]); if (i>0) cap+=" "; cap+=slice; } } - + return cap; } @@ -542,7 +542,7 @@ int String::get_slice_count(String p_splitter) const{ return 0; if (p_splitter.empty()) return 0; - + int pos=0; int slices=1; @@ -559,7 +559,7 @@ String String::get_slice(String p_splitter, int p_slice) const { if (empty() || p_splitter.empty()) return ""; - + int pos=0; int prev_pos=0; // int slices=1; @@ -844,7 +844,7 @@ int String::length() const { const CharType * String::c_str() const { static const CharType zero=0; - + return size()?&operator[](0):&zero; } @@ -867,10 +867,10 @@ String String::md5(const uint8_t *p_md5) { } String String::chr(CharType p_char) { - + CharType c[2]={p_char,0}; return String(c); - + } String String::num(double p_num,int p_decimals) { @@ -1014,7 +1014,7 @@ String String::num(double p_num,int p_decimals) { String decimal; for (int i=0;i='0' && c<='9') reading=READING_INT; // let it fallthrough @@ -2228,26 +2228,26 @@ double String::to_double() const { } else { break; } - } + } case READING_INT: { - + if (c>='0' && c<='9') { - + integer*=10; - integer+=c-'0'; - } else if (c=='.') { + integer+=c-'0'; + } else if (c=='.') { reading=READING_DEC; } else if (c=='e') { reading=READING_EXP; } else { reading=READING_DONE; } - + } break; case READING_DEC: { - + if (c>='0' && c<='9') { - + decimal+=(c-'0')*decimal_mult; decimal_mult*=0.1; } else if (c=='e') { @@ -2255,12 +2255,12 @@ double String::to_double() const { } else { reading=READING_DONE; } - + } break; case READING_EXP: { - + if (c>='0' && c<='9') { - + exp*=10.0; exp+=(c-'0'); } else if (c=='-' && exp==0) { @@ -2274,14 +2274,14 @@ double String::to_double() const { } break; } } - + return sign*(integer+decimal)*Math::pow(10,exp_sign*exp); #endif #if 0 double ret=sign*(integer+decimal)*Math::pow(10,exp_sign*exp); - + print_line(*this +" == "+rtos(ret)); return ret; #endif @@ -2308,14 +2308,14 @@ String operator+(CharType p_chr, const String& p_str) { } uint32_t String::hash(const char* p_cstr) { - + uint32_t hashv = 5381; uint32_t c; - + while ((c = *p_cstr++)) hashv = ((hashv << 5) + hashv) + c; /* hash * 33 + c */ - - return hashv; + + return hashv; } uint32_t String::hash(const char* p_cstr,int p_len) { @@ -2348,19 +2348,19 @@ uint32_t String::hash(const CharType* p_cstr) { } uint32_t String::hash() const { - + /* simple djb2 hashing */ - + const CharType * chr = c_str(); uint32_t hashv = 5381; uint32_t c; - + while ((c = *chr++)) hashv = ((hashv << 5) + hashv) + c; /* hash * 33 + c */ - + return hashv; - - + + } uint64_t String::hash64() const { @@ -2442,16 +2442,16 @@ String String::substr(int p_from,int p_chars) const{ } int String::find_last(String p_str) const { - + int pos=-1; int findfrom=0; int findres=-1; while((findres=find(p_str,findfrom))!=-1) { - + pos=findres; findfrom=pos+1; } - + return pos; } int String::find(String p_str,int p_from) const { @@ -2708,48 +2708,48 @@ bool String::ends_with(const String& p_string) const { } bool String::begins_with(const String& p_string) const { - + if (p_string.length() > length()) return false; - + int l=p_string.length(); if (l==0) return true; - + const CharType *src=&p_string[0]; const CharType *str=&operator[](0); - + int i = 0; for (;i=size()) return *this; - + if (p_pos<0) return ""; @@ -2868,26 +2868,26 @@ CharType String::ord_at(int p_idx) const { } String String::strip_edges() const { - + int len=length(); int beg=0,end=len; - + for (int i=0;i=0;i--) { - + if (operator[](i)<=32) end--; else break; } - + if (beg==0 && end==len) return *this; @@ -3012,7 +3012,7 @@ String String::humanize_size(size_t p_size) { int digits=prefix_idx>0?_humanize_digits(p_size/_div):0; double divisor = prefix_idx>0?_div:1; - + return String::num(p_size/divisor,digits)+prefix[prefix_idx]; } bool String::is_abs_path() const { @@ -3587,12 +3587,12 @@ String String::get_file() const { } String String::extension() const { - + int pos = find_last("."); if (pos<0) return *this; - - return substr( pos+1, length() ); + + return substr( pos+1, length() ); } String String::plus_file(const String& p_file) const { @@ -3749,7 +3749,7 @@ String String::sprintf(const Array& values, bool* error) const { if (!values[value_index].is_num()) { return "a number is required"; } - + int64_t value = values[value_index]; int base; bool capitalize = false; @@ -3811,7 +3811,7 @@ String String::sprintf(const Array& values, bool* error) const { formatted += str; ++value_index; in_format = false; - + break; } case 's': { // String -- cgit v1.2.3