LPCSTR _CopyVal(LPCSTR src, xr_string& dst, char separator) { LPCSTR p; ptrdiff_t n; p = strchr(src, separator); n = (p > 0) ? (p - src) : xr_strlen(src); dst = src; dst = dst.erase(n, dst.length()); return dst.c_str(); }
bool CUILine::GetWord(Word& w, const xr_string& text, int begin) const{ if (text.empty()) return false; StrSize first, last, lastsp/*last space*/; first = text.find_first_not_of(' ', begin); last = text.find_first_of(' ', first); if( npos==last && npos==first ) return false; if( npos==last && npos!=first ) { w.pos = (int)first; w.len = (int)(text.length()-first); w.len_full = w.len; return true; } lastsp = text.find_first_not_of(' ', last); if (npos == lastsp && npos == first) // maybe we have string only with spaces { first = text.find_first_of(' ',begin); last = text.find_last_of(' ',begin); if (npos == first) //suxxx it is empty string return false; w.pos = (int)first; w.len = (int)(last - first + 1); w.len_full = w.len; return true; } if (npos == lastsp) lastsp = last; else --lastsp; if (npos == last && npos != first) last = text.size() - 1; else --last; if (npos == lastsp) lastsp = last; first = begin; w.pos = (int) first; w.len = (int)(last - first + 1); w.len_full = (int)(lastsp - first + 1); #ifdef DEBUG if (npos != first && (npos == last || npos == lastsp )) R_ASSERT2(false,"CUILine::InitPos -- impossible match"); #endif return true; }