Project

General

Profile

Bug #13932 ยป load.patch

A fix - akihikodaki (Akihiko Odaki), 09/23/2017 04:48 PM

View differences:

load.c
430 430
	for (i = 0; ; i++) {
431 431
	    VALUE entry;
432 432
	    long index;
433
	    int found_expanded;
433 434
	    if (RB_TYPE_P(this_feature_index, T_ARRAY)) {
434 435
		if (i >= RARRAY_LEN(this_feature_index)) break;
435 436
		entry = RARRAY_AREF(this_feature_index, i);
......
443 444
	    v = RARRAY_AREF(features, index);
444 445
	    f = StringValuePtr(v);
445 446
	    if ((n = RSTRING_LEN(v)) < len) continue;
446
	    if (strncmp(f, feature, len) != 0) {
447
	    found_expanded = strncmp(f, feature, len) != 0;
448
	    if (found_expanded) {
447 449
		if (expanded) continue;
448 450
		if (!load_path) load_path = rb_get_expanded_load_path();
449 451
		if (!(p = loaded_feature_path(f, n, feature, len, type, load_path)))
450 452
		    continue;
451
		expanded = 1;
452 453
		f += RSTRING_LEN(p) + 1;
453 454
	    }
454 455
	    if (!*(e = f + len)) {
......
456 457
		return 'u';
457 458
	    }
458 459
	    if (*e != '.') continue;
459
	    if ((!rb || !ext) && (IS_SOEXT(e) || IS_DLEXT(e))) {
460
		return 's';
460
	    if (IS_SOEXT(e) || IS_DLEXT(e)) {
461
		if (!ext) {
462
		    type = 's';
463
		    continue;
464
		}
465
		if (!rb) {
466
		    return 's';
467
		}
461 468
	    }
462 469
	    if ((rb || !ext) && (IS_RBEXT(e))) {
463 470
		return 'r';
464 471
	    }
472
	    if (found_expanded) {
473
	      expanded = 1;
474
	    }
465 475
	}
466 476
    }
467 477

  
478
    if (!ext && type) {
479
      return type;
480
    }
481

  
468 482
    loading_tbl = get_loading_table();
469 483
    f = 0;
470 484
    if (!expanded) {
test/ruby/test_require.rb
251 251
    end
252 252
  end
253 253

  
254
  def test_require_twice_with_shared_object
255
    Dir.mktmpdir do |tmp|
256
      so = File.join(tmp, "very_long_file_name.so")
257
      File.write(so, "dummy");
258
      assert_file.exist?(so)
259
      req = File.join(tmp, "very_long_file_name.rb")
260
      File.write(req, "p :ok\n")
261
      assert_file.exist?(req)
262
      req[/.rb$/i] = ""
263
      assert_in_out_err(['--disable-gems'], <<-INPUT, %w(:ok), [])
264
        require "#{req}"
265
        require "#{req}"
266
      INPUT
267
    end
268
  end
269

  
254 270
  def assert_syntax_error_backtrace
255 271
    Dir.mktmpdir do |tmp|
256 272
      req = File.join(tmp, "test.rb")