diff --git a/ChangeLog b/ChangeLog index 36507d10f2..c7553d27a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon Apr 23 20:35:49 2012 NAKAMURA Usaku + + * win32/win32.c (szInternalCmds, internal_match, internal_cmd_match): + get rid of a segmentation fault with GCC 4.7.0. + reported by raylinn@gmail.com (ray linn) at [ruby-core:44505] + [Bug #6333], and patched by mame. + + * test/ruby/test_system.rb (TestSystem#test_system): test for it. + Mon Apr 23 20:11:02 2012 Tanaka Akira * lib/drb/ssl.rb: generate 1024 bits RSA key instead of 512 bits. diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index f1372781cf..13266d9d37 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -84,6 +84,10 @@ class TestSystem < Test::Unit::TestCase ENV["PATH"] = path end File.unlink tmpfilename + + testname = '[ruby-core:44505]' + assert_match /Windows/, `ver`, testname + assert_equal 0, $?.to_i, testname end } end diff --git a/win32/win32.c b/win32/win32.c index 687d8bd04a..7cbbaa2183 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -844,62 +844,62 @@ FindFreeChildSlot(void) 98cmd ntcmd */ static const char *const szInternalCmds[] = { - "\2" "assoc" + 1, - "\3" "break" + 1, - "\3" "call" + 1, - "\3" "cd" + 1, - "\1" "chcp" + 1, - "\3" "chdir" + 1, - "\3" "cls" + 1, - "\2" "color" + 1, - "\3" "copy" + 1, - "\1" "ctty" + 1, - "\3" "date" + 1, - "\3" "del" + 1, - "\3" "dir" + 1, - "\3" "echo" + 1, - "\2" "endlocal" + 1, - "\3" "erase" + 1, - "\3" "exit" + 1, - "\3" "for" + 1, - "\2" "ftype" + 1, - "\3" "goto" + 1, - "\3" "if" + 1, - "\1" "lfnfor" + 1, - "\1" "lh" + 1, - "\1" "lock" + 1, - "\3" "md" + 1, - "\3" "mkdir" + 1, - "\2" "move" + 1, - "\3" "path" + 1, - "\3" "pause" + 1, - "\2" "popd" + 1, - "\3" "prompt" + 1, - "\2" "pushd" + 1, - "\3" "rd" + 1, - "\3" "rem" + 1, - "\3" "ren" + 1, - "\3" "rename" + 1, - "\3" "rmdir" + 1, - "\3" "set" + 1, - "\2" "setlocal" + 1, - "\3" "shift" + 1, - "\2" "start" + 1, - "\3" "time" + 1, - "\2" "title" + 1, - "\1" "truename" + 1, - "\3" "type" + 1, - "\1" "unlock" + 1, - "\3" "ver" + 1, - "\3" "verify" + 1, - "\3" "vol" + 1, + "\2" "assoc", + "\3" "break", + "\3" "call", + "\3" "cd", + "\1" "chcp", + "\3" "chdir", + "\3" "cls", + "\2" "color", + "\3" "copy", + "\1" "ctty", + "\3" "date", + "\3" "del", + "\3" "dir", + "\3" "echo", + "\2" "endlocal", + "\3" "erase", + "\3" "exit", + "\3" "for", + "\2" "ftype", + "\3" "goto", + "\3" "if", + "\1" "lfnfor", + "\1" "lh", + "\1" "lock", + "\3" "md", + "\3" "mkdir", + "\2" "move", + "\3" "path", + "\3" "pause", + "\2" "popd", + "\3" "prompt", + "\2" "pushd", + "\3" "rd", + "\3" "rem", + "\3" "ren", + "\3" "rename", + "\3" "rmdir", + "\3" "set", + "\2" "setlocal", + "\3" "shift", + "\2" "start", + "\3" "time", + "\2" "title", + "\1" "truename", + "\3" "type", + "\1" "unlock", + "\3" "ver", + "\3" "verify", + "\3" "vol", }; /* License: Ruby's */ static int internal_match(const void *key, const void *elem) { - return strcmp(key, *(const char *const *)elem); + return strcmp(key, (*(const char *const *)elem) + 1); } /* License: Ruby's */ @@ -956,7 +956,7 @@ internal_cmd_match(const char *cmdname, int nt) sizeof(szInternalCmds) / sizeof(*szInternalCmds), sizeof(*szInternalCmds), internal_match); - if (!nm || !(nm[0][-1] & (nt ? 2 : 1))) + if (!nm || !(nm[0][0] & (nt ? 2 : 1))) return 0; return 1; }