Logo Search packages:      
Sourcecode: osb-jscore version File versions  Download package

int KJS::UString::rfind ( const UString f,
int  pos 
) const

Returns:
Position of first occurrence of f searching backwards from position pos. -1 if the search was not successful.

Definition at line 1021 of file ustring.cpp.

References data(), and size().

{
  int sz = size();
  int fsz = f.size();
  if (sz < fsz)
    return -1;
  if (pos < 0)
    pos = 0;
  if (pos > sz - fsz)
    pos = sz - fsz;
  if (fsz == 0)
    return pos;
  long fsizeminusone = (fsz - 1) * sizeof(UChar);
  const UChar *fdata = f.data();
  for (const UChar *c = data() + pos; c >= data(); c--) {
    if (*c == *fdata && !memcmp(c + 1, fdata + 1, fsizeminusone))
      return (c-data());
  }

  return -1;
}


Generated by  Doxygen 1.6.0   Back to index