Feature #10927 ยป 0001-Add-a-default-empty-string-to-string-replacements.patch
string.c | ||
---|---|---|
/*
|
||
* call-seq:
|
||
* str.sub!(pattern, replacement) -> str or nil
|
||
* str.sub!(pattern, replacement='') -> str or nil
|
||
* str.sub!(pattern) {|match| block } -> str or nil
|
||
*
|
||
* Performs the same substitution as String#sub in-place.
|
||
... | ... | |
int iter = 0;
|
||
int tainted = 0;
|
||
long plen;
|
||
int min_arity = rb_block_given_p() ? 1 : 2;
|
||
long beg;
|
||
rb_check_arity(argc, min_arity, 2);
|
||
rb_check_arity(argc, 1, 2);
|
||
if (argc == 1) {
|
||
iter = 1;
|
||
if (rb_block_given_p()) {
|
||
iter = 1;
|
||
}
|
||
else {
|
||
repl = rb_str_new("", 0);
|
||
}
|
||
}
|
||
else {
|
||
repl = argv[1];
|
||
... | ... | |
/*
|
||
* call-seq:
|
||
* str.sub(pattern, replacement) -> new_str
|
||
* str.sub(pattern, replacement='') -> new_str
|
||
* str.sub(pattern, hash) -> new_str
|
||
* str.sub(pattern) {|match| block } -> new_str
|
||
*
|
||
... | ... | |
switch (argc) {
|
||
case 1:
|
||
RETURN_ENUMERATOR(str, argc, argv);
|
||
mode = ITER;
|
||
if (rb_block_given_p()) {
|
||
RETURN_ENUMERATOR(str, argc, argv);
|
||
mode = ITER;
|
||
}
|
||
else {
|
||
repl = rb_str_new("", 0);
|
||
}
|
||
break;
|
||
case 2:
|
||
repl = argv[1];
|