Fixed too many little issues, check the issues closed today.

This commit is contained in:
Juan Linietsky
2014-09-21 01:43:42 -03:00
parent c5b905fca8
commit 11a5ed508b
24 changed files with 306 additions and 44 deletions

View File

@@ -2467,13 +2467,8 @@ int String::findn(String p_str,int p_from) const {
};
CharType src=srcd[read_pos];
CharType dst=p_str[j];
if (src>='a' && src<='z')
src-='a'-'A';
if (dst>='a' && dst<='z')
dst-='a'-'A';
CharType src=_find_lower(srcd[read_pos]);
CharType dst=_find_lower(p_str[j]);
if (src!=dst) {
found=false;
@@ -2490,10 +2485,101 @@ int String::findn(String p_str,int p_from) const {
int String::rfind(String p_str,int p_from) const {
//stabilish a limit
int limit = length()-p_str.length();
if (limit<0)
return -1;
//stabilish a starting point
if (p_from<0)
p_from=limit;
else if (p_from>limit)
p_from=limit;
int src_len=p_str.length();
int len=length();
if(src_len==0 || len==0)
return -1; //wont find anything!
const CharType *src = c_str();
for (int i=p_from;i>=0;i--) {
bool found=true;
for (int j=0;j<src_len;j++) {
int read_pos=i+j;
if (read_pos>=len) {
ERR_PRINT("read_pos>=len");
return -1;
};
if (src[read_pos]!=p_str[j]) {
found=false;
break;
}
}
if (found)
return i;
}
return -1;
}
int String::rfindn(String p_str,int p_from) const {
//stabilish a limit
int limit = length()-p_str.length();
if (limit<0)
return -1;
//stabilish a starting point
if (p_from<0)
p_from=limit;
else if (p_from>limit)
p_from=limit;
int src_len=p_str.length();
int len=length();
if(src_len==0 || len==0)
return -1; //wont find anything!
const CharType *src = c_str();
for (int i=p_from;i>=0;i--) {
bool found=true;
for (int j=0;j<src_len;j++) {
int read_pos=i+j;
if (read_pos>=len) {
ERR_PRINT("read_pos>=len");
return -1;
};
CharType srcc=_find_lower(src[read_pos]);
CharType dstc=_find_lower(p_str[j]);
if (srcc!=dstc) {
found=false;
break;
}
}
if (found)
return i;
}
return -1;
}