From: Andrew C. <ac...@us...> - 2005-03-19 03:46:06
|
Update of /cvsroot/planeshift/planeshift/src/common/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17301/src/common/util Modified Files: psstring.cpp psstring.h Log Message: Removed my test code from psString. Chat history only pushes new entry if different from the last one. Index: psstring.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/psstring.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** psstring.cpp 17 Mar 2005 23:06:36 -0000 1.20 --- psstring.cpp 19 Mar 2005 03:45:53 -0000 1.21 *************** *** 73,132 **** } - int FindSubString(csStringBase& src, const char *sub, size_t start, bool caseInsense, bool wholeWord) - { - const char *myData = src.GetData(); - - size_t lensub = strlen(sub); - if ( src.IsEmpty() || !lensub || lensub>src.Length() ) - return -1; - - if ( caseInsense ) - { - while ( start <= src.Length() - lensub ) - { - if (strncasecmp(sub, myData + start, lensub) != 0) - start++; - else - { - if (wholeWord) - { - if ((start == 0 || !isalnum(myData[start])) && - (!isalnum(myData[start+lensub]))) - return start; - else - start++; - } - else - return start; - } - } - return -1; - } - else - { - while (true) - { - char* pWhere = strstr(myData + start, sub); - if (pWhere) - { - if (!wholeWord) - return pWhere - myData; - else - { - start = pWhere - myData; - - if ((start == 0 || !isalnum(myData[start])) && - (!isalnum(myData[start+lensub]))) - return start; - else - start++; - } - } - else - return -1; - } - } - } - int psString::FindSubString(const char *sub, size_t start, bool caseInsense, bool wholeWord) { --- 73,76 ---- *************** *** 255,287 **** - void GetWord(csStringBase& src, size_t pos, csStringBase &buff, bool wantPunct) - { - size_t start = pos; - size_t end = pos; - - if (pos > src.Length()) - { - buff=""; - return; - } - - const char *myData = src.GetData(); - - // go back to the beginning of the word - while (start > 0 && (!isspace(myData[start])) && - (wantPunct || !ispunct(myData[start])) - ) - start--; - if (isspace(myData[start]) || (!wantPunct && ispunct(myData[start]))) - start++; - - // search end of the word - while (end<src.Length() && (!isspace(myData[end])) && - (wantPunct || !ispunct(myData[end])) - ) - end++; - - GetSubString(src, buff,start,end); - } --- 199,202 ---- *************** *** 348,366 **** - bool ReplaceAllSubString(csStringBase& src, const char* what, const char* with, bool wholeWord ) - { - int where = FindSubString(src, what,0,XML_CASE_INSENSITIVE,wholeWord); - size_t len = strlen(what); - - while ( where > -1 ) - { - size_t pos = where; - src.DeleteAt( where, len ); - src.Insert( pos, with ); - where = FindSubString(src, what, where+strlen(with) ); - } - - return true; - } --- 263,266 ---- Index: psstring.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/psstring.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** psstring.h 17 Mar 2005 23:06:36 -0000 1.17 --- psstring.h 19 Mar 2005 03:45:53 -0000 1.18 *************** *** 28,45 **** #define XML_CASE_SENSITIVE false - enum - { - NO_PUNCT=0, - INCLUDE_PUNCT=1 - }; - - void GetWord( csStringBase &src, size_t pos, csStringBase& buff, bool wantPunct=INCLUDE_PUNCT); - void GetSubString( csStringBase& src, csStringBase& str, size_t from, size_t to); - bool ReplaceAllSubString( csStringBase& src, const char* what, const char* with,bool wholeWord); - int FindSubString(csStringBase& src, const char *sub, size_t start=0, bool caseInsense=XML_CASE_SENSITIVE,bool wholeWord=false); - - - - class psString : public csString { --- 28,31 ---- |