regex.c:3102
int
re_adjust_startpos(bufp, string, size, startpos, range)
     struct re_pattern_buffer *bufp;
     const char *string;
     int size, startpos, range;
{
  /* Update the fastmap now if not correct already.  */
  if (!bufp->fastmap_accurate) {
    re_compile_fastmap(bufp);
  }

  /* Adjust startpos for mbc string */
  if (current_mbctype && startpos>0 && !(bufp->options&RE_OPTIMIZE_BMATCH)) {
    int i = mbc_startpos(string, startpos);

    if (i < startpos) {
      if (range > 0) {
	startpos = i + mbclen(string[i]);
      }
      else {
	int len = mbclen(string[i]);
	if (i + len <= startpos)
	  startpos = i + len;
	else
	  startpos = i;
      }
    }
  }
  return startpos;
}
