string.c:1477
static VALUE
get_pat(pat, quote)
    VALUE pat;
    int quote;
{
    VALUE val;

    switch (TYPE(pat)) {
      case T_REGEXP:
	return pat;

      case T_STRING:
	break;

      default:
	val = rb_check_string_type(pat);
	if (NIL_P(val)) {
	    Check_Type(pat, T_REGEXP);
	}
	pat = val;
    }

    if (quote) {
	val = rb_reg_quote(pat);
#if RUBY_VERSION_CODE < 181
	if (val != pat && rb_str_cmp(val, pat) != 0) {
	    rb_warn("string pattern instead of regexp; metacharacters no longer effective");
	}
#endif
	pat = val;
    }

    return rb_reg_regcomp(pat);
}
