Fix rare undefined behaviors in replace-match

* src/search.c (Freplace_match): Simplify by caching search_regs
components.  Fix sanity check for out-of-range subscripts;
it incorrectly allowed negative subscripts, subscripts
equal to search_regs.num_regs, and it had undefined
behavior for subscripts outside ptrdiff_t range.
Improve wording of newly-introduced replace-match diagnostic.
Rework use of opoint, to avoid setting point to an out-of-range value
in rare cases involving modification hooks.
1 job for master in 90 minutes and 2 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Test
failed #2873
test-all

01:30:02

 
Name Stage Failure
failed
test-all Test The script exceeded the maximum execution time set for the job
make -C test check-expensive
make[1]: Entering directory '/builds/emacs/emacs/test'
rm -f ./*.tmp
make[2]: Entering directory '/builds/emacs/emacs/test'
make[3]: Entering directory '/builds/emacs/emacs/test'
ELC lisp/net/tramp-tests.elc
GEN lisp/net/tramp-tests.log
Pulling docker image gitlab/gitlab-runner-helper:x86_64-d0b76032 ...
ERROR: Job failed: execution took longer than 1h30m0s seconds