Project

General

Profile

Feature #10927 ยป 0001-Add-a-default-empty-string-to-string-replacements.patch

zimbatm (zimba tm), 03/02/2015 04:18 PM

View differences:

string.c
4087 4087

  
4088 4088
/*
4089 4089
 *  call-seq:
4090
 *     str.sub!(pattern, replacement)          -> str or nil
4090
 *     str.sub!(pattern, replacement='')       -> str or nil
4091 4091
 *     str.sub!(pattern) {|match| block }      -> str or nil
4092 4092
 *
4093 4093
 *  Performs the same substitution as String#sub in-place.
......
4103 4103
    int iter = 0;
4104 4104
    int tainted = 0;
4105 4105
    long plen;
4106
    int min_arity = rb_block_given_p() ? 1 : 2;
4107 4106
    long beg;
4108 4107

  
4109
    rb_check_arity(argc, min_arity, 2);
4108
    rb_check_arity(argc, 1, 2);
4110 4109
    if (argc == 1) {
4111
	iter = 1;
4110
       if (rb_block_given_p()) {
4111
          iter = 1;
4112
       }
4113
       else {
4114
          repl = rb_str_new("", 0);
4115
       }
4112 4116
    }
4113 4117
    else {
4114 4118
	repl = argv[1];
......
4210 4214

  
4211 4215
/*
4212 4216
 *  call-seq:
4213
 *     str.sub(pattern, replacement)         -> new_str
4217
 *     str.sub(pattern, replacement='')      -> new_str
4214 4218
 *     str.sub(pattern, hash)                -> new_str
4215 4219
 *     str.sub(pattern) {|match| block }     -> new_str
4216 4220
 *
......
4271 4275

  
4272 4276
    switch (argc) {
4273 4277
      case 1:
4274
	RETURN_ENUMERATOR(str, argc, argv);
4275
	mode = ITER;
4278
        if (rb_block_given_p()) {
4279
          RETURN_ENUMERATOR(str, argc, argv);
4280
          mode = ITER;
4281
        }
4282
        else {
4283
          repl = rb_str_new("", 0);
4284
        }
4276 4285
	break;
4277 4286
      case 2:
4278 4287
	repl = argv[1];
4279
-