FYI: here are my routines; (try to re-use what i can) :P

----

// look for a specific character in the memory buffer, starting at end
char *
_MemRChr(void *p, char chr, uint32 count)
{
  char *pos;
  char *x;
  int   i;

  // default return value
  pos = NULL;

  // pre-condition (cannot have null pointer)
  if ((p != NULL) && (count != 0))
  {
    // use temporary variables for processing
    x = (char *)p;
    x += count;

    // lets scan the memory buffer
    i = count;
    do
    {
      if (*x == chr) { pos = x; break; }
      x--;
    } while (--i);
  }

  return pos;
}

and...

char *
_StrRChr(char *s, char chr)
{
  return (char *)_StrNRChr((void *)s, chr, _StrLen(s));
}

char *
_StrNRChr(char *s, char chr, uint32 count)
{
  return (char *)_MemRChr((void *)s, chr, (uint32)(MIN(count, _StrLen(s))));
}

-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to