fixed a bug in r_str_replace

There's a bug - wrong computation of the next offset from which you have to start searching for the next occurrence of the string.