diff --git a/test/gdbm/test_gdbm.rb b/test/gdbm/test_gdbm.rb index 621101c9b3..38d97c1605 100644 --- a/test/gdbm/test_gdbm.rb +++ b/test/gdbm/test_gdbm.rb @@ -147,14 +147,14 @@ if defined? GDBM def test_s_open_lock return unless have_fork? # snip this test pid = fork() { - assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644)) + assert_instance_of(GDBM, GDBM.open("#{@tmpdir}/#{@prefix}", 0644)) sleep 2 } begin sleep 1 assert_raise(Errno::EWOULDBLOCK) { begin - assert_instance_of(GDBM, gdbm2 = GDBM.open("#{@tmpdir}/#{@prefix}", 0644)) + assert_instance_of(GDBM, GDBM.open("#{@tmpdir}/#{@prefix}", 0644)) rescue Errno::EAGAIN, Errno::EACCES raise Errno::EWOULDBLOCK end @@ -187,7 +187,7 @@ if defined? GDBM return unless have_fork? # snip this test pid = fork() { - assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644, + assert_instance_of(GDBM, GDBM.open("#{@tmpdir}/#{@prefix}", 0644, GDBM::NOLOCK)) sleep 2 } @@ -202,10 +202,10 @@ if defined? GDBM gdbm2.close if gdbm2 end - p Dir.glob("#{@tmpdir}/#{@prefix}*") if $DEBUG + STDERR.puts Dir.glob("#{@tmpdir}/#{@prefix}*") if $DEBUG pid = fork() { - assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644)) + assert_instance_of(GDBM, GDBM.open("#{@tmpdir}/#{@prefix}", 0644)) sleep 2 } begin diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 2f8ec49411..91c0792c33 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -44,9 +44,9 @@ class TestEncodingConverter < Test::Unit::TestCase def test_asciicompat_encoding_iso2022jp acenc = Encoding::Converter.asciicompat_encoding("ISO-2022-JP") - str = "\e$B~~\(B".force_encoding("iso-2022-jp") + str = "\e$B~~\e(B".force_encoding("iso-2022-jp") str2 = str.encode(acenc) - str3 = str.encode("ISO-2022-JP") + str3 = str2.encode("ISO-2022-JP") assert_equal(str, str3) end @@ -147,7 +147,7 @@ class TestEncodingConverter < Test::Unit::TestCase def test_nil_source_buffer ec = Encoding::Converter.new("UTF-8", "EUC-JP") - ret = ec.primitive_convert(nil, dst="", nil, 10) + ret = ec.primitive_convert(nil, "", nil, 10) assert_equal(:finished, ret) end @@ -475,44 +475,44 @@ class TestEncodingConverter < Test::Unit::TestCase def test_errinfo_invalid_euc_jp ec = Encoding::Converter.new("EUC-JP", "Shift_JIS") - ec.primitive_convert(src="\xff", dst="", nil, 10) + ec.primitive_convert("\xff", "", nil, 10) assert_errinfo(:invalid_byte_sequence, "EUC-JP", "Shift_JIS", "\xFF", "", ec) end def test_errinfo_invalid_euc_jp2 ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - ec.primitive_convert(src="\xff", dst="", nil, 10) + ec.primitive_convert("\xff", "", nil, 10) assert_errinfo(:invalid_byte_sequence, "EUC-JP", "UTF-8", "\xFF", "", ec) end def test_errinfo_undefined_hiragana ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - ec.primitive_convert(src="\xa4\xa2", dst="", nil, 10) + ec.primitive_convert("\xa4\xa2", "", nil, 10) assert_errinfo(:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE3\x81\x82", "", ec) end def test_errinfo_invalid_partial_character ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - ec.primitive_convert(src="\xa4", dst="", nil, 10) + ec.primitive_convert("\xa4", "", nil, 10) assert_errinfo(:incomplete_input, "EUC-JP", "UTF-8", "\xA4", "", ec) end def test_errinfo_valid_partial_character ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") - ec.primitive_convert(src="\xa4", dst="", nil, 10, :partial_input=>true) + ec.primitive_convert("\xa4", "", nil, 10, :partial_input=>true) assert_errinfo(:source_buffer_empty, nil, nil, nil, nil, ec) end def test_errinfo_invalid_utf16be ec = Encoding::Converter.new("UTF-16BE", "UTF-8") - ec.primitive_convert(src="\xd8\x00\x00@", dst="", nil, 10) + ec.primitive_convert(src="\xd8\x00\x00@", "", nil, 10) assert_errinfo(:invalid_byte_sequence, "UTF-16BE", "UTF-8", "\xD8\x00", "\x00", ec) assert_equal("@", src) end def test_errinfo_invalid_utf16le ec = Encoding::Converter.new("UTF-16LE", "UTF-8") - ec.primitive_convert(src="\x00\xd8@\x00", dst="", nil, 10) + ec.primitive_convert(src="\x00\xd8@\x00", "", nil, 10) assert_errinfo(:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "@\x00", ec) assert_equal("", src) end @@ -599,7 +599,7 @@ class TestEncodingConverter < Test::Unit::TestCase def test_putback2 ec = Encoding::Converter.new("utf-16le", "euc-jp") - ret = ec.primitive_convert(src="\x00\xd8\x21\x00", dst="", nil, nil) + ret = ec.primitive_convert("\x00\xd8\x21\x00", "", nil, nil) assert_equal(:invalid_byte_sequence, ret) assert_equal("\x00".force_encoding("utf-16le"), ec.putback(1)) assert_equal("\x21".force_encoding("utf-16le"), ec.putback(1)) @@ -705,20 +705,20 @@ class TestEncodingConverter < Test::Unit::TestCase def test_last_error1 ec = Encoding::Converter.new("sjis", "euc-jp") assert_equal(nil, ec.last_error) - assert_equal(:incomplete_input, ec.primitive_convert(src="fo\x81", dst="", nil, nil)) + assert_equal(:incomplete_input, ec.primitive_convert("fo\x81", "", nil, nil)) assert_kind_of(Encoding::InvalidByteSequenceError, ec.last_error) end def test_last_error2 ec = Encoding::Converter.new("sjis", "euc-jp") - assert_equal("fo", ec.convert(src="fo\x81")) + assert_equal("fo", ec.convert("fo\x81")) assert_raise(Encoding::InvalidByteSequenceError) { ec.finish } assert_kind_of(Encoding::InvalidByteSequenceError, ec.last_error) end def test_us_ascii ec = Encoding::Converter.new("UTF-8", "US-ASCII") - ec.primitive_convert(src="\u{3042}", dst="") + ec.primitive_convert("\u{3042}", "") err = ec.last_error assert_kind_of(Encoding::UndefinedConversionError, err) assert_equal("\u{3042}", err.error_char) @@ -726,7 +726,7 @@ class TestEncodingConverter < Test::Unit::TestCase def test_88591 ec = Encoding::Converter.new("UTF-8", "ISO-8859-1") - ec.primitive_convert(src="\u{3042}", dst="") + ec.primitive_convert("\u{3042}", "") err = ec.last_error assert_kind_of(Encoding::UndefinedConversionError, err) assert_equal("\u{3042}", err.error_char) diff --git a/test/test_securerandom.rb b/test/test_securerandom.rb index be951ea722..f3e1bf0afc 100644 --- a/test/test_securerandom.rb +++ b/test/test_securerandom.rb @@ -87,7 +87,13 @@ end f << 'raise LoadError' } $LOAD_PATH.unshift(dir) - require 'securerandom' + v = $VERBOSE + begin + $VERBOSE = false + require 'securerandom' + ensure + $VERBOSE = v + end test_s_random_bytes end ensure diff --git a/tool/compile_prelude.rb b/tool/compile_prelude.rb index 1047e418b5..4f63b798c4 100755 --- a/tool/compile_prelude.rb +++ b/tool/compile_prelude.rb @@ -75,7 +75,7 @@ class Prelude end def emit(outfile) - init_name = outfile[/\w+(?=_prelude.c\b)/] || 'prelude' + @init_name = outfile[/\w+(?=_prelude.c\b)/] || 'prelude' erb = ERB.new(<<'EOS', nil, '%') /* -*-c-*- THIS FILE WAS AUTOGENERATED BY tool/compile_prelude.rb. DO NOT EDIT. @@ -152,7 +152,7 @@ prelude_require(VALUE self, VALUE nth) % end void -Init_<%=init_name%>(void) +Init_<%=@init_name%>(void) { % if @have_sublib or @need_ruby_prefix struct prelude_env memo; diff --git a/vm_exec.c b/vm_exec.c index e72bc487df..6bd4f4e735 100644 --- a/vm_exec.c +++ b/vm_exec.c @@ -14,10 +14,10 @@ #if VMDEBUG > 0 #define DECL_SC_REG(type, r, reg) register type reg_##r -#elif __GNUC__ && __x86_64__ +#elif defined(__GNUC__) && defined(_x86_64__) #define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("r" reg) -#elif __GNUC__ && __i386__ +#elif defined(__GNUC__) && defined(__i386__) #define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("e" reg) #else @@ -41,12 +41,12 @@ vm_exec_core(rb_thread_t *th, VALUE initial) #endif #endif -#if __GNUC__ && __i386__ +#if defined(__GNUC__) && defined(__i386__) DECL_SC_REG(VALUE *, pc, "di"); DECL_SC_REG(rb_control_frame_t *, cfp, "si"); #define USE_MACHINE_REGS 1 -#elif __GNUC__ && __x86_64__ +#elif defined(__GNUC__) && defined(__x86_64__) DECL_SC_REG(VALUE *, pc, "14"); DECL_SC_REG(rb_control_frame_t *, cfp, "15"); #define USE_MACHINE_REGS 1 diff --git a/vm_exec.h b/vm_exec.h index 4f8b030e68..2c1e2d5527 100644 --- a/vm_exec.h +++ b/vm_exec.h @@ -60,7 +60,7 @@ typedef rb_iseq_t *ISEQ; /* #define throwdebug printf */ /************************************************/ -#if DISPATCH_XXX +#if defined(DISPATCH_XXX) error ! /************************************************/ #elif OPT_CALL_THREADED_CODE @@ -95,7 +95,7 @@ error ! INSN_ENTRY_SIG(insn); \ /* dispather */ -#if __GNUC__ && (__i386__ || __x86_64__) && __GNUC__ == 3 +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && __GNUC__ == 3 #define DISPATCH_ARCH_DEPEND_WAY(addr) \ asm volatile("jmp *%0;\t# -- inseted by vm.h\t[length = 2]" : : "r" (addr))