diff --git a/ChangeLog b/ChangeLog index fe76d3d1fb1a83..128f1fe1383852 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,397 @@ +Mon Apr 13 22:17:59 2015 CHIKANAGA Tomoyuki + + * ext/openssl/lib/openssl/ssl.rb: stricter hostname verification + following RFC 6125. with the patch provided by Tony Arcieri and + Hiroshi Nakamura [ruby-core:61545] [Bug #9644] + * test/openssl/test_ssl.rb: add tests for above. + +Mon Apr 13 17:09:06 2015 Nobuyoshi Nakada + + * win32/win32.c (different_device_p): compare by volume serial + numbers, not by path names. [ruby-core:68162] [Bug #10865] + +Mon Apr 13 17:09:06 2015 Nobuyoshi Nakada + + * win32/win32.c (wrename): return EXDEV if moving a directory to + another drive, since MoveFileExW does not set proper error code. + [ruby-core:68162] [Bug #10865] + +Mon Apr 13 17:02:25 2015 Scott Francis + + * thread_pthread.c (reserve_stack): fix intermittent SIGBUS on + Linux, by reserving the stack virtual address space at process + start up so that it will not clash with the heap space. + [Fix GH-822] + +Mon Apr 13 16:52:14 2015 Koichi Sasada + + * class.c (rb_prepend_module): need a WB for klass -> origin. + +Mon Apr 13 16:48:14 2015 Nobuyoshi Nakada + + * vm_eval.c (vm_call_super): search next super class from the + original class, to get rid of infinite recursion with + prepending. a patch by Seiei Higa at + [ruby-core:68434]. [ruby-core:68093] [Bug #10847] + +Mon Apr 13 16:39:57 2015 Nobuyoshi Nakada + + * parse.y (arg): fix segfault by null caused by syntax error. + [ruby-core:68851] [Bug #10957] + +Tue Mar 31 00:49:23 2015 Naohisa Goto + + * gc.c (wmap_final_func): fix memory size shortage when realloc wmap. + Fix SEGV during finalize of WeakRef on Solaris (though the SEGV + could occur on all OS/platforms). [ruby-dev:48779] [Bug #10646] + +Tue Mar 31 00:38:14 2015 Seiei Higa + + * vm_method.c (rb_method_entry): if no super class, no original + method entry. [ruby-core:67389] [Bug #10707] + +Tue Mar 31 00:34:39 2015 Vit Ondruch + + * configure.in (RUBY_SETJMP_TYPE): Remove superfluous semicolon + which causes a syntax error with autoconf 2.63. + [ruby-core:67429] [Bug #10716] + +Tue Mar 31 00:32:04 2015 Nobuyoshi Nakada + + * test/fiddle/test_handle.rb (test_NEXT): use -test-/dln/empty + which is always a shared object and is not used by others. + [ruby-dev:48629] [Bug #10384] + +Tue Mar 31 00:18:12 2015 Nobuyoshi Nakada + + * parse.y (primary): empty parentheses at cmdarg can be null. + [ruby-core:68477] [Bug #10957] + +Mon Mar 30 23:30:57 2015 Nobuyoshi Nakada + + * ext/io/console/console.c (console_dev): id_console is not a + constant name, use rb_const_remove() to get rid of NameError. + +Sun Mar 22 04:15:39 2015 Nobuyoshi Nakada + + * ext/thread/thread.c (Init_thread): ConditionVariable and Queue + are not able to copy. [ruby-core:59961] [Bug #9440] + +Wed Mar 18 02:42:37 2015 NAKAMURA Usaku + + * win32/win32.c (w32_spawn): `v2` is used not only for `shell` but also + `cmd`, so must not free before using `cmd`. + [ruby-core:66648] [Bug #10563] + +Wed Mar 18 02:40:18 2015 Nobuyoshi Nakada + + * win32/win32.c (constat_reset): do nothing on non-standard + console emulators. [ruby-core:66471] [Bug #10546] + +Wed Mar 18 02:03:02 2015 Kazuki Tsujimoto + + * vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements + of original crefs. It fixes segmentation fault when calling + refined method in duplicate module. [ruby-dev:48878] [Bug #10885] + + * vm_core.h, class.c: change accordingly. + + * test/ruby/test_refinement.rb: add a test for above. + +Wed Mar 18 01:58:18 2015 Nobuyoshi Nakada + + * ext/sdbm/_sdbm.c: include ruby/ruby.h for PRIdPTRDIFF when a + macro `DEBUG` is defined. based on the patch by Owen Rodley in + [ruby-core:67987]. [Bug #10825] + +Wed Mar 18 01:45:12 2015 Nobuyoshi Nakada + + * lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of + interference by modifying global variables in have_devel? method. + [ruby-core:67962] [Bug #10821] + +Wed Mar 18 00:58:43 2015 Shugo Maeda + + * class.c (method_entry_i, class_instance_method_list, + rb_obj_singleton_methods): should not include methods of + superclasses if recur is false. [ruby-dev:48854] [Bug #10826] + +Wed Mar 18 00:58:43 2015 Shugo Maeda + + * vm_method.c (remove_method): When remove refined + method, raise a NameError if the method is not + defined in refined class. + + But if the method is defined in refined class, + it should keep refined method and remove original + method. + + Patch by Seiei Higa. [ruby-core:67722] [Bug #10765] + +Wed Mar 18 00:32:08 2015 Seiei Higa + + * vm_method.c (check_definition): Module#public_method_defined?, + Module#private_method_defined?, Module#protected_method_defined? + should not use refinements. [ruby-core:67656] [Bug #10753] + +Tue Mar 10 02:40:11 2015 SHIBATA Hiroshi + + * thread.c: Improve documentation for Thread#value + [Bug #10694][ruby-core:67324][ci skip] + +Tue Mar 10 02:37:55 2015 SHIBATA Hiroshi + + * string.c: [DOC] Add missing documentation around String#chomp. + Patch by @stderr [ci skip][fix GH-780] + +Mon Mar 9 22:30:50 2015 SHIBATA Hiroshi + + * spec/default.mspec: use default configuration file name. + https://github.com/ruby/rubyspec/commit/cc69f337b06362e5607ffa3e3ad40ef7494960cf + +Mon Mar 9 22:30:50 2015 SHIBATA Hiroshi + + * spec/default.mspec: remove specific version number. + https://github.com/ruby/rubyspec/commit/7a909e925c1baa9c700bd44af9241aef6e596714 + +Mon Mar 9 22:27:47 2015 SHIBATA Hiroshi + + * common.mk: use ruby organization for rubyspec. + +Mon Mar 9 21:52:41 2015 NARUSE, Yui + + * lib/uri/generic.rb (URI::Generic.build): + use hostname= to detect and wrap IPv6 hosts. + Build is accepting URI components and users may not expect + that a host component needs to be wrapped with square brackets + since it's not providing a URI. + Note: initialize with arg_check => true does not wrap IPv6 hosts. + by Joe Rafaniello + https://github.com/ruby/ruby/pull/765 fix GH-765 + + * test/uri/test_generic.rb: Add more tests + +Tue Mar 3 02:42:27 2015 Eric Wong + + * ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX + Thanks to Yura Sokolov + [ruby-core:68369] [Bug#10923] + * test/io/wait/test_io_wait.rb (test_nread_buffered): + fix broken test + +Sun Mar 1 02:30:23 2015 Seiei Higa + + * vm_method.c (rb_alias): raise a NameError when creating alias to + a refined method if the original method of the refined method is + not defined. [ruby-core:67523] [Bug #10731] + +Sun Mar 1 01:17:24 2015 Seiei Higa + + * vm_method.c (rb_export_method): bail out if the original method + is undefined when the method is refined. + [ruby-core:67387] [Bug #10706] + +Sun Mar 1 01:14:59 2015 Eric Wong + + * lib/resolv.rb: consider ENETUNREACH as ResolvTimeout + [ruby-core:67411] [Bug #10712] + +Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi + + * lib/net/http.rb (Net::HTTP#send_request): there is no response body + with HEAD request. Patch by @rodrigosaito [fix GH-520] + +Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi + + * test/net/http/test_http.rb (_test_send_request__HEAD): Added + failing test for send_request with HEAD method. + +Sun Mar 1 00:58:30 2015 SHIBATA Hiroshi + + * ext/zlib/zlib.c: fix document of method signatures. + [Bug #10668][ruby-core:67186][ci skip] + +Sat Feb 28 02:13:17 2015 Tanaka Akira + + * lib/resolv.rb (Resolv::DNS::Name#==): Compare an array of Label:Str + objects. Label#Str#== is case-insensitive. + +Sat Feb 28 02:13:17 2015 Ben Miller + + * lib/resolv.rb (Resolv::DNS::Name#==): DNS is case-insensitive, so the + comparison should be case-insensitive as well. + [ruby-core:66498] [Bug #10550] + +Sat Feb 28 02:13:17 2015 Nobuyoshi Nakada + + * lib/resolv.rb (Resolv::DNS::Name): names with different dots + should be different. + +Thu Feb 19 19:14:34 2015 NARUSE, Yui + + * lib/net/http/response.rb (Net::HTTPResponse): require one or more + spaces [Bug #10591]. + by leriksen + https://github.com/ruby/ruby/pull/782 fix GH-782 + NOTE: graph.facebook.com returns without SP Reason-Phrase. + +Thu Feb 19 19:10:53 2015 SHIBATA Hiroshi + + * ext/tk/lib/tkextlib/tcllib/plotchart.rb: fix to invoke correct function + of tcllib. Patch by @zalt50 [fix GH-787] + +Wed Feb 18 00:27:57 2015 Eric Hodel + + * lib/net/http.rb: Do not attempt SSL session resumption when the + session is expired. [Bug #10533] + +Wed Feb 18 00:20:36 2015 Eric Wong + + * vm_eval.c (rb_yield_splat): add missing GC guard + [Bug #10509] + +Wed Feb 18 00:18:12 2015 Nobuyoshi Nakada + + * lib/rdoc/text.rb (expand_tabs): get rid of infinite loop with + CR. should check if substitution occurred too. + [ruby-dev:48813] [Bug #10732] + +Tue Feb 17 22:59:31 2015 Nobuyoshi Nakada + + * lib/resolv.rb (Resolv::DNS::Resource#==, #hash): elements + returned by Kernel#instance_variables are Symbols now. + [ruby-core:68128] [Bug #10857] + +Sun Feb 15 07:29:12 2015 Nobuyoshi Nakada + + * ext/socket/getaddrinfo.c (get_addr): reject too long hostname to + get rid of GHOST vulnerability on very old platforms. + + * ext/socket/raddrinfo.c (make_hostent_internal): ditto, paranoic + check for the canonical name. + +Mon Feb 2 22:57:30 2015 Nobuyoshi Nakada + + * ext/etc/etc.c (etc_getlogin): set login name encoding properly. + [ruby-core:66163] [Bug #10493] + +Mon Feb 2 22:47:35 2015 Nobuyoshi Nakada + + * proc.c (method_proc): the receiver of binding from method should + be same as the receiver of the method. + [ruby-core:65917] [Bug #10432] + +Mon Feb 2 22:43:42 2015 Aaron Patterson + + * lib/resolv.rb: fall back if canonicalization fails. + Thanks Vit Ondruch for the patch! [ruby-core:65836] + + * test/resolv/test_dns.rb: test for patch + +Mon Feb 2 22:38:53 2015 Nobuyoshi Nakada + + * configure.in (rb_cv_binary_elf): get rid of -e option of cat + which is not available on BusyBox, use tr instead. + [ruby-core:64824] [Bug #10210] + +Thu Jan 22 20:40:36 2015 Nobuyoshi Nakada + + * ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge + data gradually not to exceed INT_MAX. workaround of OpenSSL API + limitation. [ruby-core:67043] [Bug #10633] + +Thu Jan 22 01:14:12 2015 NAKAMURA Usaku + + * signal.c (ruby_signal): since SIGKILL is not supported by MSVCRT, + should be treated before calling signal(3). + [Bug #10615] + +Thu Jan 22 01:02:16 2015 Nobuyoshi Nakada + + * thread.c (exec_recursive): use the same last method name as + recursive_push in the error message when recursive_pop failed. + [ruby-core:66742] [Bug #10579] + +Thu Jan 22 01:02:16 2015 Nobuyoshi Nakada + + * eval.c (rb_frame_last_func): return the most recent frame method + name. + + * thread.c (recursive_list_access): use the last method name, + instead of the current method name which can be unset in some + cases, not to use a symbol by the invalid ID. + [ruby-core:66742] [Bug #10579] + +Thu Jan 22 00:54:00 2015 Nobuyoshi Nakada + + * parse.y (symbol_list): fix the node type of literal symbol list + with no interpolation. [ruby-core:66343] + +Thu Jan 22 00:49:52 2015 Nobuyoshi Nakada + + * object.c: [DOC] Revise documentation by Marcus Stollsteimer at + [ruby-core:66368]. [Bug #10526] + + * #inspect: be more specific about generated string, remove + obsolete example. + * #nil?: use code examples instead of different call-seq's. + * #tap: clarify what is yielded. + * Integer(): be more specific about to_int and to_i, remove + reference to Ruby 1.8. + * Array(): fix error. + * Class: fix variable name style and indentation in example. + * improve consistency, fix typos and formatting. + +Thu Jan 22 00:49:52 2015 Benoit Daloze + + * object.c (Module#const_defined?): [DOC] Revise the documentation. + Patch by Xavier Noria. + [Fixes GH-754] https://github.com/ruby/ruby/pull/754 + +Thu Jan 22 00:49:52 2015 SHIBATA Hiroshi + + * object.c: fix document of Kernel.Stirng by @suzukaze + [fix GH-743][ci skip] + +Thu Jan 22 00:25:15 2015 Nobuyoshi Nakada + + * load.c (rb_f_load): path name needs to be transcoded to OS path + encoding. [ruby-list:49994] + +Wed Jan 21 04:36:27 2015 Nobuyoshi Nakada + + * configure.in (NET_LUID): include winsock2.h instead of windows.h. + patch by Jon Forums in [ruby-core:67125]. [Bug #10640] + +Wed Jan 21 04:36:27 2015 Nobuyoshi Nakada + + * configure.in (NET_LUID): include also ifdef.h as a workaround of + a bug in mingw-w64 header. [ruby-core:67103] [Bug #10640] + +Wed Jan 7 22:34:52 2015 NARUSE, Yui + + * tool/config_files.rb: use config.guess in gcc repo. + +Tue Jan 6 00:04:38 2015 SHIBATA Hiroshi + + * test/ruby/test_io.rb: added timeout for AIX environment. + [ruby-core:62983][Bug #9917] + +Mon Jan 5 23:58:50 2015 CHIKANAGA Tomoyuki + + * test/ruby/test_string.rb(test_LSHIFT_neary_long_max): + increase timeout for Arch Linux CI environment. + +Wed Dec 31 00:00:09 2014 NARUSE, Yui + + * lib/net/http.rb (Net::HTTP.proxy_uri): use initializer instead + of parser to handle IPv6 address. [Bug #9129] + +Tue Dec 30 23:46:26 2014 CHIKANAGA Tomoyuki + + * lib/rubygems/*: upgrade to RubyGems 2.2.3. [Backport #10515] + +>>>>>>> ruby/ruby_2_1 Thu Nov 13 22:32:34 2014 CHIKANAGA Tomoyuki * lib/rexml/document.rb: add REXML::Document#document. @@ -41,7 +435,7 @@ Tue Oct 28 22:30:21 2014 NARUSE, Yui * configure.in: remove apple-gcc4.2 from CC candidates. -火 10 28 22:19:44 2014 CHIKANAGA Tomoyuki +Tue Oct 28 22:19:44 2014 CHIKANAGA Tomoyuki * version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.5. diff --git a/class.c b/class.c index ec587a15508a48..a48b39debdddea 100644 --- a/class.c +++ b/class.c @@ -233,25 +233,6 @@ rb_class_new(VALUE super) return rb_class_boot(super); } -static void -rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr) -{ - NODE *new_node; - while (node) { - if (node->nd_clss == old_klass) { - new_node = NEW_CREF(new_klass); - RB_OBJ_WRITE(new_node, &new_node->nd_next, node->nd_next); - *new_cref_ptr = new_node; - return; - } - new_node = NEW_CREF(node->nd_clss); - node = node->nd_next; - *new_cref_ptr = new_node; - new_cref_ptr = &new_node->nd_next; - } - *new_cref_ptr = NULL; -} - static void clone_method(VALUE klass, ID mid, const rb_method_entry_t *me) { @@ -261,7 +242,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me) NODE *new_cref; newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass); GetISeqPtr(newiseqval, iseq); - rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref); + rb_vm_rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref); RB_OBJ_WRITE(iseq->self, &iseq->cref_stack, new_cref); rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag); RB_GC_GUARD(newiseqval); @@ -957,7 +938,7 @@ rb_prepend_module(VALUE klass, VALUE module) OBJ_WB_UNPROTECT(origin); /* TODO: conservertive shading. Need more survery. */ RCLASS_SET_SUPER(origin, RCLASS_SUPER(klass)); RCLASS_SET_SUPER(klass, origin); - RCLASS_ORIGIN(klass) = origin; + RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin); RCLASS_M_TBL_WRAPPER(origin) = RCLASS_M_TBL_WRAPPER(klass); RCLASS_M_TBL_INIT(klass); st_foreach(RCLASS_M_TBL(origin), move_refined_method, @@ -1118,25 +1099,32 @@ ins_methods_pub_i(st_data_t name, st_data_t type, st_data_t ary) return ins_methods_push((ID)name, (long)type, (VALUE)ary, NOEX_PUBLIC); } +struct method_entry_arg { + st_table *list; + int recur; +}; + static int method_entry_i(st_data_t key, st_data_t value, st_data_t data) { const rb_method_entry_t *me = (const rb_method_entry_t *)value; - st_table *list = (st_table *)data; + struct method_entry_arg *arg = (struct method_entry_arg *)data; long type; if (me && me->def->type == VM_METHOD_TYPE_REFINED) { + VALUE klass = me->klass; me = rb_resolve_refined_method(Qnil, me, NULL); if (!me) return ST_CONTINUE; + if (!arg->recur && me->klass != klass) return ST_CONTINUE; } - if (!st_lookup(list, key, 0)) { + if (!st_lookup(arg->list, key, 0)) { if (UNDEFINED_METHOD_ENTRY_P(me)) { type = -1; /* none */ } else { type = VISI(me->flag); } - st_add_direct(list, key, type); + st_add_direct(arg->list, key, type); } return ST_CONTINUE; } @@ -1146,7 +1134,7 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func { VALUE ary; int recur, prepended = 0; - st_table *list; + struct method_entry_arg me_arg; if (argc == 0) { recur = TRUE; @@ -1162,16 +1150,17 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func prepended = 1; } - list = st_init_numtable(); + me_arg.list = st_init_numtable(); + me_arg.recur = recur; for (; mod; mod = RCLASS_SUPER(mod)) { - if (RCLASS_M_TBL(mod)) st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)list); + if (RCLASS_M_TBL(mod)) st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)&me_arg); if (BUILTIN_TYPE(mod) == T_ICLASS && !prepended) continue; if (obj && FL_TEST(mod, FL_SINGLETON)) continue; if (!recur) break; } ary = rb_ary_new(); - st_foreach(list, func, ary); - st_free_table(list); + st_foreach(me_arg.list, func, ary); + st_free_table(me_arg.list); return ary; } @@ -1393,7 +1382,8 @@ VALUE rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj) { VALUE recur, ary, klass, origin; - st_table *list, *mtbl; + struct method_entry_arg me_arg; + st_table *mtbl; if (argc == 0) { recur = Qtrue; @@ -1403,22 +1393,23 @@ rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj) } klass = CLASS_OF(obj); origin = RCLASS_ORIGIN(klass); - list = st_init_numtable(); + me_arg.list = st_init_numtable(); + me_arg.recur = recur; if (klass && FL_TEST(klass, FL_SINGLETON)) { if ((mtbl = RCLASS_M_TBL(origin)) != 0) - st_foreach(mtbl, method_entry_i, (st_data_t)list); + st_foreach(mtbl, method_entry_i, (st_data_t)&me_arg); klass = RCLASS_SUPER(klass); } if (RTEST(recur)) { while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) { if (klass != origin && (mtbl = RCLASS_M_TBL(klass)) != 0) - st_foreach(mtbl, method_entry_i, (st_data_t)list); + st_foreach(mtbl, method_entry_i, (st_data_t)&me_arg); klass = RCLASS_SUPER(klass); } } ary = rb_ary_new(); - st_foreach(list, ins_methods_i, ary); - st_free_table(list); + st_foreach(me_arg.list, ins_methods_i, ary); + st_free_table(me_arg.list); return ary; } diff --git a/common.mk b/common.mk index 41fb072704e82c..1e1e9d04d2cfbf 100644 --- a/common.mk +++ b/common.mk @@ -14,7 +14,7 @@ RUBYLIB = $(PATH_SEPARATOR) RUBYOPT = - RUN_OPTS = --disable-gems -SPEC_GIT_BASE = git://github.com/nurse +SPEC_GIT_BASE = git://github.com/ruby MSPEC_GIT_URL = $(SPEC_GIT_BASE)/mspec.git RUBYSPEC_GIT_URL = $(SPEC_GIT_BASE)/rubyspec.git diff --git a/complex.c b/complex.c index e1d5ff9f2a97a0..67b45dd6ae097f 100644 --- a/complex.c +++ b/complex.c @@ -433,6 +433,8 @@ f_complex_new2(VALUE klass, VALUE x, VALUE y) * * Complex(1, 2) #=> (1+2i) * Complex('1+2i') #=> (1+2i) + * Complex(nil) #=> TypeError + * Complex(1, nil) #=> TypeError * * Syntax of string form: * diff --git a/configure.in b/configure.in index 5968bbdb14a487..5a1248f9f5bdf7 100644 --- a/configure.in +++ b/configure.in @@ -816,10 +816,13 @@ if test "$GCC" = yes; then ], [ # ANSI (no XCFLAGS because this is C only) - RUBY_TRY_CFLAGS(-ansi -std=iso9899:199409, [ - RUBY_APPEND_OPTION(warnflags, -ansi -std=iso9899:199409) - RUBY_APPEND_OPTION(strict_warnflags, -ansi -std=iso9899:199409) - ]) + for ansi_options in -std=iso9899:1999 "-ansi -std=iso9899:199409"; do + RUBY_TRY_CFLAGS(${ansi_options}, [ + RUBY_APPEND_OPTIONS(warnflags, ${ansi_options}) + RUBY_APPEND_OPTIONS(strict_warnflags, ${ansi_options}) + ], [ansi_options=]) + test "x${ansi_options}" = x || break + done ]) # suppress annoying -Wstrict-overflow warnings @@ -1054,8 +1057,8 @@ main() ac_cv_func_malloc_usable_size=no { test "$target_cpu" = x64 && ac_cv_func___builtin_setjmp=no; } AC_CHECK_TYPE([NET_LUID], [], [], - [@%:@include - @%:@include ]) + [@%:@include + @%:@include ]) if test x"$ac_cv_type_NET_LUID" = xyes; then AC_DEFINE(HAVE_TYPE_NET_LUID, 1) fi @@ -2075,7 +2078,7 @@ if test ${setjmp_prefix+set}; then if test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp${setjmp_suffix} = no; then AC_MSG_ERROR(${setjmp_prefix}setjmp${setjmp_suffix} is not available) fi -elif { AS_CASE("$ac_cv_func___builtin_setjmp", [yes*], [true], [false]); }; then +elif { AS_CASE("$ac_cv_func___builtin_setjmp", [yes*], [true], [false]) }; then setjmp_cast=`expr "$ac_cv_func___builtin_setjmp" : "yes with cast (\(.*\))"` setjmp_prefix=__builtin_ setjmp_suffix= @@ -2617,8 +2620,8 @@ AC_ARG_WITH(dln-a-out, AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf, [AC_TRY_LINK([],[], [ -AS_CASE(["`head -1 conftest$EXEEXT | cat -e`"], -['^?ELF'*], [rb_cv_binary_elf=yes], [rb_cv_binary_elf=no])], +AS_CASE(["`head -1 conftest$EXEEXT | tr -dc '\177ELF' | tr '\177' .`"], +[.ELF*], [rb_cv_binary_elf=yes], [rb_cv_binary_elf=no])], rb_cv_binary_elf=no)]) if test "$rb_cv_binary_elf" = yes; then @@ -2699,7 +2702,7 @@ if test "$with_dln_a_out" != yes; then RPATHFLAG=' +b %1$-s' fi rb_cv_dlopen=yes], - [solaris*], [ if test "$GCC" = yes; then + [solaris*], [ if test "$GCC" = yes; then : ${LDSHARED='$(CC) -shared'} if test "$rb_cv_prog_gnu_ld" = yes; then LDFLAGS="$LDFLAGS -Wl,-E" @@ -2818,7 +2821,7 @@ if test "$with_dln_a_out" != yes; then [os2-emx*], [ LDFLAGS="$LDFLAGS -Zomf" ], [nacl], [ LDSHARED='$(CC) -shared' ], - [ : ${LDSHARED='$(LD)'}]) + [ : ${LDSHARED='$(LD)'}]) AC_MSG_RESULT($rb_cv_dlopen) fi if test "${LDSHAREDXX}" = ""; then diff --git a/eval.c b/eval.c index 7f002270a55d3f..ed1eacead1969b 100644 --- a/eval.c +++ b/eval.c @@ -978,6 +978,19 @@ prev_frame_func(void) return frame_func_id(prev_cfp); } +ID +rb_frame_last_func(void) +{ + rb_thread_t *th = GET_THREAD(); + rb_control_frame_t *cfp = th->cfp; + ID mid; + + while (!(mid = frame_func_id(cfp)) && + (cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp), + !RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp))); + return mid; +} + /* * call-seq: * append_features(mod) -> mod diff --git a/ext/etc/etc.c b/ext/etc/etc.c index 18d425a8bfd7b2..3d195e44c64928 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -67,8 +67,15 @@ etc_getlogin(VALUE obj) login = getenv("USER"); #endif - if (login) - return rb_tainted_str_new2(login); + if (login) { +#ifdef _WIN32 + rb_encoding *extenc = rb_utf8_encoding(); +#else + rb_encoding *extenc = rb_locale_encoding(); +#endif + return rb_external_str_new_with_enc(login, strlen(login), extenc); + } + return Qnil; } diff --git a/ext/io/console/console.c b/ext/io/console/console.c index de5ca825583bd0..85b6750c9fbf77 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -689,7 +689,7 @@ console_dev(VALUE klass) if ((fptr = RFILE(con)->fptr) && GetReadFD(fptr) != -1) return con; } - rb_mod_remove_const(klass, ID2SYM(id_console)); + rb_const_remove(klass, id_console); } { VALUE args[2]; diff --git a/ext/io/console/io-console.gemspec b/ext/io/console/io-console.gemspec index f71e1b9b8f3906..309b9bd85b7bcb 100644 --- a/ext/io/console/io-console.gemspec +++ b/ext/io/console/io-console.gemspec @@ -1,5 +1,5 @@ # -*- ruby -*- -_VERSION = "0.4.2" +_VERSION = "0.4.3" date = %w$Date:: $[1] Gem::Specification.new do |s| diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c index d8bb55fc475fe0..ce8cfbbeb49fb9 100644 --- a/ext/io/wait/wait.c +++ b/ext/io/wait/wait.c @@ -62,7 +62,7 @@ io_nread(VALUE io) GetOpenFile(io, fptr); rb_io_check_readable(fptr); len = rb_io_read_pending(fptr); - if (len > 0) return len; + if (len > 0) return INT2FIX(len); if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0); if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0); if (n > 0) return ioctl_arg2num(n); diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb index 43025e76220cf1..b91dce312a89d4 100644 --- a/ext/openssl/lib/openssl/ssl.rb +++ b/ext/openssl/lib/openssl/ssl.rb @@ -143,8 +143,7 @@ def verify_certificate_identity(cert, hostname) case san.tag when 2 # dNSName in GeneralName (RFC5280) should_verify_common_name = false - reg = Regexp.escape(san.value).gsub(/\\\*/, "[^.]+") - return true if /\A#{reg}\z/i =~ hostname + return true if verify_hostname(hostname, san.value) when 7 # iPAddress in GeneralName (RFC5280) should_verify_common_name = false # follows GENERAL_NAME_print() in x509v3/v3_alt.c @@ -159,8 +158,7 @@ def verify_certificate_identity(cert, hostname) if should_verify_common_name cert.subject.to_a.each{|oid, value| if oid == "CN" - reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+") - return true if /\A#{reg}\z/i =~ hostname + return true if verify_hostname(hostname, value) end } end @@ -168,11 +166,67 @@ def verify_certificate_identity(cert, hostname) end module_function :verify_certificate_identity + def verify_hostname(hostname, san) # :nodoc: + # RFC 5280, IA5String is limited to the set of ASCII characters + return false unless san.ascii_only? + return false unless hostname.ascii_only? + + # See RFC 6125, section 6.4.1 + # Matching is case-insensitive. + san_parts = san.downcase.split(".") + + # TODO: this behavior should probably be more strict + return san == hostname if san_parts.size < 2 + + # Matching is case-insensitive. + host_parts = hostname.downcase.split(".") + + # RFC 6125, section 6.4.3, subitem 2. + # If the wildcard character is the only character of the left-most + # label in the presented identifier, the client SHOULD NOT compare + # against anything but the left-most label of the reference + # identifier (e.g., *.example.com would match foo.example.com but + # not bar.foo.example.com or example.com). + return false unless san_parts.size == host_parts.size + + # RFC 6125, section 6.4.3, subitem 1. + # The client SHOULD NOT attempt to match a presented identifier in + # which the wildcard character comprises a label other than the + # left-most label (e.g., do not match bar.*.example.net). + return false unless verify_wildcard(host_parts.shift, san_parts.shift) + + san_parts.join(".") == host_parts.join(".") + end + module_function :verify_hostname + + def verify_wildcard(domain_component, san_component) # :nodoc: + parts = san_component.split("*", -1) + + return false if parts.size > 2 + return san_component == domain_component if parts.size == 1 + + # RFC 6125, section 6.4.3, subitem 3. + # The client SHOULD NOT attempt to match a presented identifier + # where the wildcard character is embedded within an A-label or + # U-label of an internationalized domain name. + return false if domain_component.start_with?("xn--") && san_component != "*" + + parts[0].length + parts[1].length < domain_component.length && + domain_component.start_with?(parts[0]) && + domain_component.end_with?(parts[1]) + end + module_function :verify_wildcard + class SSLSocket include Buffering include SocketForwarder include Nonblock + ## + # Perform hostname verification after an SSL connection is established + # + # This method MUST be called after calling #connect to ensure that the + # hostname of a remote peer has been verified. def post_connection_check(hostname) unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname) raise SSLError, "hostname \"#{hostname}\" does not match the server certificate" diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c index df6fd108878b40..0fa740e1cb3638 100644 --- a/ext/openssl/ossl_cipher.c +++ b/ext/openssl/ossl_cipher.c @@ -329,6 +329,33 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self) return Qnil; } +static int +ossl_cipher_update_long(EVP_CIPHER_CTX *ctx, unsigned char *out, long *out_len_ptr, + const unsigned char *in, long in_len) +{ + int out_part_len; + long out_len = 0; +#define UPDATE_LENGTH_LIMIT INT_MAX + +#if SIZEOF_LONG > UPDATE_LENGTH_LIMIT + if (in_len > UPDATE_LENGTH_LIMIT) { + const int in_part_len = (UPDATE_LENGTH_LIMIT / 2 + 1) & ~1; + do { + if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0, + &out_part_len, in, in_part_len)) + return 0; + out_len += out_part_len; + in += in_part_len; + } while ((in_len -= in_part_len) > UPDATE_LENGTH_LIMIT); + } +#endif + if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0, + &out_part_len, in, (int)in_len)) + return 0; + if (out_len_ptr) *out_len_ptr = out_len += out_part_len; + return 1; +} + /* * call-seq: * cipher.update(data [, buffer]) -> string or buffer @@ -347,17 +374,21 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self) { EVP_CIPHER_CTX *ctx; unsigned char *in; - int in_len, out_len; + long in_len, out_len; VALUE data, str; rb_scan_args(argc, argv, "11", &data, &str); StringValue(data); in = (unsigned char *)RSTRING_PTR(data); - if ((in_len = RSTRING_LENINT(data)) == 0) + if ((in_len = RSTRING_LEN(data)) == 0) ossl_raise(rb_eArgError, "data must not be empty"); GetCipher(self, ctx); out_len = in_len+EVP_CIPHER_CTX_block_size(ctx); + if (out_len <= 0) { + ossl_raise(rb_eRangeError, + "data too big to make output buffer: %ld bytes", in_len); + } if (NIL_P(str)) { str = rb_str_new(0, out_len); @@ -366,7 +397,7 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self) rb_str_resize(str, out_len); } - if (!EVP_CipherUpdate(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len)) + if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len)) ossl_raise(eCipherError, NULL); assert(out_len < RSTRING_LEN(str)); rb_str_set_len(str, out_len); @@ -506,17 +537,16 @@ ossl_cipher_set_auth_data(VALUE self, VALUE data) { EVP_CIPHER_CTX *ctx; unsigned char *in; - int in_len; - int out_len; + long in_len, out_len; StringValue(data); in = (unsigned char *) RSTRING_PTR(data); - in_len = RSTRING_LENINT(data); + in_len = RSTRING_LEN(data); GetCipher(self, ctx); - if (!EVP_CipherUpdate(ctx, NULL, &out_len, in, in_len)) + if (!ossl_cipher_update_long(ctx, NULL, &out_len, in, in_len)) ossl_raise(eCipherError, "couldn't set additional authenticated data"); return data; diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c index 847eb2aaf6b2cf..d810befbce4ee5 100644 --- a/ext/sdbm/_sdbm.c +++ b/ext/sdbm/_sdbm.c @@ -7,8 +7,7 @@ * core routines */ -#include "ruby/config.h" -#include "ruby/defines.h" +#include "ruby/ruby.h" #ifdef HAVE_UNISTD_H #include @@ -803,7 +802,7 @@ delpair(char *pag, datum key) } #else #ifdef MEMMOVE - memmove(dst, src, m); + memmove(dst-m, src-m, m); #else while (m--) *--dst = *--src; diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c index a17d12b70559f4..68f610e807fb15 100644 --- a/ext/socket/getaddrinfo.c +++ b/ext/socket/getaddrinfo.c @@ -593,6 +593,7 @@ get_addr(const char *hostname, int af, struct addrinfo **res, struct addrinfo *p } else hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error); #else + if (strlen(hostname) >= NI_MAXHOST) ERR(EAI_NODATA); hp = gethostbyname((char*)hostname); h_error = h_errno; #endif diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 3deadd1aeae539..e4cb9c379fcfc3 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -617,7 +617,8 @@ make_hostent_internal(struct hostent_arg *arg) } rb_ary_push(ary, rb_str_new2(hostp)); - if (addr->ai_canonname && (h = gethostbyname(addr->ai_canonname))) { + if (addr->ai_canonname && strlen(addr->ai_canonname) < NI_MAXHOST && + (h = gethostbyname(addr->ai_canonname))) { names = rb_ary_new(); if (h->h_aliases != NULL) { for (pch = h->h_aliases; *pch; pch++) { diff --git a/ext/thread/thread.c b/ext/thread/thread.c index c3d81dc58d8a8b..c54396b927a54f 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -590,12 +590,14 @@ Init_thread(void) rb_define_method(rb_cConditionVariable, "initialize", rb_condvar_initialize, 0); rb_define_method(rb_cConditionVariable, "marshal_dump", undumpable, 0); + rb_undef_method(rb_cConditionVariable, "initialize_copy"); rb_define_method(rb_cConditionVariable, "wait", rb_condvar_wait, -1); rb_define_method(rb_cConditionVariable, "signal", rb_condvar_signal, 0); rb_define_method(rb_cConditionVariable, "broadcast", rb_condvar_broadcast, 0); rb_define_method(rb_cQueue, "initialize", rb_queue_initialize, 0); rb_define_method(rb_cQueue, "marshal_dump", undumpable, 0); + rb_undef_method(rb_cQueue, "initialize_copy"); rb_define_method(rb_cQueue, "push", rb_queue_push, 1); rb_define_method(rb_cQueue, "pop", rb_queue_pop, -1); rb_define_method(rb_cQueue, "empty?", rb_queue_empty_p, 0); diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb index 2f3d79d4279238..cd52a0ed4bb7fa 100644 --- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb +++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb @@ -142,7 +142,7 @@ def self.polar_to_pixel(w, rad, phi) end def self.pixel_to_coords(w, x, y) - list(tk_call_without_enc('::Plotchart::coordsToPixel', w.path, x, y)) + list(tk_call_without_enc('::Plotchart::pixelToCoords', w.path, x, y)) end def self.determine_scale(*args) # (xmin, xmax, inverted=false) @@ -311,7 +311,7 @@ def polar_to_pixel(rad, phi) end def pixel_to_coords(x, y) - list(tk_call_without_enc('::Plotchart::coordsToPixel', @path, x, y)) + list(tk_call_without_enc('::Plotchart::pixelToCoords', @path, x, y)) end def determine_scale(xmax, ymax) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 4d8fde68c9d9f0..9dbc193f54bf72 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -461,7 +461,7 @@ rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2) /* * Document-method: Zlib.crc32 * - * call-seq: Zlib.crc32(string, adler) + * call-seq: Zlib.crc32(string, crc) * * Calculates CRC checksum for +string+, and returns updated value of +crc+. If * +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it diff --git a/gc.c b/gc.c index d8fb2f4db6900e..69f1198736ef4b 100644 --- a/gc.c +++ b/gc.c @@ -6482,7 +6482,7 @@ wmap_final_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing) return ST_DELETE; } if (j < i) { - ptr = ruby_sized_xrealloc2(ptr, j, sizeof(VALUE), i); + ptr = ruby_sized_xrealloc2(ptr, j + 1, sizeof(VALUE), i); ptr[0] = j; *value = (st_data_t)ptr; } diff --git a/include/ruby/intern.h b/include/ruby/intern.h index f1b42cf33158f4..e9a17d5617cdc4 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -948,6 +948,10 @@ VALUE rb_f_eval(int argc, VALUE *argv, VALUE self); DEPRECATED(void rb_frame_pop(void)); +/* deprecated */ +DEPRECATED(void rb_frame_pop(void)); + + RUBY_SYMBOL_EXPORT_END #if defined(__cplusplus) diff --git a/lib/net/http.rb b/lib/net/http.rb index a1b8d691bb2871..bd0a4d6b5fec6b 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -914,7 +914,10 @@ def connect @socket.write(buf) HTTPResponse.read_new(@socket).value end - s.session = @ssl_session if @ssl_session + if @ssl_session and + Time.now < @ssl_session.time + @ssl_session.timeout + s.session = @ssl_session if @ssl_session + end # Server Name Indication (SNI) RFC 3546 s.hostname = @address if s.respond_to? :hostname= Timeout.timeout(@open_timeout, Net::OpenTimeout) { s.connect } @@ -1026,7 +1029,9 @@ def proxy_from_env? # The proxy URI determined from the environment for this connection. def proxy_uri # :nodoc: - @proxy_uri ||= URI("http://#{address}:#{port}").find_proxy + @proxy_uri ||= URI::HTTP.new( + "http".freeze, nil, address, port, nil, nil, nil, nil, nil + ).find_proxy end # The address of the proxy server, if one is configured. @@ -1345,7 +1350,8 @@ def request_put(path, data, initheader = nil, &block) #:nodoc: # puts response.body # def send_request(name, path, data = nil, header = nil) - r = HTTPGenericRequest.new(name,(data ? true : false),true,path,header) + has_response_body = name != 'HEAD' + r = HTTPGenericRequest.new(name,(data ? true : false),has_response_body,path,header) request r, data end diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index da3e4b4c8cc7ae..9aaa0b32080c12 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -37,7 +37,7 @@ def read_new(sock) #:nodoc: internal use only def read_status_line(sock) str = sock.readline - m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in.match(str) or + m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) or raise Net::HTTPBadResponse, "wrong status line: #{str.dump}" m.captures end diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 0fda72e3ae4358..ef525003583a82 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -68,11 +68,11 @@ def expand_tabs text expanded = [] text.each_line do |line| - line.gsub!(/^((?:.{8})*?)([^\t\r\n]{0,7})\t/) do + nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do r = "#{$1}#{$2}#{' ' * (8 - $2.size)}" r.force_encoding text.encoding if Object.const_defined? :Encoding r - end until line !~ /\t/ + end expanded << line end diff --git a/lib/resolv.rb b/lib/resolv.rb index 60b2d9091c20e8..74618bfaab37ee 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -671,8 +671,8 @@ def request(sender, tout) timelimit = start + tout begin sender.send - rescue Errno::EHOSTUNREACH - # multi-homed IPv6 may generate this + rescue Errno::EHOSTUNREACH, # multi-homed IPv6 may generate this + Errno::ENETUNREACH raise ResolvTimeout end while true @@ -1070,6 +1070,10 @@ def generate_candidates(name) candidates = [] end candidates.concat(@search.map {|domain| Name.new(name.to_a + domain)}) + fname = Name.create("#{name}.") + if !candidates.include?(fname) + candidates << fname + end end return candidates end @@ -1236,7 +1240,8 @@ def absolute? def ==(other) # :nodoc: return false unless Name === other - return @labels.join == other.to_a.join && @absolute == other.absolute? + return false unless @absolute == other.absolute? + return @labels == other.to_a end alias eql? == # :nodoc: @@ -1662,10 +1667,10 @@ def ==(other) # :nodoc: return false unless self.class == other.class s_ivars = self.instance_variables s_ivars.sort! - s_ivars.delete "@ttl" + s_ivars.delete :@ttl o_ivars = other.instance_variables o_ivars.sort! - o_ivars.delete "@ttl" + o_ivars.delete :@ttl return s_ivars == o_ivars && s_ivars.collect {|name| self.instance_variable_get name} == o_ivars.collect {|name| other.instance_variable_get name} @@ -1678,7 +1683,7 @@ def eql?(other) # :nodoc: def hash # :nodoc: h = 0 vars = self.instance_variables - vars.delete "@ttl" + vars.delete :@ttl vars.each {|name| h ^= self.instance_variable_get(name).hash } diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 456273ed19d763..ea1893046f6259 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.2.2' + VERSION = '2.2.3' end # Must be first since it unloads the prelude from 1.9.2 diff --git a/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem b/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem new file mode 100644 index 00000000000000..20585f1c01e187 --- /dev/null +++ b/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem @@ -0,0 +1,25 @@ +-----BEGIN CERTIFICATE----- +MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU +MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs +IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 +MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux +FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h +bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v +dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt +H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9 +uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX +mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX +a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN +E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0 +WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD +VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0 +Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU +cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx +IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN +AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH +YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 +6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC +Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX +c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a +mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= +-----END CERTIFICATE----- diff --git a/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem b/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem new file mode 100644 index 00000000000000..6fbdf52b17a73a --- /dev/null +++ b/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem @@ -0,0 +1,32 @@ +-----BEGIN CERTIFICATE----- +MIIFdDCCBFygAwIBAgIQJ2buVutJ846r13Ci/ITeIjANBgkqhkiG9w0BAQwFADBv +MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk +ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF +eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow +gYUxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO +BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMSswKQYD +VQQDEyJDT01PRE8gUlNBIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkq +hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAkehUktIKVrGsDSTdxc9EZ3SZKzejfSNw +AHG8U9/E+ioSj0t/EFa9n3Byt2F/yUsPF6c947AEYe7/EZfH9IY+Cvo+XPmT5jR6 +2RRr55yzhaCCenavcZDX7P0N+pxs+t+wgvQUfvm+xKYvT3+Zf7X8Z0NyvQwA1onr +ayzT7Y+YHBSrfuXjbvzYqOSSJNpDa2K4Vf3qwbxstovzDo2a5JtsaZn4eEgwRdWt +4Q08RWD8MpZRJ7xnw8outmvqRsfHIKCxH2XeSAi6pE6p8oNGN4Tr6MyBSENnTnIq +m1y9TBsoilwie7SrmNnu4FGDwwlGTm0+mfqVF9p8M1dBPI1R7Qu2XK8sYxrfV8g/ +vOldxJuvRZnio1oktLqpVj3Pb6r/SVi+8Kj/9Lit6Tf7urj0Czr56ENCHonYhMsT +8dm74YlguIwoVqwUHZwK53Hrzw7dPamWoUi9PPevtQ0iTMARgexWO/bTouJbt7IE +IlKVgJNp6I5MZfGRAy1wdALqi2cVKWlSArvX31BqVUa/oKMoYX9w0MOiqiwhqkfO +KJwGRXa/ghgntNWutMtQ5mv0TIZxMOmm3xaG4Nj/QN370EKIf6MzOi5cHkERgWPO +GHFrK+ymircxXDpqR+DDeVnWIBqv8mqYqnK8V0rSS527EPywTEHl7R09XiidnMy/ +s1Hap0flhFMCAwEAAaOB9DCB8TAfBgNVHSMEGDAWgBStvZh6NLQm9/rEJlTvA73g +JMtUGjAdBgNVHQ4EFgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQD +AgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAGBgRVHSAAMEQGA1UdHwQ9 +MDswOaA3oDWGM2h0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9BZGRUcnVzdEV4dGVy +bmFsQ0FSb290LmNybDA1BggrBgEFBQcBAQQpMCcwJQYIKwYBBQUHMAGGGWh0dHA6 +Ly9vY3NwLnVzZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQEMBQADggEBAGS/g/FfmoXQ +zbihKVcN6Fr30ek+8nYEbvFScLsePP9NDXRqzIGCJdPDoCpdTPW6i6FtxFQJdcfj +Jw5dhHk3QBN39bSsHNA7qxcS1u80GH4r6XnTq1dFDK8o+tDb5VCViLvfhVdpfZLY +Uspzgb8c8+a4bmYRBbMelC1/kZWSWfFMzqORcUx8Rww7Cxn2obFshj5cqsQugsv5 +B5a6SE2Q8pTIqXOi6wZ7I53eovNNVZ96YUWYGGjHXkBrI/V5eu+MtWuLt29G9Hvx +PUsE2JOAWVrgQSQdso8VYFhH2+9uRv0V9dlfmrPb2LjkQLPNlzmuhbsdjrzch5vR +pu/xO28QOG8= +-----END CERTIFICATE----- diff --git a/lib/test/unit.rb b/lib/test/unit.rb index 13a993fc6cd4d3..09036e5b938dc3 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -394,7 +394,7 @@ def terminal_width begin require 'io/console' width = $stdout.winsize[1] - rescue LoadError, NoMethodError, Errno::ENOTTY, Errno::EBADF + rescue LoadError, NoMethodError, Errno::ENOTTY, Errno::EBADF, Errno::EINVAL width = ENV["COLUMNS"].to_i.nonzero? || 80 end width -= 1 if /mswin|mingw/ =~ RUBY_PLATFORM diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 88c96fe90a8f94..d7a55dcbd81eed 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -192,7 +192,7 @@ def initialize(scheme, if arg_check self.scheme = scheme self.userinfo = userinfo - self.host = host + self.hostname = host self.port = port self.path = path self.query = query diff --git a/load.c b/load.c index f31b7aeaca961b..e5014c165faef0 100644 --- a/load.c +++ b/load.c @@ -683,7 +683,7 @@ rb_load_protect(VALUE fname, int wrap, int *state) static VALUE rb_f_load(int argc, VALUE *argv) { - VALUE fname, wrap, path; + VALUE fname, wrap, path, orig_fname; rb_scan_args(argc, argv, "11", &fname, &wrap); @@ -693,10 +693,12 @@ rb_f_load(int argc, VALUE *argv) rb_sourceline()); } - path = rb_find_file(FilePathValue(fname)); + orig_fname = FilePathValue(fname); + fname = rb_str_encode_ospath(orig_fname); + path = rb_find_file(fname); if (!path) { if (!rb_file_load_ok(RSTRING_PTR(fname))) - load_failed(fname); + load_failed(orig_fname); path = fname; } rb_load_internal(path, RTEST(wrap)); diff --git a/method.h b/method.h index 556d2865b7122c..856929b6809cc4 100644 --- a/method.h +++ b/method.h @@ -108,6 +108,9 @@ struct unlinked_method_entry_list_entry { }; #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF) +#define UNDEFINED_REFINED_METHOD_P(def) \ + ((def)->type == VM_METHOD_TYPE_REFINED && \ + UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me)) void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex); rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex); diff --git a/object.c b/object.c index 0d7e03a95f1bd1..d7b37e56b38680 100644 --- a/object.c +++ b/object.c @@ -154,7 +154,7 @@ rb_obj_equal(VALUE obj1, VALUE obj2) * capacity of a Fixnum will be truncated before being used. * * The hash value for an object may not be identical across invocations or - * implementations of ruby. If you need a stable identifier across ruby + * implementations of Ruby. If you need a stable identifier across Ruby * invocations and implementations you will need to generate one with a custom * method. */ @@ -233,7 +233,7 @@ rb_obj_class(VALUE obj) * obj.singleton_class -> class * * Returns the singleton class of obj. This method creates - * a new singleton class if obj does not have it. + * a new singleton class if obj does not have one. * * If obj is nil, true, or * false, it returns NilClass, TrueClass, or FalseClass, @@ -314,9 +314,9 @@ init_copy(VALUE dest, VALUE obj) * obj.clone -> an_object * * Produces a shallow copy of obj---the instance variables of - * obj are copied, but not the objects they reference. Copies - * the frozen and tainted state of obj. See also the discussion - * under Object#dup. + * obj are copied, but not the objects they reference. + * clone copies the frozen and tainted state of obj. + * See also the discussion under Object#dup. * * class Klass * attr_accessor :str @@ -364,8 +364,8 @@ rb_obj_clone(VALUE obj) * obj.dup -> an_object * * Produces a shallow copy of obj---the instance variables of - * obj are copied, but not the objects they reference. dup - * copies the tainted state of obj. + * obj are copied, but not the objects they reference. + * dup copies the tainted state of obj. * * This method may have class-specific behavior. If so, that * behavior will be documented under the #+initialize_copy+ method of @@ -379,7 +379,7 @@ rb_obj_clone(VALUE obj) * typically uses the class of the descendant object to create the new * instance. * - * When using #dup any modules that the object has been extended with will not + * When using #dup, any modules that the object has been extended with will not * be copied. * * class Klass @@ -445,7 +445,7 @@ rb_obj_init_dup_clone(VALUE obj, VALUE orig) * Returns a string representing obj. The default * to_s prints the object's class and an encoding of the * object id. As a special case, the top-level object that is the - * initial execution context of Ruby programs returns ``main.'' + * initial execution context of Ruby programs returns ``main''. */ VALUE @@ -462,7 +462,7 @@ rb_any_to_s(VALUE obj) /* * If the default external encoding is ASCII compatible, the encoding of - * inspected result must be compatible with it. + * the inspected result must be compatible with it. * If the default external encoding is ASCII incompatible, * the result must be ASCII only. */ @@ -531,9 +531,10 @@ inspect_obj(VALUE obj, VALUE str, int recur) * obj.inspect -> string * * Returns a string containing a human-readable representation of obj. - * By default, show the class name and the list of the instance variables and + * The default inspect shows the object's class name, + * an encoding of the object id, and a list of the instance variables and * their values (by calling #inspect on each of them). - * User defined classes should override this method to make better + * User defined classes should override this method to provide a better * representation of obj. When overriding this method, it should * return a string whose encoding is compatible with the default external * encoding. @@ -551,13 +552,6 @@ inspect_obj(VALUE obj, VALUE str, int recur) * end * end * Bar.new.inspect #=> "#" - * - * class Baz - * def to_s - * "baz" - * end - * end - * Baz.new.inspect #=> "#" */ static VALUE @@ -680,14 +674,14 @@ rb_class_search_ancestor(VALUE cl, VALUE c) * call-seq: * obj.tap{|x|...} -> obj * - * Yields x to the block, and then returns x. + * Yields self to the block, and then returns self. * The primary purpose of this method is to "tap into" a method chain, * in order to perform operations on intermediate results within the chain. * * (1..10) .tap {|x| puts "original: #{x.inspect}"} * .to_a .tap {|x| puts "array: #{x.inspect}"} * .select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"} - * .map { |x| x*x } .tap {|x| puts "squares: #{x.inspect}"} + * .map {|x| x*x} .tap {|x| puts "squares: #{x.inspect}"} * */ @@ -721,7 +715,7 @@ rb_obj_tap(VALUE obj) * class Baz < Bar * end * - * produces: + * produces: * * New subclass: Bar * New subclass: Baz @@ -743,7 +737,7 @@ rb_obj_tap(VALUE obj) * def some_instance_method() end * end * - * produces: + * produces: * * Adding :some_instance_method * @@ -769,7 +763,7 @@ rb_obj_tap(VALUE obj) * remove_method :some_instance_method * end * - * produces: + * produces: * * Removing :some_instance_method * @@ -957,13 +951,13 @@ rb_obj_tainted(VALUE obj) * * Objects that are marked as tainted will be restricted from various built-in * methods. This is to prevent insecure data, such as command-line arguments - * or strings read from Kernel#gets, from inadvertently compromising the users + * or strings read from Kernel#gets, from inadvertently compromising the user's * system. * - * To check whether an object is tainted, use #tainted? + * To check whether an object is tainted, use #tainted?. * * You should only untaint a tainted object if your code has inspected it and - * determined that it is safe. To do so use #untaint + * determined that it is safe. To do so use #untaint. * * In $SAFE level 3, all newly created objects are tainted and you can't untaint * objects. @@ -1249,7 +1243,7 @@ true_and(VALUE obj, VALUE obj2) * call-seq: * true | obj -> true * - * Or---Returns true. As anObject is an argument to + * Or---Returns true. As obj is an argument to * a method call, it is always evaluated; there is no short-circuit * evaluation in this case. * @@ -1373,10 +1367,12 @@ rb_true(VALUE obj) /* * call-seq: - * nil.nil? -> true - * .nil? -> false + * obj.nil? -> true or false * * Only the object nil responds true to nil?. + * + * Object.new.nil? #=> false + * nil.nil? #=> true */ @@ -1453,7 +1449,7 @@ rb_obj_cmp(VALUE obj1, VALUE obj2) * Instance methods appear as methods in a class when the module is * included, module methods do not. Conversely, module methods may be * called without creating an encapsulating object, while instance - * methods may not. (See Module#module_function) + * methods may not. (See Module#module_function.) * * In the descriptions that follow, the parameter sym refers * to a symbol, which is either a quoted string or a @@ -1476,7 +1472,7 @@ rb_obj_cmp(VALUE obj1, VALUE obj2) * call-seq: * mod.to_s -> string * - * Return a string representing this module or class. For basic + * Returns a string representing this module or class. For basic * classes and modules, this is the name. For singletons, we * show information on the thing we're attached to as well. */ @@ -1536,7 +1532,7 @@ rb_mod_freeze(VALUE mod) * call-seq: * mod === obj -> true or false * - * Case Equality---Returns true if anObject is an + * Case Equality---Returns true if obj is an * instance of mod or one of mod's descendants. Of * limited use for modules, but can be used in case * statements to classify objects by class. @@ -1556,7 +1552,7 @@ rb_mod_eqq(VALUE mod, VALUE arg) * is the same as other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class Amod is a subclass of other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class Anil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class AA"). + * "class AA".) * */ @@ -1628,7 +1624,7 @@ rb_mod_ge(VALUE mod, VALUE arg) * Returns true if mod is an ancestor of other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class AA"). + * "class AA".) * */ @@ -1875,7 +1871,7 @@ rb_class_new_instance(int argc, VALUE *argv, VALUE klass) * class Bar < Foo; end * Bar.superclass #=> Foo * - * returns nil when the given class hasn't a parent class: + * Returns nil when the given class does not have a parent class: * * BasicObject.superclass #=> nil * @@ -2050,9 +2046,9 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass) * mod.const_get(sym, inherit=true) -> obj * mod.const_get(str, inherit=true) -> obj * - * Checks for a constant with the given name in mod + * Checks for a constant with the given name in mod. * If +inherit+ is set, the lookup will also search - * the ancestors (and +Object+ if mod is a +Module+.) + * the ancestors (and +Object+ if mod is a +Module+). * * The value of the constant is returned if a definition is found, * otherwise a +NameError+ is raised. @@ -2078,7 +2074,7 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass) * Object.const_get 'Foo::Baz::VAL' # => 10 * Object.const_get 'Foo::Baz::VAL', false # => NameError * - * If neither +sym+ nor +str+ is not a valid constant name a NameError will be + * If the argument is not a valid constant name a +NameError+ will be * raised with a warning "wrong constant name". * * Object.const_get 'foobar' #=> NameError: wrong constant name foobar @@ -2190,7 +2186,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) * Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714 * Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968 * - * If neither +sym+ nor +str+ is not a valid constant name a NameError will be + * If +sym+ or +str+ is not a valid constant name a +NameError+ will be * raised with a warning "wrong constant name". * * Object.const_set('foobar', 42) #=> NameError: wrong constant name foobar @@ -2210,20 +2206,39 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value) * mod.const_defined?(sym, inherit=true) -> true or false * mod.const_defined?(str, inherit=true) -> true or false * - * Checks for a constant with the given name in mod - * If +inherit+ is set, the lookup will also search - * the ancestors (and +Object+ if mod is a +Module+.) + * Says whether _mod_ or its ancestors have a constant with the given name: * - * Returns whether or not a definition is found: + * Float.const_defined?(:EPSILON) #=> true, found in Float itself + * Float.const_defined?("String") #=> true, found in Object (ancestor) + * BasicObject.const_defined?(:Hash) #=> false * - * Math.const_defined? "PI" #=> true - * IO.const_defined? :SYNC #=> true - * IO.const_defined? :SYNC, false #=> false + * If _mod_ is a +Module+, additionally +Object+ and its ancestors are checked: * - * If neither +sym+ nor +str+ is not a valid constant name a NameError will be - * raised with a warning "wrong constant name". + * Math.const_defined?(:String) #=> true, found in Object + * + * In each of the checked classes or modules, if the constant is not present + * but there is an autoload for it, +true+ is returned directly without + * autoloading: + * + * module Admin + * autoload :User, 'admin/user' + * end + * Admin.const_defined?(:User) #=> true + * + * If the constant is not found the callback +const_missing+ is *not* called + * and the method returns +false+. + * + * If +inherit+ is false, the lookup only checks the constants in the receiver: * - * Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar + * IO.const_defined?(:SYNC) #=> true, found in File::Constants (ancestor) + * IO.const_defined?(:SYNC, false) #=> false, not found in IO itself + * + * In this case, the same logic for autoloading applies. + * + * If the argument is not a valid constant name a +NameError+ is raised with the + * message "wrong constant name _name_": + * + * Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar * */ @@ -2373,10 +2388,10 @@ rb_obj_ivar_get(VALUE obj, VALUE iv) * obj.instance_variable_set(symbol, obj) -> obj * obj.instance_variable_set(string, obj) -> obj * - * Sets the instance variable names by symbol to - * object, thereby frustrating the efforts of the class's + * Sets the instance variable named by symbol to the given + * object, thereby frustrating the efforts of the class's * author to attempt to provide proper encapsulation. The variable - * did not have to exist prior to this call. + * does not have to exist prior to this call. * If the instance variable name is passed as a string, that string * is converted to a symbol. * @@ -2446,7 +2461,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv) * * Returns the value of the given class variable (or throws a * NameError exception). The @@ part of the - * variable name should be included for regular class variables + * variable name should be included for regular class variables. * String arguments are converted to symbols. * * class Fred @@ -2482,8 +2497,8 @@ rb_mod_cvar_get(VALUE obj, VALUE iv) * obj.class_variable_set(symbol, obj) -> obj * obj.class_variable_set(string, obj) -> obj * - * Sets the class variable names by symbol to - * object. + * Sets the class variable named by symbol to the given + * object. * If the class variable name is passed as a string, that string * is converted to a symbol. * @@ -2740,24 +2755,26 @@ rb_Integer(VALUE val) /* * call-seq: - * Integer(arg,base=0) -> integer + * Integer(arg, base=0) -> integer * * Converts arg to a Fixnum or Bignum. * Numeric types are converted directly (with floating point numbers - * being truncated). base (0, or between 2 and 36) is a base for + * being truncated). base (0, or between 2 and 36) is a base for * integer string representation. If arg is a String, - * when base is omitted or equals to zero, radix indicators + * when base is omitted or equals zero, radix indicators * (0, 0b, and 0x) are honored. * In any case, strings should be strictly conformed to numeric * representation. This behavior is different from that of - * String#to_i. Non string values will be converted using - * to_int, and to_i. + * String#to_i. Non string values will be converted by first + * trying to_int, then to_i. Passing nil + * raises a TypeError. * * Integer(123.999) #=> 123 * Integer("0x1a") #=> 26 * Integer(Time.new) #=> 1204973019 * Integer("0930", 10) #=> 930 * Integer("111", 2) #=> 7 + * Integer(nil) #=> TypeError */ static VALUE @@ -2923,8 +2940,8 @@ rb_Float(VALUE val) * Float(arg) -> float * * Returns arg converted to a float. Numeric types are converted - * directly, the rest are converted using arg.to_f. As of Ruby - * 1.8, converting nil generates a TypeError. + * directly, the rest are converted using arg.to_f. + * Converting nil generates a TypeError. * * Float(1) #=> 1.0 * Float("123.456") #=> 123.456 @@ -2996,8 +3013,9 @@ rb_String(VALUE val) * call-seq: * String(arg) -> string * - * Converts arg to a String by calling its - * to_s method. + * Returns arg as a String. + * + * First tries to call its to_str method, then its to_s method. * * String(self) #=> "main" * String(self.class) #=> "Object" @@ -3030,7 +3048,7 @@ rb_Array(VALUE val) * * Returns +arg+ as an Array. * - * First tries to call Array#to_ary on +arg+, then Array#to_a. + * First tries to call to_ary on +arg+, then to_a. * * Array(1..5) #=> [1, 2, 3, 4, 5] */ @@ -3085,7 +3103,7 @@ rb_f_hash(VALUE obj, VALUE arg) * Typically, you create a new class by using: * * class Name - * # some class describing the class behavior + * # some code describing the class behavior * end * * When a new class is created, an object of type Class is initialized and @@ -3097,19 +3115,17 @@ rb_f_hash(VALUE obj, VALUE arg) * Class: * * class Class - * alias oldNew new - * def new(*args) - * print "Creating a new ", self.name, "\n" - * oldNew(*args) - * end - * end - * - * - * class Name - * end + * alias old_new new + * def new(*args) + * print "Creating a new ", self.name, "\n" + * old_new(*args) + * end + * end * + * class Name + * end * - * n = Name.new + * n = Name.new * * produces: * @@ -3117,7 +3133,7 @@ rb_f_hash(VALUE obj, VALUE arg) * * Classes, modules, and objects are interrelated. In the diagram * that follows, the vertical arrows represent inheritance, and the - * parentheses meta-classes. All metaclasses are instances + * parentheses metaclasses. All metaclasses are instances * of the class `Class'. * +---------+ +-... * | | | @@ -3178,7 +3194,7 @@ rb_f_hash(VALUE obj, VALUE arg) * * BasicObject does not include Kernel (for methods like +puts+) and * BasicObject is outside of the namespace of the standard library so common - * classes will not be found without a using a full class path. + * classes will not be found without using a full class path. * * A variety of strategies can be used to provide useful portions of the * standard library to subclasses of BasicObject. A subclass could @@ -3216,7 +3232,7 @@ rb_f_hash(VALUE obj, VALUE arg) * * Object is the default root of all Ruby objects. Object inherits from * BasicObject which allows creating alternate object hierarchies. Methods - * on object are available to all classes unless explicitly overridden. + * on Object are available to all classes unless explicitly overridden. * * Object mixes in the Kernel module, making the built-in kernel functions * globally accessible. Although the instance methods of Object are defined diff --git a/parse.y b/parse.y index 5c62e36d23cfd7..d091a0e6ef4a9d 100644 --- a/parse.y +++ b/parse.y @@ -2046,8 +2046,8 @@ arg : lhs '=' arg value_expr($1); value_expr($3); $$ = NEW_DOT2($1, $3); - if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && + $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } /*% @@ -2060,8 +2060,8 @@ arg : lhs '=' arg value_expr($1); value_expr($3); $$ = NEW_DOT3($1, $3); - if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && + $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } /*% @@ -4033,7 +4033,13 @@ symbol_list : /* none */ { /*%%%*/ $2 = evstr2dstr($2); - nd_set_type($2, NODE_DSYM); + if (nd_type($2) == NODE_DSTR) { + nd_set_type($2, NODE_DSYM); + } + else { + nd_set_type($2, NODE_LIT); + $2->nd_lit = rb_str_intern($2->nd_lit); + } $$ = list_append($1, $2); /*% $$ = dispatch2(symbols_add, $1, $2); diff --git a/proc.c b/proc.c index 66ffa4c0410f27..a13452329de747 100644 --- a/proc.c +++ b/proc.c @@ -2317,7 +2317,10 @@ static VALUE method_proc(VALUE method) { VALUE procval; + struct METHOD *meth; rb_proc_t *proc; + rb_env_t *env; + /* * class Method * def to_proc @@ -2327,9 +2330,16 @@ method_proc(VALUE method) * end * end */ + TypedData_Get_Struct(method, struct METHOD, &method_data_type, meth); procval = rb_iterate(mlambda, 0, bmcall, method); GetProcPtr(procval, proc); proc->is_from_method = 1; + proc->block.self = meth->recv; + proc->block.klass = meth->defined_class; + GetEnvPtr(proc->envval, env); + env->block.self = meth->recv; + env->block.klass = meth->defined_class; + env->block.iseq = method_get_iseq(meth->me->def); return procval; } diff --git a/rational.c b/rational.c index 7bc72063768d51..d8bee601e09937 100644 --- a/rational.c +++ b/rational.c @@ -584,6 +584,8 @@ f_rational_new_no_reduce2(VALUE klass, VALUE x, VALUE y) * * Rational(1, 2) #=> (1/2) * Rational('1/2') #=> (1/2) + * Rational(nil) #=> TypeError + * Rational(1, nil) #=> TypeError * * Syntax of string form: * diff --git a/signal.c b/signal.c index 3db044e517a2fd..346d68d7587f16 100644 --- a/signal.c +++ b/signal.c @@ -601,6 +601,17 @@ posix_signal(int signum, sighandler_t handler) return ruby_signal(signum, handler); } +#elif defined _WIN32 +static inline sighandler_t +ruby_signal(int signum, sighandler_t handler) +{ + if (signum == SIGKILL) { + errno = EINVAL; + return SIG_ERR; + } + return signal(signum, handler); +} + #else /* !POSIX_SIGNAL */ #define ruby_signal(sig,handler) (/* rb_trap_accept_nativethreads[(sig)] = 0,*/ signal((sig),(handler))) #if 0 /* def HAVE_NATIVETHREAD */ @@ -769,7 +780,8 @@ sigbus(int sig SIGINFO_ARG) * and it's delivered as SIGBUS instead of SIGSEGV to userland. It's crazy * wrong IMHO. but anyway we have to care it. Sigh. */ -#if defined __APPLE__ + /* Seems Linux also delivers SIGBUS. */ +#if defined __APPLE__ || defined __linux__ CHECK_STACK_OVERFLOW(); #endif rb_bug("Bus Error" MESSAGE_FAULT_ADDRESS); diff --git a/spec/default.mspec b/spec/default.mspec index c4b75f614aa3a3..e45526c7aceec0 100644 --- a/spec/default.mspec +++ b/spec/default.mspec @@ -1,4 +1,4 @@ -load File.dirname(__FILE__) + '/rubyspec/ruby.1.9.mspec' +load File.dirname(__FILE__) + '/rubyspec/default.mspec' class MSpecScript builddir = Dir.pwd srcdir = ENV['SRCDIR'] diff --git a/string.c b/string.c index d4ad1cd3a7a08a..338648fa28819b 100644 --- a/string.c +++ b/string.c @@ -7078,15 +7078,18 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) * from the end of str (if present). If $/ has not been * changed from the default Ruby record separator, then chomp also * removes carriage return characters (that is it will remove \n, - * \r, and \r\n). - * - * "hello".chomp #=> "hello" - * "hello\n".chomp #=> "hello" - * "hello\r\n".chomp #=> "hello" - * "hello\n\r".chomp #=> "hello\n" - * "hello\r".chomp #=> "hello" - * "hello \n there".chomp #=> "hello \n there" - * "hello".chomp("llo") #=> "he" + * \r, and \r\n). If $/ is an empty string, + * it will remove all trailing newlines from the string. + * + * "hello".chomp #=> "hello" + * "hello\n".chomp #=> "hello" + * "hello\r\n".chomp #=> "hello" + * "hello\n\r".chomp #=> "hello\n" + * "hello\r".chomp #=> "hello" + * "hello \n there".chomp #=> "hello \n there" + * "hello".chomp("llo") #=> "he" + * "hello\r\n\r\n".chomp('') #=> "hello" + * "hello\r\n\r\r\n".chomp('') #=> "hello\r\n\r" */ static VALUE diff --git a/test/etc/test_etc.rb b/test/etc/test_etc.rb index c105122af12481..946be9bdf664db 100644 --- a/test/etc/test_etc.rb +++ b/test/etc/test_etc.rb @@ -4,7 +4,9 @@ class TestEtc < Test::Unit::TestCase def test_getlogin s = Etc.getlogin - assert(s.is_a?(String) || s == nil, "getlogin must return a String or nil") + return if s == nil + assert(s.is_a?(String), "getlogin must return a String or nil") + assert_predicate(s, :valid_encoding?, "login name should be a valid string") end def test_passwd diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb index cde3fa816dcef9..0bb6c823e395a9 100644 --- a/test/fiddle/test_handle.rb +++ b/test/fiddle/test_handle.rb @@ -37,9 +37,9 @@ def test_static_sym assert_equal Fiddle::Handle.sym('dlopen'), Fiddle::Handle['dlopen'] rescue # NetBSD - require 'objspace' - refute_nil Fiddle::Handle.sym('Init_objspace') - assert_equal Fiddle::Handle.sym('Init_objspace'), Fiddle::Handle['Init_objspace'] + require '-test-/dln/empty' + refute_nil Fiddle::Handle.sym('Init_empty') + assert_equal Fiddle::Handle.sym('Init_empty'), Fiddle::Handle['Init_empty'] end end @@ -166,9 +166,9 @@ def test_NEXT # interface, below, should be used, since getpid() is a function and not a # data object.) # --- FreeBSD 8.0 dlsym(3) - require 'objspace' + require '-test-/dln/empty' handle = Handle::NEXT - refute_nil handle['Init_objspace'] + refute_nil handle['Init_empty'] end end unless /mswin|mingw/ =~ RUBY_PLATFORM diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index a9de376a2b5b9c..91e1c8b1624ca4 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -217,18 +217,22 @@ def test_winsize end if IO.console + def test_close + IO.console.close + assert_kind_of(IO, IO.console) + assert_nothing_raised(IOError) {IO.console.fileno} + end + def test_sync assert(IO.console.sync, "console should be unbuffered") end else + def test_close + assert_equal(["true"], run_pty("IO.console.close; p IO.console.fileno >= 0")) + end + def test_sync - r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", "p IO.console.class") - rescue RuntimeError - skip $! - else - con = r.gets.chomp - Process.wait(pid) - assert_match("File", con) + assert_equal(["true"], run_pty("p IO.console.sync")) end end @@ -243,6 +247,24 @@ def helper m.close if m s.close if s end + + def run_pty(src, n = 1) + r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", src) + rescue RuntimeError + skip $! + else + result = [] + n.times {result << r.gets.chomp} + Process.wait(pid) + if block_given? + yield result + else + result + end + ensure + r.close if r + w.close if w + end end if defined?(PTY) and defined?(IO::console) class TestIO_Console < Test::Unit::TestCase diff --git a/test/io/wait/test_io_wait.rb b/test/io/wait/test_io_wait.rb index 46097e00c69dcd..6d8b0442ae2000 100644 --- a/test/io/wait/test_io_wait.rb +++ b/test/io/wait/test_io_wait.rb @@ -31,7 +31,7 @@ def test_nread def test_nread_buffered @w.syswrite ".\n!" - assert_equal ".\n", @r.read(2) + assert_equal ".\n", @r.gets assert_equal 1, @r.nread end diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb index ea6a9d80f435f8..92825eecf7c47e 100644 --- a/test/mkmf/base.rb +++ b/test/mkmf/base.rb @@ -3,6 +3,7 @@ require 'test/unit' require 'mkmf' require 'tmpdir' +require_relative '../ruby/envutil' $extout = '$(topdir)/'+RbConfig::CONFIG["EXTOUT"] RbConfig::CONFIG['topdir'] = CONFIG['topdir'] = File.expand_path(CONFIG['topdir']) diff --git a/test/mkmf/test_flags.rb b/test/mkmf/test_flags.rb index 4e0d5f66a230fc..e49d474dc904f4 100644 --- a/test/mkmf/test_flags.rb +++ b/test/mkmf/test_flags.rb @@ -34,21 +34,21 @@ def test_valid_warnflags def test_try_ldflag_invalid_opt assert_separately([], <<-'end;') #do - assert(!try_ldflags("----------")) + assert(!try_ldflags("nosuch.c"), TestMkmf::MKMFLOG) assert(have_devel?, TestMkmf::MKMFLOG) end; end def test_try_cflag_invalid_opt assert_separately([], <<-'end;') #do - assert(!try_cflags("----------")) + assert(!try_cflags("nosuch.c"), TestMkmf::MKMFLOG) assert(have_devel?, TestMkmf::MKMFLOG) end; end def test_try_cppflag_invalid_opt assert_separately([], <<-'end;') #do - assert(!try_cppflags("----------")) + assert(!try_cppflags("nosuch.c"), TestMkmf::MKMFLOG) assert(have_devel?, TestMkmf::MKMFLOG) end; end diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 6c847dba7e7cd6..60d9d761504f59 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -574,6 +574,7 @@ def _test_request__uri_host(http) def test_send_request start {|http| _test_send_request__GET http + _test_send_request__HEAD http _test_send_request__POST http } end @@ -588,6 +589,16 @@ def _test_send_request__GET(http) assert_equal $test_net_http_data, res.body end + def _test_send_request__HEAD(http) + res = http.send_request('HEAD', '/') + assert_kind_of Net::HTTPResponse, res + unless self.is_a?(TestNetHTTP_v1_2_chunked) + assert_not_nil res['content-length'] + assert_equal $test_net_http_data.size, res['content-length'].to_i + end + assert_nil res.body + end + def _test_send_request__POST(http) data = 'aaabbb cc ddddddddddd lkjoiu4j3qlkuoa' res = http.send_request('POST', '/', data, 'content-type' => 'application/x-www-form-urlencoded') diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb index 974f8296cc08e2..0193a153e467db 100644 --- a/test/net/http/test_httpresponse.rb +++ b/test/net/http/test_httpresponse.rb @@ -244,6 +244,65 @@ def test_uri_equals refute_same uri, response.uri end + def test_ensure_zero_space_does_not_regress + io = dummy_io(< e + next if /wrap/ =~ name and e.message == 'wrap mode not allowed' + raise + end } end diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index b743819518f7b5..68a2543485fda3 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -359,6 +359,156 @@ def test_verify_certificate_identity end end + def test_verify_hostname + assert_equal(true, OpenSSL::SSL.verify_hostname("www.example.com", "*.example.com")) + assert_equal(false, OpenSSL::SSL.verify_hostname("www.subdomain.example.com", "*.example.com")) + end + + def test_verify_wildcard + assert_equal(false, OpenSSL::SSL.verify_wildcard("foo", "x*")) + assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "foo")) + assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "f*")) + assert_equal(true, OpenSSL::SSL.verify_wildcard("foo", "*")) + assert_equal(false, OpenSSL::SSL.verify_wildcard("abc*bcd", "abcd")) + assert_equal(false, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "x*")) + assert_equal(false, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "*--qdk4b9b")) + assert_equal(true, OpenSSL::SSL.verify_wildcard("xn--qdk4b9b", "xn--qdk4b9b")) + end + + # Comments in this test is excerpted from http://tools.ietf.org/html/rfc6125#page-27 + def test_post_connection_check_wildcard_san + # case-insensitive ASCII comparison + # RFC 6125, section 6.4.1 + # + # "..matching of the reference identifier against the presented identifier + # is performed by comparing the set of domain name labels using a + # case-insensitive ASCII comparison, as clarified by [DNS-CASE] (e.g., + # "WWW.Example.Com" would be lower-cased to "www.example.com" for + # comparison purposes) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.example.com'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.Example.COM'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.example.com'), 'WWW.Example.COM')) + # 1. The client SHOULD NOT attempt to match a presented identifier in + # which the wildcard character comprises a label other than the + # left-most label (e.g., do not match bar.*.example.net). + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:www.*.com'), 'www.example.com')) + # 2. If the wildcard character is the only character of the left-most + # label in the presented identifier, the client SHOULD NOT compare + # against anything but the left-most label of the reference + # identifier (e.g., *.example.com would match foo.example.com but + # not bar.foo.example.com or example.com). + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.example.com'), 'foo.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*.example.com'), 'bar.foo.example.com')) + # 3. The client MAY match a presented identifier in which the wildcard + # character is not the only character of the label (e.g., + # baz*.example.net and *baz.example.net and b*z.example.net would + # be taken to match baz1.example.net and foobaz.example.net and + # buzz.example.net, respectively). ... + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:baz*.example.com'), 'baz1.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*baz.example.com'), 'foobaz.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:b*z.example.com'), 'buzz.example.com')) + # Section 6.4.3 of RFC6125 states that client should NOT match identifier + # where wildcard is other than left-most label. + # + # Also implicitly mentions the wildcard character only in singular form, + # and discourages matching against more than one wildcard. + # + # See RFC 6125, section 7.2, subitem 2. + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*b*.example.com'), 'abc.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*b*.example.com'), 'ab.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:*b*.example.com'), 'bc.example.com')) + # ... However, the client SHOULD NOT + # attempt to match a presented identifier where the wildcard + # character is embedded within an A-label or U-label [IDNA-DEFS] of + # an internationalized domain name [IDNA-PROTO]. + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:xn*.example.com'), 'xn1ca.example.com')) + # part of A-label + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:xn--*.example.com'), 'xn--1ca.example.com')) + # part of U-label + # dNSName in RFC5280 is an IA5String so U-label should NOT be allowed + # regardless of wildcard. + # + # See Section 7.2 of RFC 5280: + # IA5String is limited to the set of ASCII characters. + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_san('DNS:á*.example.com'), 'á1.example.com')) + end + + def test_post_connection_check_wildcard_cn + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.example.com'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.Example.COM'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.example.com'), 'WWW.Example.COM')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('www.*.com'), 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.example.com'), 'foo.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*.example.com'), 'bar.foo.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('baz*.example.com'), 'baz1.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*baz.example.com'), 'foobaz.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('b*z.example.com'), 'buzz.example.com')) + # Section 6.4.3 of RFC6125 states that client should NOT match identifier + # where wildcard is other than left-most label. + # + # Also implicitly mentions the wildcard character only in singular form, + # and discourages matching against more than one wildcard. + # + # See RFC 6125, section 7.2, subitem 2. + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*b*.example.com'), 'abc.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*b*.example.com'), 'ab.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('*b*.example.com'), 'bc.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('xn*.example.com'), 'xn1ca.example.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('xn--*.example.com'), 'xn--1ca.example.com')) + # part of U-label + # Subject in RFC5280 states case-insensitive ASCII comparison. + # + # See Section 7.2 of RFC 5280: + # IA5String is limited to the set of ASCII characters. + assert_equal(false, OpenSSL::SSL.verify_certificate_identity( + create_cert_with_name('á*.example.com'), 'á1.example.com')) + end + + def create_cert_with_san(san) + ef = OpenSSL::X509::ExtensionFactory.new + cert = OpenSSL::X509::Certificate.new + cert.subject = OpenSSL::X509::Name.parse("/DC=some/DC=site/CN=Some Site") + ext = ef.create_ext('subjectAltName', san) + cert.add_extension(ext) + cert + end + + def create_cert_with_name(name) + cert = OpenSSL::X509::Certificate.new + cert.subject = OpenSSL::X509::Name.new([['DC', 'some'], ['DC', 'site'], ['CN', name]]) + cert + end + + # Create NULL byte SAN certificate def create_null_byte_SAN_certificate(critical = false) ef = OpenSSL::X509::ExtensionFactory.new diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index b0c464a659dd6a..a69989d15d6ab5 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -56,6 +56,9 @@ def test_expand_tabs assert_equal('. .', expand_tabs(".\t\t."), 'dot tab tab dot') + + assert_equal('a a', + Timeout.timeout(1) {expand_tabs("\ra\ta")}, "carriage return") end def test_expand_tabs_encoding diff --git a/test/resolv/test_addr.rb b/test/resolv/test_addr.rb index e06c3c2a4cef79..b4718430cca5f0 100644 --- a/test/resolv/test_addr.rb +++ b/test/resolv/test_addr.rb @@ -17,7 +17,7 @@ def test_invalid_ipv4_address def test_invalid_byte_comment bug9273 = '[ruby-core:59239] [Bug #9273]' - Tempfile.create('resolv_test_addr_') do |tmpfile| + Tempfile.open('resolv_test_addr_') do |tmpfile| tmpfile.print("\xff\x00\x40") tmpfile.close hosts = Resolv::Hosts.new(tmpfile.path) diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb index e07840f855a159..e91d127f350c10 100644 --- a/test/resolv/test_dns.rb +++ b/test/resolv/test_dns.rb @@ -23,6 +23,20 @@ def with_udp(host, port) end end + # [ruby-core:65836] + def test_resolve_with_2_ndots + conf = Resolv::DNS::Config.new :nameserver => ['127.0.0.1'], :ndots => 2 + assert conf.single? + + candidates = [] + conf.resolv('example.com') { |candidate, *args| + candidates << candidate + raise Resolv::DNS::Config::NXDomain + } + n = Resolv::DNS::Name.create 'example.com.' + assert_equal n, candidates.last + end + def test_query_ipv4_address begin OpenSSL @@ -153,7 +167,7 @@ def test_no_server def test_invalid_byte_comment bug9273 = '[ruby-core:59239] [Bug #9273]' - Tempfile.create('resolv_test_dns_') do |tmpfile| + Tempfile.open('resolv_test_dns_') do |tmpfile| tmpfile.print("\xff\x00\x40") tmpfile.close assert_nothing_raised(ArgumentError, bug9273) do @@ -161,4 +175,17 @@ def test_invalid_byte_comment end end end + + def test_dots_diffences + name1 = Resolv::DNS::Name.create("example.org") + name2 = Resolv::DNS::Name.create("ex.ampl.eo.rg") + assert_not_equal(name1, name2, "different dots") + end + + def test_case_insensitive_name + bug10550 = '[ruby-core:66498] [Bug #10550]' + lower = Resolv::DNS::Name.create("ruby-lang.org") + upper = Resolv::DNS::Name.create("Ruby-Lang.org") + assert_equal(lower, upper, bug10550) + end end diff --git a/test/resolv/test_resource.rb b/test/resolv/test_resource.rb new file mode 100644 index 00000000000000..7ec17e33e79f7c --- /dev/null +++ b/test/resolv/test_resource.rb @@ -0,0 +1,21 @@ +require 'test/unit' +require 'resolv' + +class TestResolvResource < Test::Unit::TestCase + def setup + address = "192.168.0.1" + @name1 = Resolv::DNS::Resource::IN::A.new(address) + @name1.instance_variable_set(:@ttl, 100) + @name2 = Resolv::DNS::Resource::IN::A.new(address) + end + + def test_equality + bug10857 = '[ruby-core:68128] [Bug #10857]' + assert_equal(@name1, @name2, bug10857) + end + + def test_hash + bug10857 = '[ruby-core:68128] [Bug #10857]' + assert_equal(@name1.hash, @name2.hash, bug10857) + end +end diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index cf0ac9803e7dc6..77ab97317a6e4c 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2896,7 +2896,7 @@ def test_io_select_with_many_files } IO.select(tempfiles) - }, bug8080 + }, bug8080, timeout: 30 end def test_read_32bit_boundary diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index e4c35e03d9226f..5fa326acfec25c 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -434,4 +434,14 @@ def test_float } end + def test_symbol_list + assert_equal([:foo, :bar], %i[foo bar]) + assert_equal([:"\"foo"], %i["foo]) + + x = 10 + assert_equal([:foo, :b10], %I[foo b#{x}]) + assert_equal([:"\"foo10"], %I["foo#{x}]) + + assert_ruby_status(["--disable-gems", "--dump=parsetree"], "%I[foo bar]") + end end diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 050d17a5d3fd1c..9910e261d536cd 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1708,6 +1708,17 @@ def hello assert_equal('hello!', foo.new.hello, bug9236) end + def test_prepend_call_super + assert_separately([], <<-'end;') #do + bug10847 = '[ruby-core:68093] [Bug #10847]' + module M; end + Float.prepend M + assert_nothing_raised(SystemStackError, bug10847) do + 0.3.numerator + end + end; + end + def test_class_variables m = Module.new m.class_variable_set(:@@foo, 1) diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index a4198f8ed426a8..6eb7c8b2059313 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -98,4 +98,11 @@ def test_each_object } End end + + def test_each_object_recursive_key + assert_normal_exit(<<-'end;', '[ruby-core:66742] [Bug #10579]') + h = {["foo"]=>nil} + p Thread.current[:__recursive_key__] + end; + end end diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 1c8a053cca84fe..06f137fdd1ca46 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -202,7 +202,10 @@ def m_block_given? def test_method_to_proc b = block() assert_equal "OK", b.call - assert_instance_of(Binding, b.binding, '[ruby-core:25589]') + b = b.binding + assert_instance_of(Binding, b, '[ruby-core:25589]') + bug10432 = '[ruby-core:65919] [Bug #10432]' + assert_same(self, b.eval("self"), bug10432) end def test_block_given_method diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 77e4789bfc7a37..4ed0423abdd0fe 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1165,6 +1165,238 @@ def foo assert_raise(NoMethodError, bug10106) {Object.new.foo} end; + + assert_separately([], <<-"end;") + bug10707 = '[ruby-core:67389] [Bug #10707]' + module RefinementBug + refine BasicObject do + def foo + end + end + end + + assert(methods, bug10707) + assert_raise(NameError, bug10707) {method(:foo)} + end; + end + + def test_change_refined_new_method_visibility + assert_separately([], <<-"end;") + bug10706 = '[ruby-core:67387] [Bug #10706]' + module RefinementBug + refine Object do + def foo + end + end + end + + assert_raise(NameError, bug10706) {private(:foo)} + end; + end + + def test_alias_refined_method + assert_separately([], <<-"end;") + bug10731 = '[ruby-core:67523] [Bug #10731]' + + class C + end + + module RefinementBug + refine C do + def foo + end + + def bar + end + end + end + + assert_raise(NameError, bug10731) do + class C + alias foo bar + end + end + end; + end + + def test_refined_method_defined + assert_separately([], <<-"end;") + bug10753 = '[ruby-core:67656] [Bug #10753]' + + c = Class.new do + def refined_public; end + def refined_protected; end + def refined_private; end + + public :refined_public + protected :refined_protected + private :refined_private + end + + m = Module.new do + refine(c) do + def refined_public; end + def refined_protected; end + def refined_private; end + + public :refined_public + protected :refined_protected + private :refined_private + end + end + + using m + + assert_equal(true, c.public_method_defined?(:refined_public), bug10753) + assert_equal(false, c.public_method_defined?(:refined_protected), bug10753) + assert_equal(false, c.public_method_defined?(:refined_private), bug10753) + + assert_equal(false, c.protected_method_defined?(:refined_public), bug10753) + assert_equal(true, c.protected_method_defined?(:refined_protected), bug10753) + assert_equal(false, c.protected_method_defined?(:refined_private), bug10753) + + assert_equal(false, c.private_method_defined?(:refined_public), bug10753) + assert_equal(false, c.private_method_defined?(:refined_protected), bug10753) + assert_equal(true, c.private_method_defined?(:refined_private), bug10753) + end; + end + + def test_undefined_refined_method_defined + assert_separately([], <<-"end;") + bug10753 = '[ruby-core:67656] [Bug #10753]' + + c = Class.new + + m = Module.new do + refine(c) do + def undefined_refined_public; end + def undefined_refined_protected; end + def undefined_refined_private; end + public :undefined_refined_public + protected :undefined_refined_protected + private :undefined_refined_private + end + end + + using m + + assert_equal(false, c.public_method_defined?(:undefined_refined_public), bug10753) + assert_equal(false, c.public_method_defined?(:undefined_refined_protected), bug10753) + assert_equal(false, c.public_method_defined?(:undefined_refined_private), bug10753) + + assert_equal(false, c.protected_method_defined?(:undefined_refined_public), bug10753) + assert_equal(false, c.protected_method_defined?(:undefined_refined_protected), bug10753) + assert_equal(false, c.protected_method_defined?(:undefined_refined_private), bug10753) + + assert_equal(false, c.private_method_defined?(:undefined_refined_public), bug10753) + assert_equal(false, c.private_method_defined?(:undefined_refined_protected), bug10753) + assert_equal(false, c.private_method_defined?(:undefined_refined_private), bug10753) + end; + end + + def test_remove_refined_method + assert_separately([], <<-"end;") + bug10765 = '[ruby-core:67722] [Bug #10765]' + + class C + def foo + "C#foo" + end + end + + module RefinementBug + refine C do + def foo + "RefinementBug#foo" + end + end + end + + using RefinementBug + + class C + remove_method :foo + end + + assert_equal("RefinementBug#foo", C.new.foo, bug10765) + end; + end + + def test_remove_undefined_refined_method + assert_separately([], <<-"end;") + bug10765 = '[ruby-core:67722] [Bug #10765]' + + class C + end + + module RefinementBug + refine C do + def foo + end + end + end + + using RefinementBug + + assert_raise(NameError, bug10765) { + class C + remove_method :foo + end + } + end; + end + + module NotIncludeSuperclassMethod + class X + def foo + end + end + + class Y < X + end + + module Bar + refine Y do + def foo + end + end + end + end + + def test_instance_methods_not_include_superclass_method + bug10826 = '[ruby-dev:48854] [Bug #10826]' + assert_not_include(NotIncludeSuperclassMethod::Y.instance_methods(false), + :foo, bug10826) + assert_include(NotIncludeSuperclassMethod::Y.instance_methods(true), + :foo, bug10826) + end + + def test_call_refined_method_in_duplicate_module + bug10885 = '[ruby-dev:48878]' + assert_in_out_err([], <<-INPUT, [], [], bug10885) + module M + refine Object do + def raise + # do nothing + end + end + + class << self + using M + def m0 + raise + end + end + + using M + def M.m1 + raise + end + end + + M.dup.m0 + M.dup.m1 + INPUT end private diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 3bd327c8517607..2bdad8f981ca4d 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -307,6 +307,28 @@ def test_load2 # [ruby-core:25039] } end + def test_load_ospath + bug = '[ruby-list:49994] path in ospath' + base = "test_load\u{3042 3044 3046 3048 304a}".encode(Encoding::Windows_31J) + path = nil + Tempfile.create([base, ".rb"]) do |t| + path = t.path + + assert_raise_with_message(LoadError, /#{base}/) { + load(File.join(File.dirname(path), base)) + } + + t.puts "warn 'ok'" + t.close + assert_include(path, base) + assert_warn("ok\n", bug) { + assert_nothing_raised(LoadError, bug) { + load(path) + } + } + end + end + def test_tainted_loadpath Tempfile.create(["test_ruby_test_require", ".rb"]) {|t| abs_dir, file = File.split(t.path) diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index eff35c18daac47..9fc3fd059fbe44 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -194,8 +194,9 @@ def test_float sprintf("%20.0f", 36893488147419107329.0)) assert_equal(" Inf", sprintf("% 0e", 1.0/0.0), "moved from btest/knownbug") assert_equal(" -0.", sprintf("%#10.0f", -0.5), "[ruby-dev:42552]") - assert_equal("0x1p+2", sprintf('%.0a', Float('0x1.fp+1')), "[ruby-dev:42551]") - assert_equal("-0x1.0p+2", sprintf('%.1a', Float('-0x1.ffp+1')), "[ruby-dev:42551]") + # out of spec + #assert_equal("0x1p+2", sprintf('%.0a', Float('0x1.fp+1')), "[ruby-dev:42551]") + #assert_equal("-0x1.0p+2", sprintf('%.1a', Float('-0x1.ffp+1')), "[ruby-dev:42551]") end def test_float_hex diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index e510a4984ccd23..4942621392500c 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2227,7 +2227,7 @@ def =~(str) def test_LSHIFT_neary_long_max return unless @cls == String - assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]', timeout: 20) + assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]', timeout: 60) begin a = "a" * 0x4000_0000 a << "a" * 0x1_0000 diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 2ed57889ba5e05..692763ef98cb7b 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -408,6 +408,14 @@ def test_error_message_encoding assert_syntax_error(code, /def n "\u{2208}"; end/, bug10114) end + def test_null_range_cmdarg + bug10957 = '[ruby-core:68477] [Bug #10957]' + assert_ruby_status(['-c', '-e', 'p ()..0'], "", bug10957) + assert_ruby_status(['-c', '-e', 'p ()...0'], "", bug10957) + assert_syntax_error('0..%w.', /unterminated string/, bug10957) + assert_syntax_error('0...%w.', /unterminated string/, bug10957) + end + private def not_label(x) @result = x; @not_label ||= nil end diff --git a/test/thread/test_cv.rb b/test/thread/test_cv.rb index 08459a0a04c526..53f3261390e24e 100644 --- a/test/thread/test_cv.rb +++ b/test/thread/test_cv.rb @@ -195,6 +195,14 @@ def test_condvar_empty_broadcast assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} } end + def test_dup + bug9440 = '[ruby-core:59961] [Bug #9440]' + condvar = ConditionVariable.new + assert_raise(NoMethodError, bug9440) do + condvar.dup + end + end + (DumpableCV = ConditionVariable.dup).class_eval {remove_method :marshal_dump} def test_dump diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 314ee98dab0ddb..c33cb6dc8adfd9 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -220,6 +220,14 @@ def test_queue_thread_raise end end + def test_dup + bug9440 = '[ruby-core:59961] [Bug #9440]' + q = Queue.new + assert_raise(NoMethodError, bug9440) do + q.dup + end + end + (DumpableQueue = Queue.dup).class_eval {remove_method :marshal_dump} def test_dump diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index b5b1fc1c2637c3..c9e3576a8036a5 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -741,12 +741,26 @@ def test_ipv6 end def test_build - URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil]) + u = URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil]) + assert_equal('http://example.com:80/foo', u.to_s) + + u = URI::Generic.build(:scheme => "http", :host => "::1", :path => "/bar/baz") + assert_equal("http://[::1]/bar/baz", u.to_s) + assert_equal("[::1]", u.host) + assert_equal("::1", u.hostname) + + u = URI::Generic.build(:scheme => "http", :host => "[::1]", :path => "/bar/baz") + assert_equal("http://[::1]/bar/baz", u.to_s) + assert_equal("[::1]", u.host) + assert_equal("::1", u.hostname) end def test_build2 - URI::Generic.build2(path: "/foo bar/baz") - URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil]) + u = URI::Generic.build2(path: "/foo bar/baz") + assert_equal('/foo%20bar/baz', u.to_s) + + u = URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil]) + assert_equal('http://example.com:80/foo%20bar', u.to_s) end # 192.0.2.0/24 is TEST-NET. [RFC3330] diff --git a/thread.c b/thread.c index d9df90272e8049..605ac60c0820c8 100644 --- a/thread.c +++ b/thread.c @@ -916,10 +916,14 @@ thread_join_m(int argc, VALUE *argv, VALUE self) * call-seq: * thr.value -> obj * - * Waits for +thr+ to complete, using #join, and returns its value. + * Waits for +thr+ to complete, using #join, and returns its value or raises + * the exception which terminated the thread. * * a = Thread.new { 2 + 2 } * a.value #=> 4 + * + * b = Thread.new { raise 'something went wrong' } + * b.value #=> RuntimeError: something went wrong */ static VALUE @@ -4763,6 +4767,8 @@ ident_hash_new(void) return hash; } +ID rb_frame_last_func(void); + /* * Returns the current "recursive list" used to detect recursion. * This list is a hash table, unique for the current thread and for @@ -4770,10 +4776,9 @@ ident_hash_new(void) */ static VALUE -recursive_list_access(void) +recursive_list_access(VALUE sym) { volatile VALUE hash = rb_thread_local_aref(rb_thread_current(), recursive_key); - VALUE sym = ID2SYM(rb_frame_this_func()); VALUE list; if (NIL_P(hash) || !RB_TYPE_P(hash, T_HASH)) { hash = ident_hash_new(); @@ -4875,25 +4880,23 @@ recursive_push(VALUE list, VALUE obj, VALUE paired_obj) * Assumes the recursion list is valid. */ -static void +static int recursive_pop(VALUE list, VALUE obj, VALUE paired_obj) { if (paired_obj) { VALUE pair_list = rb_hash_lookup2(list, obj, Qundef); if (pair_list == Qundef) { - VALUE symname = rb_inspect(ID2SYM(rb_frame_this_func())); - VALUE thrname = rb_inspect(rb_thread_current()); - rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list for %s in %s", - StringValuePtr(symname), StringValuePtr(thrname)); + return 0; } if (RB_TYPE_P(pair_list, T_HASH)) { rb_hash_delete(pair_list, paired_obj); if (!RHASH_EMPTY_P(pair_list)) { - return; /* keep hash until is empty */ + return 1; /* keep hash until is empty */ } } } rb_hash_delete(list, obj); + return 1; } struct exec_recursive_params { @@ -4927,9 +4930,11 @@ static VALUE exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE arg, int outer) { VALUE result = Qundef; + const ID mid = rb_frame_last_func(); + const VALUE sym = mid ? ID2SYM(mid) : ID2SYM(idNULL); struct exec_recursive_params p; int outermost; - p.list = recursive_list_access(); + p.list = recursive_list_access(sym); p.objid = rb_obj_id(obj); p.obj = obj; p.pairid = pairid; @@ -4951,8 +4956,8 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE recursive_push(p.list, ID2SYM(recursive_key), 0); recursive_push(p.list, p.objid, p.pairid); result = rb_catch_protect(p.list, exec_recursive_i, (VALUE)&p, &state); - recursive_pop(p.list, p.objid, p.pairid); - recursive_pop(p.list, ID2SYM(recursive_key), 0); + if (!recursive_pop(p.list, p.objid, p.pairid)) goto invalid; + if (!recursive_pop(p.list, ID2SYM(recursive_key), 0)) goto invalid; if (state) JUMP_TAG(state); if (result == p.list) { result = (*func)(obj, arg, TRUE); @@ -4965,7 +4970,12 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE result = (*func)(obj, arg, FALSE); } POP_TAG(); - recursive_pop(p.list, p.objid, p.pairid); + if (!recursive_pop(p.list, p.objid, p.pairid)) { + invalid: + rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list " + "for %+"PRIsVALUE" in %+"PRIsVALUE, + sym, rb_thread_current()); + } if (state) JUMP_TAG(state); } } diff --git a/thread_pthread.c b/thread_pthread.c index 581dfecaaa3d27..f3cd8702f8e9b1 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -648,6 +648,42 @@ space_size(size_t stack_size) } } +#ifdef __linux__ +static __attribute__((noinline)) void +reserve_stack(volatile char *limit, size_t size) +{ +# ifdef C_ALLOCA +# error needs alloca() +# endif + struct rlimit rl; + volatile char buf[0x100]; + STACK_GROW_DIR_DETECTION; + + if (!getrlimit(RLIMIT_STACK, &rl) && rl.rlim_cur == RLIM_INFINITY) + return; + + size -= sizeof(buf); /* margin */ + if (IS_STACK_DIR_UPPER()) { + const volatile char *end = buf + sizeof(buf); + limit += size; + if (limit > end) { + size = limit - end; + limit = alloca(size); + limit[size-1] = 0; + } + } + else { + limit -= size; + if (buf > limit) { + limit = alloca(buf - limit); + limit[0] = 0; + } + } +} +#else +# define reserve_stack(limit, size) ((void)(limit), (void)(size)) +#endif + #undef ruby_init_stack /* Set stack bottom of Ruby implementation. * @@ -669,6 +705,7 @@ ruby_init_stack(volatile VALUE *addr if (get_main_stack(&stackaddr, &size) == 0) { native_main_thread.stack_maxsize = size; native_main_thread.stack_start = stackaddr; + reserve_stack(stackaddr, size); return; } } diff --git a/tool/config.guess b/tool/config.guess new file mode 100755 index 00000000000000..dbfb9786cb6f9b --- /dev/null +++ b/tool/config.guess @@ -0,0 +1,1421 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-01-01' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; +esac + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/tool/config.sub b/tool/config.sub new file mode 100755 index 00000000000000..6d2e94c8bf9ea6 --- /dev/null +++ b/tool/config.sub @@ -0,0 +1,1807 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-01-01' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pyramid-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/tool/config_files.rb b/tool/config_files.rb index 676c355e059f94..9c2a4c7dabeb19 100644 --- a/tool/config_files.rb +++ b/tool/config_files.rb @@ -1,6 +1,6 @@ require 'open-uri' -ConfigFiles = "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=%s;hb=HEAD" +ConfigFiles = "http://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=%s;hb=HEAD" def ConfigFiles.download(name, dir = nil) data = URI(self % name).read file = dir ? File.join(dir, name) : name diff --git a/version.h b/version.h index 54332dc33d0484..11331cb9017734 100644 --- a/version.h +++ b/version.h @@ -1,9 +1,9 @@ -#define RUBY_VERSION "2.1.5" -#define RUBY_RELEASE_DATE "2014-11-13" -#define RUBY_PATCHLEVEL 273 +#define RUBY_VERSION "2.1.6" +#define RUBY_RELEASE_DATE "2015-04-13" +#define RUBY_PATCHLEVEL 336 -#define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 11 +#define RUBY_RELEASE_YEAR 2015 +#define RUBY_RELEASE_MONTH 4 #define RUBY_RELEASE_DAY 13 #include "ruby/version.h" diff --git a/vm_core.h b/vm_core.h index 73127e65eab41d..34a53f07fa8024 100644 --- a/vm_core.h +++ b/vm_core.h @@ -896,6 +896,8 @@ void rb_gc_mark_machine_stack(rb_thread_t *th); int rb_autoloading_value(VALUE mod, ID id, VALUE* value); +void rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr); + #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack] #define RUBY_CONST_ASSERT(expr) (1/!!(expr)) /* expr must be a compile-time constant */ diff --git a/vm_eval.c b/vm_eval.c index dc0b05375b77fd..da6338419fdfa5 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -260,7 +260,8 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv) rb_bug("vm_call_super: should not be reached"); } - klass = RCLASS_SUPER(cfp->klass); + klass = RCLASS_ORIGIN(cfp->klass); + klass = RCLASS_SUPER(klass); id = cfp->me->def->original_id; me = rb_method_entry(klass, id, &klass); if (!me) { @@ -986,6 +987,7 @@ rb_yield_splat(VALUE values) rb_raise(rb_eArgError, "not an array"); } v = rb_yield_0(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp)); + RB_GC_GUARD(tmp); return v; } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index f52a8f562d7b6c..20dc63f1e05d89 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -278,6 +278,27 @@ rb_vm_get_cref(const rb_iseq_t *iseq, const VALUE *ep) return cref; } +void +rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr) +{ + NODE *new_node; + while (node) { + if (node->nd_clss == old_klass) { + new_node = NEW_CREF(new_klass); + COPY_CREF_OMOD(new_node, node); + RB_OBJ_WRITE(new_node, &new_node->nd_next, node->nd_next); + *new_cref_ptr = new_node; + return; + } + new_node = NEW_CREF(node->nd_clss); + COPY_CREF_OMOD(new_node, node); + node = node->nd_next; + *new_cref_ptr = new_node; + new_cref_ptr = &new_node->nd_next; + } + *new_cref_ptr = NULL; +} + static NODE * vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr) { diff --git a/vm_method.c b/vm_method.c index 441d45499be86e..7fbbf99f080a45 100644 --- a/vm_method.c +++ b/vm_method.c @@ -738,12 +738,17 @@ get_original_method_entry(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr) { + VALUE super; + if (me->def->body.orig_me) { return me->def->body.orig_me; } + else if (!(super = RCLASS_SUPER(me->klass))) { + return 0; + } else { rb_method_entry_t *tmp_me; - tmp_me = rb_method_entry(RCLASS_SUPER(me->klass), me->called_id, + tmp_me = rb_method_entry(super, me->called_id, defined_class_ptr); return rb_resolve_refined_method(refinements, tmp_me, defined_class_ptr); @@ -831,10 +836,12 @@ remove_method(VALUE klass, ID mid) if (!st_lookup(RCLASS_M_TBL(klass), mid, &data) || !(me = (rb_method_entry_t *)data) || - (!me->def || me->def->type == VM_METHOD_TYPE_UNDEF)) { + (!me->def || me->def->type == VM_METHOD_TYPE_UNDEF) || + UNDEFINED_REFINED_METHOD_P(me->def)) { rb_name_error(mid, "method `%s' not defined in %s", rb_id2name(mid), rb_class2name(klass)); } + key = (st_data_t)mid; st_delete(RCLASS_M_TBL(klass), &key, &data); @@ -842,6 +849,10 @@ remove_method(VALUE klass, ID mid) rb_clear_method_cache_by_class(klass); rb_unlink_method_entry(me); + if (me->def->type == VM_METHOD_TYPE_REFINED) { + rb_add_refined_method_entry(klass, mid); + } + CALL_METHOD_HOOK(self, removed, mid); } @@ -910,7 +921,8 @@ rb_export_method(VALUE klass, ID name, rb_method_flag_t noex) me = search_method(rb_cObject, name, &defined_class); } - if (UNDEFINED_METHOD_ENTRY_P(me)) { + if (UNDEFINED_METHOD_ENTRY_P(me) || + UNDEFINED_REFINED_METHOD_P(me->def)) { rb_print_undef(klass, name, 0); } @@ -1009,8 +1021,7 @@ rb_undef(VALUE klass, ID id) me = search_method(klass, id, 0); if (UNDEFINED_METHOD_ENTRY_P(me) || - (me->def->type == VM_METHOD_TYPE_REFINED && - UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) { + UNDEFINED_REFINED_METHOD_P(me->def)) { const char *s0 = " class"; VALUE c = klass; @@ -1141,7 +1152,7 @@ check_definition(VALUE mod, VALUE mid, rb_method_flag_t noex) const rb_method_entry_t *me; ID id = rb_check_id(&mid); if (!id) return Qfalse; - me = rb_method_entry(mod, id, 0); + me = rb_method_entry_without_refinements(mod, id, 0); if (me) { if (VISI_CHECK(me->flag, noex)) return Qtrue; @@ -1356,7 +1367,8 @@ rb_alias(VALUE klass, ID name, ID def) again: orig_me = search_method(klass, def, &defined_class); - if (UNDEFINED_METHOD_ENTRY_P(orig_me)) { + if (UNDEFINED_METHOD_ENTRY_P(orig_me) || + UNDEFINED_REFINED_METHOD_P(orig_me->def)) { if ((!RB_TYPE_P(klass, T_MODULE)) || (orig_me = search_method(rb_cObject, def, 0), UNDEFINED_METHOD_ENTRY_P(orig_me))) { diff --git a/win32/win32.c b/win32/win32.c index 3051a97f569050..ed5bfa778e70d4 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -543,11 +543,15 @@ init_env(void) if (!GetEnvironmentVariableW(L"USERNAME", env, numberof(env)) && !GetUserNameW(env, (len = numberof(env), &len))) { NTLoginName = ""; - return; } - set_env_val(L"USER"); + else { + set_env_val(L"USER"); + NTLoginName = rb_w32_wstr_to_mbstr(CP_UTF8, env, -1, NULL); + } + } + else { + NTLoginName = rb_w32_wstr_to_mbstr(CP_UTF8, env, -1, NULL); } - NTLoginName = strdup(rb_w32_getenv("USER")); if (!GetEnvironmentVariableW(TMPDIR, env, numberof(env)) && !GetEnvironmentVariableW(L"TMP", env, numberof(env)) && @@ -1316,9 +1320,9 @@ w32_spawn(int mode, const char *cmd, const char *prog, UINT cp) } if (!e && shell && !(wshell = mbstr_to_wstr(cp, shell, -1, NULL))) e = E2BIG; - if (v2) ALLOCV_END(v2); if (cmd_sep) *cmd_sep = sep; if (!e && cmd && !(wcmd = mbstr_to_wstr(cp, cmd, -1, NULL))) e = E2BIG; + if (v2) ALLOCV_END(v2); if (v) ALLOCV_END(v); if (!e) { @@ -4669,6 +4673,31 @@ rb_w32_getenv(const char *name) return w32_getenv(name, CP_ACP); } +/* License: Ruby's */ +static DWORD +get_volume_serial_number(const WCHAR *path) +{ + const DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; + const DWORD creation = OPEN_EXISTING; + const DWORD flags = FILE_FLAG_BACKUP_SEMANTICS; + BY_HANDLE_FILE_INFORMATION st = {0}; + HANDLE h = CreateFileW(path, 0, share_mode, NULL, creation, flags, NULL); + BOOL ret; + + if (h == INVALID_HANDLE_VALUE) return 0; + ret = GetFileInformationByHandle(h, &st); + CloseHandle(h); + if (!ret) return 0; + return st.dwVolumeSerialNumber; +} + +/* License: Ruby's */ +static int +different_device_p(const WCHAR *oldpath, const WCHAR *newpath) +{ + return get_volume_serial_number(oldpath) != get_volume_serial_number(newpath); +} + /* License: Artistic or GPL */ static int wrename(const WCHAR *oldpath, const WCHAR *newpath) @@ -4692,8 +4721,14 @@ wrename(const WCHAR *oldpath, const WCHAR *newpath) if (!MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED)) res = -1; - if (res) - errno = map_errno(GetLastError()); + if (res) { + DWORD e = GetLastError(); + if ((e == ERROR_ACCESS_DENIED) && (oldatts & FILE_ATTRIBUTE_DIRECTORY) && + different_device_p(oldpath, newpath)) + errno = EXDEV; + else + errno = map_errno(e); + } else SetFileAttributesW(newpath, oldatts); }); @@ -5920,7 +5955,7 @@ constat_reset(HANDLE h) { st_data_t data; struct constat *p; - if (!conlist) return; + if (!conlist || conlist == conlist_disabled) return; if (!st_lookup(conlist, (st_data_t)h, &data)) return; p = (struct constat *)data; p->vt100.state = constat_init;