Stop allocating backref strings within gsub's search loop

* internal.h: add prototype for rb_reg_search0

* re.c: rename rb_reg_search to rb_reg_search0, add set_backref_str
  argument to allow callers to indicate that they don't require the
  backref string to be allocated

* string.c: don't allocate backref str if replacement string is provided

Closes GH-578. [Bug #9676] [ruby-core:61682]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e