From a1d56b18d51a8e772243e992407899b26ecae22e Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 8 Jan 2014 23:21:11 +0000 Subject: [PATCH 01/83] merge revision(s) 44488: [Backport #9341] * test/net/imap/cacert.pem: generate new CA cert, since the last one expired. [Bug #9341] [ruby-core:59459] * test/net/imap/server.crt: new server cert signed with updated CA. * test/net/imap/Makefile: add `make regen_certs` to automate this process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++ test/net/imap/Makefile | 15 +++++++ test/net/imap/cacert.pem | 84 +++++++++++++++++++++------------------- test/net/imap/server.crt | 65 +++++++++++++------------------ version.h | 10 ++--- 5 files changed, 99 insertions(+), 83 deletions(-) create mode 100644 test/net/imap/Makefile diff --git a/ChangeLog b/ChangeLog index cb0c6ac930045c..a2734ab7e655ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Jan 9 08:21:00 2014 Aman Gupta + + * test/net/imap/cacert.pem: generate new CA cert, since the last one + expired. [Bug #9341] [ruby-core:59459] + * test/net/imap/server.crt: new server cert signed with updated CA. + * test/net/imap/Makefile: add `make regen_certs` to automate this + process. + Thu Dec 26 03:28:11 2013 Koichi Sasada * vm_insnhelper.c (argument_error): insert dummy frame to make diff --git a/test/net/imap/Makefile b/test/net/imap/Makefile new file mode 100644 index 00000000000000..b2bc9c7368ee2e --- /dev/null +++ b/test/net/imap/Makefile @@ -0,0 +1,15 @@ +all: + +regen_certs: + touch server.key + make server.crt + +cacert.pem: server.key + openssl req -new -x509 -days 1825 -key server.key -out cacert.pem -text -subj "/C=JP/ST=Shimane/L=Matz-e city/O=Ruby Core Team/CN=Ruby Test CA/emailAddress=security@ruby-lang.org" + +server.csr: + openssl req -new -key server.key -out server.csr -text -subj "/C=JP/ST=Shimane/O=Ruby Core Team/OU=Ruby Test/CN=localhost" + +server.crt: server.csr cacert.pem + openssl x509 -days 1825 -CA cacert.pem -CAkey server.key -set_serial 00 -in server.csr -req -text -out server.crt + rm server.csr diff --git a/test/net/imap/cacert.pem b/test/net/imap/cacert.pem index bd7e68ac95dc56..70733878779f3c 100644 --- a/test/net/imap/cacert.pem +++ b/test/net/imap/cacert.pem @@ -2,59 +2,65 @@ Certificate: Data: Version: 3 (0x2) Serial Number: - 9f:dc:f7:94:98:05:43:4c + b9:90:a2:bf:62:69:17:9c Signature Algorithm: sha1WithRSAEncryption Issuer: C=JP, ST=Shimane, L=Matz-e city, O=Ruby Core Team, CN=Ruby Test CA/emailAddress=security@ruby-lang.org Validity - Not Before: Dec 23 10:21:33 2010 GMT - Not After : Jan 1 10:21:33 2014 GMT + Not Before: Jan 3 01:34:17 2014 GMT + Not After : Jan 2 01:34:17 2019 GMT Subject: C=JP, ST=Shimane, L=Matz-e city, O=Ruby Core Team, CN=Ruby Test CA/emailAddress=security@ruby-lang.org Subject Public Key Info: Public Key Algorithm: rsaEncryption - Public-Key: (1024 bit) - Modulus: - 00:ce:be:2c:9f:47:ba:db:9c:9c:5b:f0:38:3b:f3: - 74:20:37:76:23:9f:84:1c:81:90:b4:3e:00:20:34: - 98:7e:81:69:50:a1:c3:65:96:ea:fa:00:da:8c:cc: - 53:3f:ba:3c:d0:50:7a:5a:b4:6b:ac:d3:2e:18:ca: - 2a:69:b3:6a:6f:38:c2:32:a8:06:b6:0a:30:a9:ee: - 03:38:e9:05:a5:19:23:54:a8:3c:b9:08:ad:2b:72: - 23:df:93:22:c4:46:a8:ea:f1:a6:e9:30:4a:3f:83: - 39:e9:62:8e:8b:a3:5e:67:89:1d:7c:75:de:05:aa: - 58:b1:b7:79:7c:10:80:6d:87 + RSA Public Key: (1024 bit) + Modulus (1024 bit): + 00:db:75:d0:45:de:b1:df:bf:71:a0:0e:b0:a5:e6: + bc:f4:1c:9d:e5:25:67:64:c5:7b:cb:f1:af:c6:be: + 9a:aa:ea:7e:0f:cc:05:af:ef:40:69:06:b2:c9:13: + 9d:7e:eb:a2:06:e2:ea:7d:07:c7:c7:99:c7:fb:d5: + b8:eb:63:77:62:2b:18:12:c3:53:58:d0:f5:c7:40: + 0c:01:d1:26:82:34:16:09:e3:dc:65:f4:dc:bb:5d: + a5:41:60:e7:a9:74:ba:d7:4c:b6:a3:9c:c5:8c:89: + af:cb:e8:9f:05:fe:ea:fe:64:24:bf:e7:ed:e3:f6: + d0:fc:d6:eb:fc:06:82:10:fb Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Key Identifier: - 41:C9:49:37:B1:FA:61:E3:BA:D7:19:3D:D9:DA:8C:B9:82:C9:B4:6A + E8:7E:58:AC:13:7B:03:22:8D:9E:AF:32:0B:84:89:80:80:0C:1E:C2 X509v3 Authority Key Identifier: - keyid:41:C9:49:37:B1:FA:61:E3:BA:D7:19:3D:D9:DA:8C:B9:82:C9:B4:6A + keyid:E8:7E:58:AC:13:7B:03:22:8D:9E:AF:32:0B:84:89:80:80:0C:1E:C2 + DirName:/C=JP/ST=Shimane/L=Matz-e city/O=Ruby Core Team/CN=Ruby Test CA/emailAddress=security@ruby-lang.org + serial:B9:90:A2:BF:62:69:17:9C X509v3 Basic Constraints: CA:TRUE Signature Algorithm: sha1WithRSAEncryption - 86:00:33:b9:dd:ff:5f:83:59:5f:c3:29:3c:d7:11:db:10:b3: - d7:d1:70:fb:0a:c6:74:85:c6:ea:e1:15:c4:92:f8:0e:11:cc: - ff:a6:3c:31:c2:2c:66:d8:fe:63:93:9f:b0:97:e6:f5:bc:5c: - 80:68:96:5d:eb:77:b9:23:dd:68:a7:49:03:ff:22:48:55:f1: - 39:7c:20:21:ff:64:52:e1:f6:cf:3c:b3:4d:2c:5c:03:62:ea: - c5:49:99:07:fa:8d:ff:7b:c2:75:0c:ca:24:b5:0b:f5:b7:57: - 3a:10:f0:8a:bb:9a:e8:92:4d:d5:6f:c2:a2:29:36:61:78:a4: - dc:7b + 8f:77:06:4e:31:72:12:ee:68:09:70:27:d4:31:85:ef:10:95: + f9:0f:2b:66:63:08:37:88:6e:b7:9b:40:3e:18:77:33:86:e8: + 61:6a:b7:3c:cb:c7:a6:d6:d5:92:6a:1f:56:d0:9f:5c:32:56: + d3:37:52:fe:0e:20:c2:7a:0d:fe:2d:3c:81:da:b8:7f:4d:6a: + 08:01:d9:be:7a:a2:15:be:a6:ce:49:64:90:8c:9a:ca:6e:2e: + 84:48:1d:94:19:56:94:46:aa:25:9b:68:c2:80:60:bf:cb:2e: + 35:03:ea:0a:65:5a:33:38:c6:cc:81:46:c0:bc:36:86:96:39: + 10:7d -----BEGIN CERTIFICATE----- -MIIC6DCCAlGgAwIBAgIJAJ/c95SYBUNMMA0GCSqGSIb3DQEBBQUAMIGMMQswCQYD -VQQGEwJKUDEQMA4GA1UECAwHU2hpbWFuZTEUMBIGA1UEBwwLTWF0ei1lIGNpdHkx -FzAVBgNVBAoMDlJ1YnkgQ29yZSBUZWFtMRUwEwYDVQQDDAxSdWJ5IFRlc3QgQ0Ex -JTAjBgkqhkiG9w0BCQEWFnNlY3VyaXR5QHJ1YnktbGFuZy5vcmcwHhcNMTAxMjIz -MTAyMTMzWhcNMTQwMTAxMTAyMTMzWjCBjDELMAkGA1UEBhMCSlAxEDAOBgNVBAgM -B1NoaW1hbmUxFDASBgNVBAcMC01hdHotZSBjaXR5MRcwFQYDVQQKDA5SdWJ5IENv -cmUgVGVhbTEVMBMGA1UEAwwMUnVieSBUZXN0IENBMSUwIwYJKoZIhvcNAQkBFhZz +MIIDjTCCAvagAwIBAgIJALmQor9iaRecMA0GCSqGSIb3DQEBBQUAMIGMMQswCQYD +VQQGEwJKUDEQMA4GA1UECBMHU2hpbWFuZTEUMBIGA1UEBxMLTWF0ei1lIGNpdHkx +FzAVBgNVBAoTDlJ1YnkgQ29yZSBUZWFtMRUwEwYDVQQDEwxSdWJ5IFRlc3QgQ0Ex +JTAjBgkqhkiG9w0BCQEWFnNlY3VyaXR5QHJ1YnktbGFuZy5vcmcwHhcNMTQwMTAz +MDEzNDE3WhcNMTkwMTAyMDEzNDE3WjCBjDELMAkGA1UEBhMCSlAxEDAOBgNVBAgT +B1NoaW1hbmUxFDASBgNVBAcTC01hdHotZSBjaXR5MRcwFQYDVQQKEw5SdWJ5IENv +cmUgVGVhbTEVMBMGA1UEAxMMUnVieSBUZXN0IENBMSUwIwYJKoZIhvcNAQkBFhZz ZWN1cml0eUBydWJ5LWxhbmcub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB -gQDOviyfR7rbnJxb8Dg783QgN3Yjn4QcgZC0PgAgNJh+gWlQocNllur6ANqMzFM/ -ujzQUHpatGus0y4Yyipps2pvOMIyqAa2CjCp7gM46QWlGSNUqDy5CK0rciPfkyLE -Rqjq8abpMEo/gznpYo6Lo15niR18dd4Fqlixt3l8EIBthwIDAQABo1AwTjAdBgNV -HQ4EFgQUQclJN7H6YeO61xk92dqMuYLJtGowHwYDVR0jBBgwFoAUQclJN7H6YeO6 -1xk92dqMuYLJtGowDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCGADO5 -3f9fg1lfwyk81xHbELPX0XD7CsZ0hcbq4RXEkvgOEcz/pjwxwixm2P5jk5+wl+b1 -vFyAaJZd63e5I91op0kD/yJIVfE5fCAh/2RS4fbPPLNNLFwDYurFSZkH+o3/e8J1 -DMoktQv1t1c6EPCKu5rokk3Vb8KiKTZheKTcew== +gQDbddBF3rHfv3GgDrCl5rz0HJ3lJWdkxXvL8a/Gvpqq6n4PzAWv70BpBrLJE51+ +66IG4up9B8fHmcf71bjrY3diKxgSw1NY0PXHQAwB0SaCNBYJ49xl9Ny7XaVBYOep +dLrXTLajnMWMia/L6J8F/ur+ZCS/5+3j9tD81uv8BoIQ+wIDAQABo4H0MIHxMB0G +A1UdDgQWBBToflisE3sDIo2erzILhImAgAwewjCBwQYDVR0jBIG5MIG2gBToflis +E3sDIo2erzILhImAgAwewqGBkqSBjzCBjDELMAkGA1UEBhMCSlAxEDAOBgNVBAgT +B1NoaW1hbmUxFDASBgNVBAcTC01hdHotZSBjaXR5MRcwFQYDVQQKEw5SdWJ5IENv +cmUgVGVhbTEVMBMGA1UEAxMMUnVieSBUZXN0IENBMSUwIwYJKoZIhvcNAQkBFhZz +ZWN1cml0eUBydWJ5LWxhbmcub3JnggkAuZCiv2JpF5wwDAYDVR0TBAUwAwEB/zAN +BgkqhkiG9w0BAQUFAAOBgQCPdwZOMXIS7mgJcCfUMYXvEJX5DytmYwg3iG63m0A+ +GHczhuhharc8y8em1tWSah9W0J9cMlbTN1L+DiDCeg3+LTyB2rh/TWoIAdm+eqIV +vqbOSWSQjJrKbi6ESB2UGVaURqolm2jCgGC/yy41A+oKZVozOMbMgUbAvDaGljkQ +fQ== -----END CERTIFICATE----- diff --git a/test/net/imap/server.crt b/test/net/imap/server.crt index d848b26ab01297..fa4f99493a9983 100644 --- a/test/net/imap/server.crt +++ b/test/net/imap/server.crt @@ -1,17 +1,17 @@ Certificate: Data: - Version: 3 (0x2) + Version: 1 (0x0) Serial Number: 0 (0x0) Signature Algorithm: sha1WithRSAEncryption Issuer: C=JP, ST=Shimane, L=Matz-e city, O=Ruby Core Team, CN=Ruby Test CA/emailAddress=security@ruby-lang.org Validity - Not Before: Dec 23 10:23:52 2010 GMT - Not After : Jan 1 10:23:52 2014 GMT + Not Before: Jan 3 01:34:17 2014 GMT + Not After : Jan 2 01:34:17 2019 GMT Subject: C=JP, ST=Shimane, O=Ruby Core Team, OU=Ruby Test, CN=localhost Subject Public Key Info: Public Key Algorithm: rsaEncryption - Public-Key: (1024 bit) - Modulus: + RSA Public Key: (1024 bit) + Modulus (1024 bit): 00:db:75:d0:45:de:b1:df:bf:71:a0:0e:b0:a5:e6: bc:f4:1c:9d:e5:25:67:64:c5:7b:cb:f1:af:c6:be: 9a:aa:ea:7e:0f:cc:05:af:ef:40:69:06:b2:c9:13: @@ -22,40 +22,27 @@ Certificate: af:cb:e8:9f:05:fe:ea:fe:64:24:bf:e7:ed:e3:f6: d0:fc:d6:eb:fc:06:82:10:fb Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - Netscape Comment: - OpenSSL Generated Certificate - X509v3 Subject Key Identifier: - E8:7E:58:AC:13:7B:03:22:8D:9E:AF:32:0B:84:89:80:80:0C:1E:C2 - X509v3 Authority Key Identifier: - keyid:41:C9:49:37:B1:FA:61:E3:BA:D7:19:3D:D9:DA:8C:B9:82:C9:B4:6A - Signature Algorithm: sha1WithRSAEncryption - ae:ee:cd:fe:c9:af:48:0b:50:37:ac:6a:f6:68:90:9b:67:df: - 6f:2d:17:c9:3c:a5:da:ad:39:dc:2a:5b:07:88:26:38:19:30: - d6:95:cf:10:69:c7:92:14:83:be:f1:b5:8e:6f:d9:91:51:c5: - 63:ae:1c:89:ac:27:bf:4f:2a:8f:4e:0c:57:42:0a:c9:8e:0c: - f4:f3:02:f7:ea:44:b6:e4:47:05:af:4e:74:e4:87:87:d9:c8: - 76:ed:ab:32:7c:f0:31:34:10:14:bc:a6:37:cd:d7:dc:33:da: - 82:d3:d4:9b:e9:d5:cd:38:cc:fa:81:5f:4e:fd:5f:53:05:5d: - 76:f9 + 85:f5:d3:05:8b:8c:f4:43:1c:88:f2:8f:b2:f2:93:77:b7:3d: + 95:c6:a0:34:bc:33:6a:d8:85:5f:3e:86:08:10:c5:5c:c1:76: + a3:53:3c:dc:38:98:23:97:e7:da:21:ac:e8:4d:3c:96:70:29: + ff:ff:1e:4a:9a:17:2b:db:04:62:b9:ef:ab:ea:a7:a5:e8:7c: + b1:d5:ed:30:a8:6c:78:de:51:7e:e3:8a:c2:a4:64:a8:63:a2: + bc:fd:43:9c:f3:55:7d:54:c9:6a:d8:53:1c:4b:6b:03:aa:b6: + 19:e6:a4:4f:47:00:96:c5:42:59:85:4e:c3:4e:cd:41:82:53: + 10:f8 -----BEGIN CERTIFICATE----- -MIIC3jCCAkegAwIBAgIBADANBgkqhkiG9w0BAQUFADCBjDELMAkGA1UEBhMCSlAx -EDAOBgNVBAgMB1NoaW1hbmUxFDASBgNVBAcMC01hdHotZSBjaXR5MRcwFQYDVQQK -DA5SdWJ5IENvcmUgVGVhbTEVMBMGA1UEAwwMUnVieSBUZXN0IENBMSUwIwYJKoZI -hvcNAQkBFhZzZWN1cml0eUBydWJ5LWxhbmcub3JnMB4XDTEwMTIyMzEwMjM1MloX -DTE0MDEwMTEwMjM1MlowYDELMAkGA1UEBhMCSlAxEDAOBgNVBAgMB1NoaW1hbmUx -FzAVBgNVBAoMDlJ1YnkgQ29yZSBUZWFtMRIwEAYDVQQLDAlSdWJ5IFRlc3QxEjAQ -BgNVBAMMCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA23XQ -Rd6x379xoA6wpea89Byd5SVnZMV7y/Gvxr6aqup+D8wFr+9AaQayyROdfuuiBuLq -fQfHx5nH+9W462N3YisYEsNTWND1x0AMAdEmgjQWCePcZfTcu12lQWDnqXS610y2 -o5zFjImvy+ifBf7q/mQkv+ft4/bQ/Nbr/AaCEPsCAwEAAaN7MHkwCQYDVR0TBAIw -ADAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUw -HQYDVR0OBBYEFOh+WKwTewMijZ6vMguEiYCADB7CMB8GA1UdIwQYMBaAFEHJSTex -+mHjutcZPdnajLmCybRqMA0GCSqGSIb3DQEBBQUAA4GBAK7uzf7Jr0gLUDesavZo -kJtn328tF8k8pdqtOdwqWweIJjgZMNaVzxBpx5IUg77xtY5v2ZFRxWOuHImsJ79P -Ko9ODFdCCsmODPTzAvfqRLbkRwWvTnTkh4fZyHbtqzJ88DE0EBS8pjfN19wz2oLT -1Jvp1c04zPqBX079X1MFXXb5 +MIICXDCCAcUCAQAwDQYJKoZIhvcNAQEFBQAwgYwxCzAJBgNVBAYTAkpQMRAwDgYD +VQQIEwdTaGltYW5lMRQwEgYDVQQHEwtNYXR6LWUgY2l0eTEXMBUGA1UEChMOUnVi +eSBDb3JlIFRlYW0xFTATBgNVBAMTDFJ1YnkgVGVzdCBDQTElMCMGCSqGSIb3DQEJ +ARYWc2VjdXJpdHlAcnVieS1sYW5nLm9yZzAeFw0xNDAxMDMwMTM0MTdaFw0xOTAx +MDIwMTM0MTdaMGAxCzAJBgNVBAYTAkpQMRAwDgYDVQQIEwdTaGltYW5lMRcwFQYD +VQQKEw5SdWJ5IENvcmUgVGVhbTESMBAGA1UECxMJUnVieSBUZXN0MRIwEAYDVQQD +Ewlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANt10EXesd+/ +caAOsKXmvPQcneUlZ2TFe8vxr8a+mqrqfg/MBa/vQGkGsskTnX7rogbi6n0Hx8eZ +x/vVuOtjd2IrGBLDU1jQ9cdADAHRJoI0Fgnj3GX03LtdpUFg56l0utdMtqOcxYyJ +r8vonwX+6v5kJL/n7eP20PzW6/wGghD7AgMBAAEwDQYJKoZIhvcNAQEFBQADgYEA +hfXTBYuM9EMciPKPsvKTd7c9lcagNLwzatiFXz6GCBDFXMF2o1M83DiYI5fn2iGs +6E08lnAp//8eSpoXK9sEYrnvq+qnpeh8sdXtMKhseN5RfuOKwqRkqGOivP1DnPNV +fVTJathTHEtrA6q2GeakT0cAlsVCWYVOw07NQYJTEPg= -----END CERTIFICATE----- diff --git a/version.h b/version.h index e9398b3e31902f..877e04134b05fb 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2013-12-31" -#define RUBY_PATCHLEVEL 2 +#define RUBY_RELEASE_DATE "2014-01-09" +#define RUBY_PATCHLEVEL 3 -#define RUBY_RELEASE_YEAR 2013 -#define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 31 +#define RUBY_RELEASE_YEAR 2014 +#define RUBY_RELEASE_MONTH 1 +#define RUBY_RELEASE_DAY 9 #include "ruby/version.h" From f07223228b0c994655fbc54f50ccedccc62ff4a4 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 9 Jan 2014 05:06:21 +0000 Subject: [PATCH 02/83] merge revision(s) 44440,44444: [Backport #9306] * win32/Makefile.sub (fake.rb): should depend on version.h because if RUBY_VERSION is updated, fake.rb need to say the new version to avoid install error in rbconfig.rb. * win32/{setup.mak,Makefile.sub}: update fake.rb like template/fake.rb.in. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ version.h | 2 +- win32/Makefile.sub | 7 +++++-- win32/setup.mak | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2734ab7e655ae..acf714116a7735 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Jan 9 14:05:24 2014 NAKAMURA Usaku + + * win32/{setup.mak,Makefile.sub}: update fake.rb like + template/fake.rb.in. + +Thu Jan 9 14:05:24 2014 NAKAMURA Usaku + + * win32/Makefile.sub (fake.rb): should depend on version.h because + if RUBY_VERSION is updated, fake.rb need to say the new version + to avoid install error in rbconfig.rb. + Thu Jan 9 08:21:00 2014 Aman Gupta * test/net/imap/cacert.pem: generate new CA cert, since the last one diff --git a/version.h b/version.h index 877e04134b05fb..d93dc540dd7edf 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-09" -#define RUBY_PATCHLEVEL 3 +#define RUBY_PATCHLEVEL 4 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 305f37df5569ee..a04e8024beab68 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -1034,14 +1034,17 @@ $(RCFILES): $(RBCONFIG) $(srcdir)/revision.h $(srcdir)/win32/resource.rb -so_name=$(RUBY_SO_NAME) \ . $(icondirs) $(win_srcdir) -$(arch)-fake.rb: $(MKFILES) +$(arch)-fake.rb: $(MKFILES) $(srcdir)/version.h @echo Creating <<$@ class Object + remove_const :CROSS_COMPILING if defined?(CROSS_COMPILING) CROSS_COMPILING = RUBY_PLATFORM remove_const :RUBY_PLATFORM remove_const :RUBY_VERSION + remove_const :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION) RUBY_PLATFORM = "$(arch)" - RUBY_VERSION = "$(MAJOR).$(MINOR).$(TEENY)" + RUBY_VERSION = $(RUBY_PROGRAM_VERSION) + RUBY_DESCRIPTION = "ruby #{RUBY_VERSION} (" + $(RUBY_PROGRAM_RELEASE_DATE) + ") [#{RUBY_PLATFORM}]" end class File remove_const :ALT_SEPARATOR diff --git a/win32/setup.mak b/win32/setup.mak index 458212bb7bb680..b6358e5dd537b5 100644 --- a/win32/setup.mak +++ b/win32/setup.mak @@ -117,6 +117,8 @@ int main(void) {return (EnumProcesses(NULL,0,NULL) ? 0 : 1);} MAJOR = RUBY_API_VERSION_MAJOR MINOR = RUBY_API_VERSION_MINOR TEENY = RUBY_API_VERSION_TEENY +RUBY_PROGRAM_VERSION = RUBY_VERSION +RUBY_PROGRAM_RELEASE_DATE = RUBY_RELEASE_DATE MSC_VER = _MSC_VER << From 0957229af7eea29fcc4dd54dd00172c709a4c31b Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 11 Jan 2014 00:06:23 +0000 Subject: [PATCH 03/83] merge revision(s) 44544: * doc/NEWS-2.1.0: Add mention for litteral.freeze git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- NEWS | 7 ++++++- version.h | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 59251a40cfe8f2..a096ad9d28fc85 100644 --- a/NEWS +++ b/NEWS @@ -114,6 +114,7 @@ with all sufficient information, see the ChangeLog file. * Process.clock_getres * String + * "literal".freeze is now optimized to return the same object * New methods: * String#scrub and String#scrub! verify and fix invalid byte sequence. If you want to use this function with older Ruby, @@ -133,6 +134,10 @@ with all sufficient information, see the ChangeLog file. === Core classes compatibility issues (excluding feature bug fixes) +* Dir + * incompatible changes: + * Dir#glob returns composed characters (previously Apple Modofied UTF-8). + * Hash * incompatible changes: * Hash#reject will return plain Hash object in the future versions, that @@ -250,7 +255,7 @@ String * REXML::Parsers::SAX2Parser * Fixes wrong number of arguments of entitydecl event. Document of the event says "an array of the entity declaration" but implementation passes two - or more arguments. It is an implementation bug but it breaks backword + or more arguments. It is an implementation bug but it breaks backward compatibility. * REXML::Parsers::StreamParser diff --git a/version.h b/version.h index d93dc540dd7edf..db8241499d00a2 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-09" -#define RUBY_PATCHLEVEL 4 +#define RUBY_RELEASE_DATE "2014-01-10" +#define RUBY_PATCHLEVEL 5 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 9 +#define RUBY_RELEASE_DAY 10 #include "ruby/version.h" From 820b71478b6a1895b0ecac617b0bdc743431e54b Mon Sep 17 00:00:00 2001 From: svn Date: Sat, 11 Jan 2014 00:06:27 +0000 Subject: [PATCH 04/83] * 2014-01-11 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index db8241499d00a2..bdc8096fac4178 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-10" +#define RUBY_RELEASE_DATE "2014-01-11" #define RUBY_PATCHLEVEL 5 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 11 #include "ruby/version.h" From b0d69f3c18d3b624b4e7c2dad92d0168e7677066 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 15 Jan 2014 02:29:58 +0000 Subject: [PATCH 05/83] merge revision(s) 44598,44599,44600: /usr/lib/libc.so is not symlink on FreeBSD 10 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/dl/test_base.rb | 3 +++ test/dl/test_handle.rb | 2 +- test/fiddle/helper.rb | 3 +++ test/fiddle/test_handle.rb | 2 +- version.h | 6 +++--- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/test/dl/test_base.rb b/test/dl/test_base.rb index a07056d14264d3..dafba6e44dc610 100644 --- a/test/dl/test_base.rb +++ b/test/dl/test_base.rb @@ -39,6 +39,9 @@ when /mirbsd/ libc_so = "/usr/lib/libc.so.41.10" libm_so = "/usr/lib/libm.so.7.0" +when /freebsd/ + libc_so = "/lib/libc.so.7" + libm_so = "/lib/libm.so.5" when /bsd|dragonfly/ libc_so = "/usr/lib/libc.so" libm_so = "/usr/lib/libm.so" diff --git a/test/dl/test_handle.rb b/test/dl/test_handle.rb index 4ef93adf41f825..83b8af196041f9 100644 --- a/test/dl/test_handle.rb +++ b/test/dl/test_handle.rb @@ -181,7 +181,7 @@ def test_dlerror # In general uses of dlerror(3) should call it before use it. require 'socket' Socket.gethostbyname("localhost") - DL.dlopen("/usr/lib/libc.so").sym('strcpy') + DL.dlopen("/lib/libc.so.7").sym('strcpy') end if /freebsd/=~ RUBY_PLATFORM end end diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb index 404c137f97ef9f..f58077e7bc0f68 100644 --- a/test/fiddle/helper.rb +++ b/test/fiddle/helper.rb @@ -40,6 +40,9 @@ when /mirbsd/ libc_so = "/usr/lib/libc.so.41.10" libm_so = "/usr/lib/libm.so.7.0" +when /freebsd/ + libc_so = "/lib/libc.so.7" + libm_so = "/lib/libm.so.5" when /bsd|dragonfly/ libc_so = "/usr/lib/libc.so" libm_so = "/usr/lib/libm.so" diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb index 2af3e5c9037da1..c598cc33a2cb09 100644 --- a/test/fiddle/test_handle.rb +++ b/test/fiddle/test_handle.rb @@ -183,7 +183,7 @@ def test_dlerror # In general uses of dlerror(3) should call it before use it. require 'socket' Socket.gethostbyname("localhost") - Fiddle.dlopen("/usr/lib/libc.so").sym('strcpy') + Fiddle.dlopen("/lib/libc.so.7").sym('strcpy') end if /freebsd/=~ RUBY_PLATFORM end end if defined?(Fiddle) diff --git a/version.h b/version.h index bdc8096fac4178..b97e200e7594f8 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-11" -#define RUBY_PATCHLEVEL 5 +#define RUBY_RELEASE_DATE "2014-01-15" +#define RUBY_PATCHLEVEL 6 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 15 #include "ruby/version.h" From 111cbcb3d9a8307707cbbbbc8585f6a61e088895 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 15 Jan 2014 02:30:50 +0000 Subject: [PATCH 06/83] merge revision(s) 44601: FreeBSD 10 SEGVs this less than 4M + 12K bytes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bootstraptest/test_method.rb | 4 ++-- version.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb index 4282bc62738dab..0a7cb0a577510d 100644 --- a/bootstraptest/test_method.rb +++ b/bootstraptest/test_method.rb @@ -957,8 +957,8 @@ class C < B assert_normal_exit %q{ begin - Process.setrlimit(Process::RLIMIT_STACK, 4_202_496) - # FreeBSD fails this less than 4M + 8K bytes. + Process.setrlimit(Process::RLIMIT_STACK, 4_206_592) + # FreeBSD SEGVs this less than 4M + 12K bytes. rescue Exception exit end diff --git a/version.h b/version.h index b97e200e7594f8..e062e963f8beea 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-15" -#define RUBY_PATCHLEVEL 6 +#define RUBY_PATCHLEVEL 7 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From ba97a56685bda66d60978d8e27f44e995a68a6ed Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 23 Jan 2014 02:17:40 +0000 Subject: [PATCH 07/83] merge revision(s) 44358,44359,44360,44363: [Backport #9275] hash.c: reword * hash.c (HAS_EXTRA_STATES, rb_hash_reject): use words "extra states". * hash.c (HAS_EXTRA_STATES): warn extra states only when something differ. [ruby-core:59254] [Bug #9275] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ hash.c | 37 ++++++++++++++++++++++++------------- test/ruby/test_hash.rb | 18 ++++++++++++++++-- version.h | 6 +++--- 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index acf714116a7735..e7f0cc4a1f070c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 23 10:37:24 2014 Nobuyoshi Nakada + + * hash.c (HAS_EXTRA_STATES): warn extra states only when something + differ. [ruby-core:59254] [Bug #9275] + Thu Jan 9 14:05:24 2014 NAKAMURA Usaku * win32/{setup.mak,Makefile.sub}: update fake.rb like diff --git a/hash.c b/hash.c index 1fa40b1bba5fd4..0cbc46baf5f039 100644 --- a/hash.c +++ b/hash.c @@ -27,12 +27,24 @@ # endif #endif -#define HAS_MISC_ATTRIBUTES(hash, klass) ( \ - (klass = rb_obj_class(hash)) != rb_cHash || \ - (klass = 0, \ - FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \ - !NIL_P(RHASH_IFNONE(hash)))) -#define HASH_REJECT_COPY_MISC_ATTRIBUTES 1 +#define HAS_EXTRA_STATES(hash, klass) ( \ + ((klass = has_extra_methods(rb_obj_class(hash))) != 0) || \ + FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \ + !NIL_P(RHASH_IFNONE(hash))) +#define HASH_REJECT_COPY_EXTRA_STATES 1 + +static VALUE +has_extra_methods(VALUE klass) +{ + const VALUE base = rb_cHash; + VALUE c = klass; + while (c != base) { + st_table *mtbl = RCLASS_M_TBL(c); + if (mtbl && mtbl->num_entries) return klass; + c = RCLASS_SUPER(c); + } + return 0; +} static VALUE rb_hash_s_try_convert(VALUE, VALUE); @@ -1133,11 +1145,11 @@ rb_hash_reject(VALUE hash) RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); if (RTEST(ruby_verbose)) { VALUE klass; - if (HAS_MISC_ATTRIBUTES(hash, klass)) { -#if HASH_REJECT_COPY_MISC_ATTRIBUTES - rb_warn("copying unguaranteed attributes: %+"PRIsVALUE, hash); - rb_warn("following atributes will not be copied in the future version:"); - if (klass != rb_cHash) { + if (HAS_EXTRA_STATES(hash, klass)) { +#if HASH_REJECT_COPY_EXTRA_STATES + rb_warn("copying extra states: %+"PRIsVALUE, hash); + rb_warn("following states will not be copied in the future version:"); + if (klass) { rb_warn(" subclass: %+"PRIsVALUE, klass); } if (FL_TEST(hash, FL_EXIVAR)) { @@ -1153,8 +1165,7 @@ rb_hash_reject(VALUE hash) else if (!NIL_P(RHASH_IFNONE(hash))) rb_warn(" default value: %+"PRIsVALUE, RHASH_IFNONE(hash)); #else - rb_warn("unguaranteed attributes are not copied: %+"PRIsVALUE, hash); - rb_warn("following atributes are ignored now:"); + rb_warn("extra states are no longer copied: %+"PRIsVALUE, hash); #endif } } diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 84346704bb73e0..910da9374a1106 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -558,12 +558,23 @@ def test_reject assert_equal(h3, h.reject {|k,v| v }) assert_equal(base, h) - return unless RUBY_VERSION >= "2.2.0" # [ruby-core:59154] [Bug #9223] + unless RUBY_VERSION >= "2.2.0" + # [ruby-core:59154] [Bug #9223] + if @cls == Hash + assert_empty(EnvUtil.verbose_warning {h.reject {false}}) + bug9275 = '[ruby-core:59254] [Bug #9275]' + c = Class.new(Hash) + assert_empty(EnvUtil.verbose_warning {c.new.reject {false}}, bug9275) + else + assert_match(/extra states/, EnvUtil.verbose_warning {h.reject {false}}) + end + return + end h.instance_variable_set(:@foo, :foo) h.default = 42 h.taint - h = h.reject {false} + h = EnvUtil.suppress_warning {h.reject {false}} assert_instance_of(Hash, h) assert_not_predicate(h, :tainted?) assert_nil(h.default) @@ -1219,6 +1230,9 @@ def hash class TestSubHash < TestHash class SubHash < Hash + def reject(*) + super + end end def setup diff --git a/version.h b/version.h index e062e963f8beea..96a672d5bbeae5 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-15" -#define RUBY_PATCHLEVEL 7 +#define RUBY_RELEASE_DATE "2014-01-23" +#define RUBY_PATCHLEVEL 8 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 15 +#define RUBY_RELEASE_DAY 23 #include "ruby/version.h" From 7d1ca1a5b4edcf78b61474c00abb71f3bc861d20 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 27 Jan 2014 07:47:11 +0000 Subject: [PATCH 08/83] merge revision(s) 44402: [Backport #9301] * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Declare a constant `OP_MSIE_SSLV2_RSA_PADDING` only if the macro is defined. The `SSL_OP_MSIE_SSLV2_RSA_PADDING` has been removed from latest snapshot of OpenSSL 1.0.1. [Fixes GH-488] git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/openssl/ossl_ssl.c | 2 ++ version.h | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7f0cc4a1f070c..8db20d22286c02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jan 27 16:45:34 2014 Yamashita Yuu + + * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Declare a constant + `OP_MSIE_SSLV2_RSA_PADDING` only if the macro is defined. The + `SSL_OP_MSIE_SSLV2_RSA_PADDING` has been removed from latest + snapshot of OpenSSL 1.0.1. [Fixes GH-488] + Thu Jan 23 10:37:24 2014 Nobuyoshi Nakada * hash.c (HAS_EXTRA_STATES): warn extra states only when something diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index ec7135064a48c6..206470cbfe90f0 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -2229,7 +2229,9 @@ Init_ossl_ssl() ossl_ssl_def_const(OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG); ossl_ssl_def_const(OP_SSLREF2_REUSE_CERT_TYPE_BUG); ossl_ssl_def_const(OP_MICROSOFT_BIG_SSLV3_BUFFER); +#if defined(SSL_OP_MSIE_SSLV2_RSA_PADDING) ossl_ssl_def_const(OP_MSIE_SSLV2_RSA_PADDING); +#endif ossl_ssl_def_const(OP_SSLEAY_080_CLIENT_DH_BUG); ossl_ssl_def_const(OP_TLS_D5_BUG); ossl_ssl_def_const(OP_TLS_BLOCK_PADDING_BUG); diff --git a/version.h b/version.h index 96a672d5bbeae5..e0d16aeffb3de7 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-23" -#define RUBY_PATCHLEVEL 8 +#define RUBY_RELEASE_DATE "2014-01-27" +#define RUBY_PATCHLEVEL 9 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_DAY 27 #include "ruby/version.h" From 3296771c5bbee084049b033acd28879328238051 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 27 Jan 2014 07:56:58 +0000 Subject: [PATCH 09/83] merge revision(s) 44588: [Backport #9316] * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional digit for the quotient to be compatible with bigdecimal 1.2.1 and the former. [ruby-core:59365] [#9316] [#9305] * test/bigdecimal/test_bigdecimal.rb: tests for the above change. * ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.4. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ ext/bigdecimal/bigdecimal.c | 6 ++++-- ext/bigdecimal/bigdecimal.gemspec | 2 +- test/bigdecimal/test_bigdecimal.rb | 4 ++++ version.h | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8db20d22286c02..0def40481bbe0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Jan 27 16:49:52 2014 Kenta Murata + + * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional + digit for the quotient to be compatible with bigdecimal 1.2.1 and + the former. [ruby-core:59365] [#9316] [#9305] + + * test/bigdecimal/test_bigdecimal.rb: tests for the above change. + + * ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.4. + Mon Jan 27 16:45:34 2014 Yamashita Yuu * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Declare a constant diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index e0b7c01e0853d6..8537817e86b636 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1221,8 +1221,10 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r) *div = b; mx = a->Prec + vabs(a->exponent); - if (mxPrec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent); - mx =(mx + 1) * VpBaseFig(); + if (mx < b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent); + mx++; /* NOTE: An additional digit is needed for the compatibility to + the version 1.2.1 and the former. */ + mx = (mx + 1) * VpBaseFig(); GUARD_OBJ((*c), VpCreateRbObject(mx, "#0")); GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0")); VpDivd(*c, *res, a, b); diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec index 676e05bacbff48..7be9d7275bd2fa 100644 --- a/ext/bigdecimal/bigdecimal.gemspec +++ b/ext/bigdecimal/bigdecimal.gemspec @@ -1,5 +1,5 @@ # -*- ruby -*- -_VERSION = "1.2.3" +_VERSION = "1.2.4" date = %w$Date:: $[1] Gem::Specification.new do |s| diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 6fdc422fdf61e3..02bb5a51755924 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -701,6 +701,10 @@ def test_div assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, (BigDecimal.new("-0") / 1).sign) assert_equal(2, BigDecimal.new("2") / 1) assert_equal(-2, BigDecimal.new("2") / -1) + + assert_equal(BigDecimal('1486.868686869'), BigDecimal('1472.0') / BigDecimal('0.99'), '[ruby-core:59365] [#9316]') + + assert_equal(4.124045235, BigDecimal('0.9932') / (700 * BigDecimal('0.344045') / BigDecimal('1000.0')), '[#9305]') end def test_div_with_float diff --git a/version.h b/version.h index e0d16aeffb3de7..8ea34368f62f85 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-27" -#define RUBY_PATCHLEVEL 9 +#define RUBY_PATCHLEVEL 10 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From fec2e7e292d6a354007755418a33da9e29b28f34 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 30 Jan 2014 06:03:02 +0000 Subject: [PATCH 10/83] merge revision(s) 44756: * configure.in: use $@ instead of $(.TARGET) because .TARGET is not supported by GNU make. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ configure.in | 2 +- version.h | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0def40481bbe0b..3766b864ae61ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 30 15:02:35 2014 Shugo Maeda + + * configure.in: use $@ instead of $(.TARGET) because .TARGET is not + supported by GNU make. + Mon Jan 27 16:49:52 2014 Kenta Murata * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional diff --git a/configure.in b/configure.in index ea14b941ed2c97..68da9e3f58bd4c 100644 --- a/configure.in +++ b/configure.in @@ -2656,7 +2656,7 @@ if test "$with_dln_a_out" != yes; then : ${LDSHARED='$(CC) -shared'} if test "$rb_cv_binary_elf" = yes; then LDFLAGS="$LDFLAGS -rdynamic" - DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)' + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@' else test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable' fi diff --git a/version.h b/version.h index 8ea34368f62f85..6d8bbb872b8c8f 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-27" -#define RUBY_PATCHLEVEL 10 +#define RUBY_RELEASE_DATE "2014-01-30" +#define RUBY_PATCHLEVEL 11 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 27 +#define RUBY_RELEASE_DAY 30 #include "ruby/version.h" From 286933b50c96f0a902b84d4edb4046a0b3d6df7d Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 31 Jan 2014 03:07:00 +0000 Subject: [PATCH 11/83] merge revision(s) 44406: [Backport #9324] * configure.in: let mingw do something black-magic, and check if _gmtime64_s() is available actually. * win32/win32.c (gmtime_s, localtime_s): use _gmtime64_s() and _localtime64_s() if available, not depending on very confusing mingw variants macros. based on the patch by phasis68 (Heesob Park) at [ruby-core:58764]. [ruby-core:58391] [Bug #9119] git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ configure.in | 2 ++ version.h | 6 +++--- win32/win32.c | 12 ++++++++---- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3766b864ae61ad..2dafde58451f31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Fri Jan 31 12:05:59 2014 Nobuyoshi Nakada + + * configure.in: let mingw do something black-magic, and check if + _gmtime64_s() is available actually. + + * win32/win32.c (gmtime_s, localtime_s): use _gmtime64_s() and + _localtime64_s() if available, not depending on very confusing + mingw variants macros. based on the patch by phasis68 (Heesob + Park) at [ruby-core:58764]. [ruby-core:58391] [Bug #9119] + Thu Jan 30 15:02:35 2014 Shugo Maeda * configure.in: use $@ instead of $(.TARGET) because .TARGET is not diff --git a/configure.in b/configure.in index 68da9e3f58bd4c..84f176dd9415be 100644 --- a/configure.in +++ b/configure.in @@ -888,6 +888,7 @@ AC_ARG_WITH(winnt-ver, AS_CASE(["$target_os"], [mingw*], [ RUBY_APPEND_OPTION(CPPFLAGS, -D_WIN32_WINNT=$with_winnt_ver) + RUBY_APPEND_OPTION(CPPFLAGS, -D__MINGW_USE_VC2005_COMPAT) ]) AS_CASE(["$target_os"], @@ -1040,6 +1041,7 @@ main() if test x"$ac_cv_type_NET_LUID" = xyes; then AC_DEFINE(HAVE_TYPE_NET_LUID, 1) fi + AC_CHECK_FUNCS(_gmtime64_s) AC_LIBOBJ([langinfo]) ], [os2-emx*], [ LIBS="-lm $LIBS" diff --git a/version.h b/version.h index 6d8bbb872b8c8f..072bf28ce92ee9 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-30" -#define RUBY_PATCHLEVEL 11 +#define RUBY_RELEASE_DATE "2014-01-31" +#define RUBY_PATCHLEVEL 12 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_DAY 31 #include "ruby/version.h" diff --git a/win32/win32.c b/win32/win32.c index 9cbd07f6697a97..2c888ae4c4a192 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -6965,7 +6965,7 @@ rb_w32_fd_is_text(int fd) return _osfile(fd) & FTEXT; } -#if RUBY_MSVCRT_VERSION < 80 && !defined(__MINGW64__) +#if RUBY_MSVCRT_VERSION < 80 && !defined(HAVE__GMTIME64_S) /* License: Ruby's */ static int unixtime_to_systemtime(const time_t t, SYSTEMTIME *st) @@ -7027,7 +7027,11 @@ systemtime_to_localtime(TIME_ZONE_INFORMATION *tz, SYSTEMTIME *gst, SYSTEMTIME * } #endif -#ifdef __MINGW64__ +#ifdef HAVE__GMTIME64_S +# ifndef HAVE__LOCALTIME64_S +/* assume same as _gmtime64_s() */ +# define HAVE__LOCALTIME64_S 1 +# endif # ifndef MINGW_HAS_SECURE_API _CRTIMP errno_t __cdecl _gmtime64_s(struct tm* tm, const __time64_t *time); _CRTIMP errno_t __cdecl _localtime64_s(struct tm* tm, const __time64_t *time); @@ -7046,7 +7050,7 @@ gmtime_r(const time_t *tp, struct tm *rp) errno = e; return NULL; } -#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__) +#if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__GMTIME64_S) e = gmtime_s(rp, tp); if (e != 0) goto error; #else @@ -7070,7 +7074,7 @@ localtime_r(const time_t *tp, struct tm *rp) errno = e; return NULL; } -#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__) +#if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__LOCALTIME64_S) e = localtime_s(rp, tp); if (e) goto error; #else From 528dfd0e00bcf904d08531b74f8f021f95b17345 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 31 Jan 2014 08:58:59 +0000 Subject: [PATCH 12/83] merge revision(s) 44455,44458,44510: [Backport #9349] * vm_insnhelper.c (vm_search_super_method): direct superclass of a module is found when super called in a Method object generated a method defined in a module, call method_missing in that case. [ruby-core:59358] [Bug #9315] * proc.c (mnew_from_me): keep iclass as-is, to make inheritance chain consistent. [ruby-core:59358] [Bug #9315] * proc.c (method_owner): return the original defined_class from prepended iclass, instead. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ proc.c | 13 ++++++++----- test/ruby/test_super.rb | 33 +++++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2dafde58451f31..601436f3261c95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada + + * proc.c (mnew_from_me): keep iclass as-is, to make inheritance + chain consistent. [ruby-core:59358] [Bug #9315] + + * proc.c (method_owner): return the original defined_class from + prepended iclass, instead. + Fri Jan 31 12:05:59 2014 Nobuyoshi Nakada * configure.in: let mingw do something black-magic, and check if diff --git a/proc.c b/proc.c index f8b2e3b3a9012f..e52beaf9d813d4 100644 --- a/proc.c +++ b/proc.c @@ -1171,10 +1171,6 @@ mnew_from_me(rb_method_entry_t *me, VALUE defined_class, VALUE klass, goto again; } - if (RB_TYPE_P(defined_class, T_ICLASS)) { - defined_class = RBASIC_CLASS(defined_class); - } - klass = defined_class; while (rclass != klass && @@ -1396,9 +1392,16 @@ static VALUE method_owner(VALUE obj) { struct METHOD *data; + VALUE defined_class; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); - return data->defined_class; + defined_class = data->defined_class; + + if (RB_TYPE_P(defined_class, T_ICLASS)) { + defined_class = RBASIC_CLASS(defined_class); + } + + return defined_class; } void diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index 846f40946db9b6..c5f724ebb8c900 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -407,4 +407,37 @@ def test_super_splat assert_equal([false, false], y.foo(false, false)) assert_equal([1, 2, 3, false, 5], y.foo(1, 2, 3, false, 5)) end + + def test_missing_super_in_method_module + bug9315 = '[ruby-core:59358] [Bug #9315]' + a = Module.new do + def foo + super + end + end + b = Class.new do + include a + end + assert_raise(NoMethodError, bug9315) do + b.new.method(:foo).call + end + end + + def test_module_super_in_method_module + bug9315 = '[ruby-core:59589] [Bug #9315]' + a = Module.new do + def foo + super + end + end + c = Class.new do + def foo + :ok + end + end + o = c.new.extend(a) + assert_nothing_raised(NoMethodError, bug9315) do + assert_equal(:ok, o.method(:foo).call, bug9315) + end + end end diff --git a/version.h b/version.h index 072bf28ce92ee9..c361122024b2b0 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-31" -#define RUBY_PATCHLEVEL 12 +#define RUBY_PATCHLEVEL 13 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From 905fb0d354b84e14ad15799b33ddcae37f3e35a0 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 31 Jan 2014 09:17:42 +0000 Subject: [PATCH 13/83] merge revision(s) 44515: [Backport #9375] * lib/rubygems: Update to RubyGems master 21e409d / RubyGems 2.2.1. See http://rubygems.rubyforge.org/rubygems-update/History_txt.html for a list of bug fixes. * test/rubygems: ditto. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 ++ NEWS | 2 + lib/rubygems.rb | 19 ++-- lib/rubygems/basic_specification.rb | 18 ++++ lib/rubygems/commands/contents_command.rb | 6 +- lib/rubygems/commands/install_command.rb | 20 ++-- lib/rubygems/commands/setup_command.rb | 16 +-- lib/rubygems/compatibility.rb | 4 +- lib/rubygems/defaults.rb | 20 ++-- lib/rubygems/deprecate.rb | 2 +- lib/rubygems/installer.rb | 4 +- lib/rubygems/platform.rb | 2 +- lib/rubygems/rdoc.rb | 2 +- lib/rubygems/request_set/lockfile.rb | 7 +- lib/rubygems/resolver.rb | 21 ---- lib/rubygems/resolver/installer_set.rb | 35 +----- lib/rubygems/specification.rb | 2 +- lib/rubygems/test_case.rb | 12 +-- lib/rubygems/uninstaller.rb | 2 +- test/rubygems/test_gem.rb | 102 +++++++++++------- .../test_gem_commands_contents_command.rb | 6 +- .../test_gem_commands_environment_command.rb | 2 +- .../test_gem_commands_install_command.rb | 15 +++ .../test_gem_commands_update_command.rb | 2 +- .../rubygems/test_gem_dependency_installer.rb | 2 +- test/rubygems/test_gem_installer.rb | 8 +- .../rubygems/test_gem_request_set_lockfile.rb | 10 +- test/rubygems/test_gem_specification.rb | 50 ++++++++- test/rubygems/test_gem_uninstaller.rb | 17 +++ version.h | 2 +- 30 files changed, 256 insertions(+), 163 deletions(-) diff --git a/ChangeLog b/ChangeLog index 601436f3261c95..e88b8e13949c57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Jan 31 18:13:43 2014 Eric Hodel + + * lib/rubygems: Update to RubyGems master 21e409d / RubyGems 2.2.1. + + See http://rubygems.rubyforge.org/rubygems-update/History_txt.html + for a list of bug fixes. + + * test/rubygems: ditto. + Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada * proc.c (mnew_from_me): keep iclass as-is, to make inheritance diff --git a/NEWS b/NEWS index a096ad9d28fc85..f622b9f2ed3ff8 100644 --- a/NEWS +++ b/NEWS @@ -276,6 +276,8 @@ String * Improved, iterative resolver (compared to RubyGems 2.1 and earlier) * Support for a sharing a GEM_HOME across ruby platforms and versions + * Updated to 2.2.1. Fixes some minor bugs and performance regressions. + For a complete list of enhancements and bug fixes see: https://github.com/rubygems/rubygems/tree/master/History.txt diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 73c4846f8274de..7afc85bda5174d 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.2.0' + VERSION = '2.2.1' end # Must be first since it unloads the prelude from 1.9.2 @@ -572,7 +572,7 @@ def self.host= host # gem's paths are inserted before site lib directory by default. def self.load_path_insert_index - index = $LOAD_PATH.index ConfigMap[:sitelibdir] + index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir'] index end @@ -743,8 +743,8 @@ def self.pre_uninstall(&hook) def self.prefix prefix = File.dirname RUBYGEMS_DIR - if prefix != File.expand_path(ConfigMap[:sitelibdir]) and - prefix != File.expand_path(ConfigMap[:libdir]) and + if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and + prefix != File.expand_path(RbConfig::CONFIG['libdir']) and 'lib' == File.basename(RUBYGEMS_DIR) then prefix end @@ -765,6 +765,10 @@ def self.read_binary(path) f.flock(File::LOCK_EX) f.read end + rescue Errno::EACCES + open path, 'rb' do |f| + f.read + end end ## @@ -772,8 +776,8 @@ def self.read_binary(path) def self.ruby if @ruby.nil? then - @ruby = File.join(ConfigMap[:bindir], - "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}") + @ruby = File.join(RbConfig::CONFIG['bindir'], + "#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}") @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/ end @@ -785,8 +789,7 @@ def self.ruby # Returns a String containing the API compatibility version of Ruby def self.ruby_api_version - @ruby_api_version ||= - "#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}" + @ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup end ## diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index a52377ff22e067..470a6ebc8b5c43 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -206,6 +206,24 @@ def require_paths [relative_extension_dir].concat @require_paths end + ## + # Returns the paths to the source files for use with analysis and + # documentation tools. These paths are relative to full_gem_path. + + def source_paths + paths = raw_require_paths.dup + + if @extensions then + ext_dirs = @extensions.map do |extension| + extension.split(File::SEPARATOR, 2).first + end.uniq + + paths.concat ext_dirs + end + + paths.uniq + end + ## # Return a Gem::Specification from this gem diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 97218848edac15..603f1d072aaa6f 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -94,11 +94,11 @@ def files_in_default_gem spec spec.files.sort.map do |file| case file when /\A#{spec.bindir}\// - [Gem::ConfigMap[:bindir], $POSTMATCH] + [RbConfig::CONFIG['bindir'], $POSTMATCH] when /\.so\z/ - [Gem::ConfigMap[:archdir], file] + [RbConfig::CONFIG['archdir'], file] else - [Gem::ConfigMap[:rubylibdir], file] + [RbConfig::CONFIG['rubylibdir'], file] end end end diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 4485eb12e81719..8219eef6ead096 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -228,7 +228,18 @@ def install_gem name, version # :nodoc: def install_gem_without_dependencies name, req # :nodoc: gem = nil - if remote? then + if local? then + if name =~ /\.gem$/ and File.file? name then + source = Gem::Source::SpecificFile.new name + spec = source.spec + else + source = Gem::Source::Local.new + spec = source.find_gem name, req + end + gem = source.download spec if spec + end + + if remote? and not gem then dependency = Gem::Dependency.new name, req dependency.prerelease = options[:prerelease] @@ -236,13 +247,6 @@ def install_gem_without_dependencies name, req # :nodoc: gem = fetcher.download_to_cache dependency end - if local? and not gem then - source = Gem::Source::Local.new - spec = source.find_gem name, req - - gem = source.download spec - end - inst = Gem::Installer.new gem, options inst.install diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index face77fae9ce28..681db0dc1d19fc 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -13,7 +13,7 @@ def initialize super 'setup', 'Install RubyGems', :format_executable => true, :document => %w[ri], - :site_or_vendor => :sitelibdir, + :site_or_vendor => 'sitelibdir', :destdir => '', :prefix => '', :previous_version => '' add_option '--previous-version=VERSION', @@ -36,7 +36,7 @@ def initialize add_option '--[no-]vendor', 'Install into vendorlibdir not sitelibdir' do |vendor, options| - options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir + options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir' end add_option '--[no-]format-executable', @@ -343,19 +343,19 @@ def generate_default_dirs(install_destdir) site_or_vendor = options[:site_or_vendor] if prefix.empty? then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + lib_dir = RbConfig::CONFIG[site_or_vendor] + bin_dir = RbConfig::CONFIG['bindir'] else # Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets # confused about installation location, so switch back to # sitelibdir/vendorlibdir. if defined?(APPLE_GEM_HOME) and # just in case Apple and RubyGems don't get this patched up proper. - (prefix == Gem::ConfigMap[:libdir] or + (prefix == RbConfig::CONFIG['libdir'] or # this one is important - prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then + lib_dir = RbConfig::CONFIG[site_or_vendor] + bin_dir = RbConfig::CONFIG['bindir'] else lib_dir = File.join prefix, 'lib' bin_dir = File.join prefix, 'bin' diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb index 5e8618fe39c088..d06ade1fa662ba 100644 --- a/lib/rubygems/compatibility.rb +++ b/lib/rubygems/compatibility.rb @@ -33,6 +33,8 @@ class << Gem module Gem RubyGemsVersion = VERSION + # TODO remove at RubyGems 3 + RbConfigPriorities = %w[ MAJOR MINOR @@ -45,7 +47,7 @@ module Gem unless defined?(ConfigMap) ## # Configuration settings from ::RbConfig - ConfigMap = Hash.new do |cm, key| + ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3 cm[key] = RbConfig::CONFIG[key.to_s] end else diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 715c0b71b36181..6924f48e5ade92 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -29,22 +29,22 @@ def self.default_spec_cache_dir def self.default_dir path = if defined? RUBY_FRAMEWORK_VERSION then [ - File.dirname(ConfigMap[:sitedir]), + File.dirname(RbConfig::CONFIG['sitedir']), 'Gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] - elsif ConfigMap[:rubylibprefix] then + elsif RbConfig::CONFIG['rubylibprefix'] then [ - ConfigMap[:rubylibprefix], + RbConfig::CONFIG['rubylibprefix'], 'gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] else [ - ConfigMap[:libdir], + RbConfig::CONFIG['libdir'], ruby_engine, 'gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] end @@ -74,7 +74,7 @@ def self.default_rubygems_dirs def self.user_dir parts = [Gem.user_home, '.gem', ruby_engine] - parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty? + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? File.join parts end @@ -100,7 +100,7 @@ def self.default_path # Deduce Ruby's --program-prefix and --program-suffix from its install name def self.default_exec_format - exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s' + exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s' unless exec_format =~ /%s/ then raise Gem::Exception, @@ -117,7 +117,7 @@ def self.default_bindir if defined? RUBY_FRAMEWORK_VERSION then # mac framework support '/usr/bin' else # generic install - ConfigMap[:bindir] + RbConfig::CONFIG['bindir'] end end diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 274d6a5c12023f..e19360da13a81f 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -50,7 +50,7 @@ def deprecate name, repl, year, month class_eval { old = "_deprecated_#{name}" alias_method old, name - define_method name do |*args, &block| # TODO: really works on 1.8.7? + define_method name do |*args, &block| klass = self.kind_of? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index f8eb2c2145fa1e..33d2f78d46a429 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -480,7 +480,7 @@ def generate_bin_symlink(filename, bindir) # def shebang(bin_file_name) - ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang + ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang path = File.join gem_dir, spec.bindir, bin_file_name first_line = File.open(path, "rb") {|file| file.gets} @@ -493,7 +493,7 @@ def shebang(bin_file_name) if which = Gem.configuration[:custom_shebang] # replace bin_file_name with "ruby" to avoid endless loops - which = which.gsub(/ #{bin_file_name}$/," #{Gem::ConfigMap[:ruby_install_name]}") + which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}") which = which.gsub(/\$(\w+)/) do case $1 diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index e050959dc6fde5..1bcd7549ad4f79 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -16,7 +16,7 @@ class Gem::Platform attr_accessor :version def self.local - arch = Gem::ConfigMap[:arch] + arch = RbConfig::CONFIG['arch'] arch = "#{arch}_60" if arch =~ /mswin32$/ @local ||= new(arch) end diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb index 52249dc267aa88..633bd893a5df0c 100644 --- a/lib/rubygems/rdoc.rb +++ b/lib/rubygems/rdoc.rb @@ -193,7 +193,7 @@ def generate ::RDoc::Parser::C.reset args = @spec.rdoc_options - args.concat @spec.require_paths + args.concat @spec.source_paths args.concat @spec.extra_rdoc_files case config_args = Gem.configuration[:rdoc] diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 522caf15026af0..0433d2a7fc86e5 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -303,7 +303,12 @@ def parse_GEM # :nodoc: type, data, = get [:text, :requirement] if type == :text and column == 4 then - last_spec = set.add name, data, Gem::Platform::RUBY + version, platform = data.split '-', 2 + + platform = + platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY + + last_spec = set.add name, version, platform else dependency = parse_dependency name, data diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index d455e03c0576fb..15a96693e95275 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -178,27 +178,6 @@ def resolve res.to_a end - ## - # Finds the State in +states+ that matches the +conflict+ so that we can try - # other possible sets. - # - # If no good candidate is found, the first state is tried. - - def find_conflict_state conflict, states # :nodoc: - until states.empty? do - state = states.pop - - explain :consider, state.dep, conflict.failed_dep - - if conflict.for_spec? state.spec - state.conflicts << [state.spec, conflict] - return state - end - end - - nil - end - ## # Extracts the specifications that may be able to fulfill +dependency+ and # returns those that match the local platform and all those that match. diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index e35e0aabecc92a..27e64551480f61 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -28,11 +28,10 @@ def initialize domain @f = Gem::SpecFetcher.fetcher - @all = Hash.new { |h,k| h[k] = [] } @always_install = [] @ignore_dependencies = false @ignore_installed = false - @loaded_remote_specs = [] + @remote_set = Gem::Resolver::BestSet.new if consider_remote? @specs = {} end @@ -79,16 +78,7 @@ def find_all req end end - if consider_remote? then - load_remote_specs dep - - @all[name].each do |remote_source, n| - if dep.match? n then - res << Gem::Resolver::IndexSpecification.new( - self, n.name, n.version, remote_source, n.platform) - end - end - end + res.concat @remote_set.find_all req if consider_remote? res end @@ -101,27 +91,6 @@ def inspect # :nodoc: ] end - ## - # Loads remote prerelease specs if +dep+ is a prerelease dependency - - def load_remote_specs dep # :nodoc: - types = [:released] - types << :prerelease if dep.prerelease? - - types.each do |type| - next if @loaded_remote_specs.include? type - @loaded_remote_specs << type - - list, = @f.available_specs type - - list.each do |uri, specs| - specs.each do |n| - @all[n.name] << [uri, n] - end - end - end - end - ## # Called from IndexSpecification to get a true Specification # object. diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 59d71d378bb3f7..e98f3284cd0bd2 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -327,7 +327,7 @@ def files add_bindir(@executables), @extra_rdoc_files, @extensions, - ].flatten.sort.uniq.compact + ].flatten.uniq.compact.sort end ###################################################################### diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 8dc37d67204dc6..ff261f7816e796 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -294,10 +294,10 @@ def setup Gem.searcher = nil Gem::SpecFetcher.fetcher = nil - @orig_BASERUBY = Gem::ConfigMap[:BASERUBY] - Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:ruby_install_name] + @orig_BASERUBY = RbConfig::CONFIG['BASERUBY'] + RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name'] - @orig_arch = Gem::ConfigMap[:arch] + @orig_arch = RbConfig::CONFIG['arch'] if win_platform? util_set_arch 'i386-mswin32' @@ -315,8 +315,8 @@ def setup def teardown $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH - Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY - Gem::ConfigMap[:arch] = @orig_arch + RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY + RbConfig::CONFIG['arch'] = @orig_arch if defined? Gem::RemoteFetcher then Gem::RemoteFetcher.fetcher = nil @@ -898,7 +898,7 @@ def util_make_gems(prerelease = false) # Set the platform to +arch+ def util_set_arch(arch) - Gem::ConfigMap[:arch] = arch + RbConfig::CONFIG['arch'] = arch platform = Gem::Platform.new arch Gem.instance_variable_set :@platforms, nil diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index 4cb2a1d33334ba..fa838333cd4543 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -237,7 +237,7 @@ def remove(spec) unless path_ok?(@gem_home, spec) or (@user_install and path_ok?(Gem.user_dir, spec)) then e = Gem::GemNotInHomeException.new \ - "Gem is not installed in directory #{@gem_home}" + "Gem '#{spec.full_name}' is not installed in directory #{@gem_home}" e.spec = spec raise e diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 759c2fe9070759..513f2d4e58e835 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -199,30 +199,30 @@ def test_self_datadir_nonexistent_package end def test_self_default_exec_format - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'ruby' + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['ruby_install_name'] = 'ruby' assert_equal '%s', Gem.default_exec_format ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME end def test_self_default_exec_format_18 - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'ruby18' + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['ruby_install_name'] = 'ruby18' assert_equal '%s18', Gem.default_exec_format ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME end def test_self_default_exec_format_jruby - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'jruby' + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['ruby_install_name'] = 'jruby' assert_equal 'j%s', Gem.default_exec_format ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME end def test_self_default_sources @@ -230,6 +230,7 @@ def test_self_default_sources end def test_self_detect_gemdeps + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' FileUtils.mkdir_p 'detect/a/b' @@ -565,24 +566,43 @@ def test_self_prefix end def test_self_prefix_libdir - orig_libdir = Gem::ConfigMap[:libdir] - Gem::ConfigMap[:libdir] = @@project_dir + orig_libdir = RbConfig::CONFIG['libdir'] + RbConfig::CONFIG['libdir'] = @@project_dir assert_nil Gem.prefix ensure - Gem::ConfigMap[:libdir] = orig_libdir + RbConfig::CONFIG['libdir'] = orig_libdir end def test_self_prefix_sitelibdir - orig_sitelibdir = Gem::ConfigMap[:sitelibdir] - Gem::ConfigMap[:sitelibdir] = @@project_dir + orig_sitelibdir = RbConfig::CONFIG['sitelibdir'] + RbConfig::CONFIG['sitelibdir'] = @@project_dir assert_nil Gem.prefix ensure - Gem::ConfigMap[:sitelibdir] = orig_sitelibdir + RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir + end + + def test_self_read_binary + open 'test', 'w' do |io| + io.write "\xCF\x80" + end + + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + + skip 'chmod not supported' if Gem.win_platform? + + begin + File.chmod 0444, 'test' + + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + ensure + File.chmod 0644, 'test' + end end def test_self_refresh + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -602,6 +622,7 @@ def test_self_refresh end def test_self_refresh_keeps_loaded_specs_activated + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -624,46 +645,44 @@ def test_self_refresh_keeps_loaded_specs_activated def test_self_ruby_escaping_spaces_in_path orig_ruby = Gem.ruby - orig_bindir = Gem::ConfigMap[:bindir] - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] - orig_exe_ext = Gem::ConfigMap[:EXEEXT] + orig_bindir = RbConfig::CONFIG['bindir'] + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin" - Gem::ConfigMap[:ruby_install_name] = "ruby" - Gem::ConfigMap[:EXEEXT] = ".exe" + RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" + RbConfig::CONFIG['ruby_install_name'] = "ruby" + RbConfig::CONFIG['EXEEXT'] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - Gem::ConfigMap[:bindir] = orig_bindir - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name - Gem::ConfigMap[:EXEEXT] = orig_exe_ext + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_path_without_spaces orig_ruby = Gem.ruby - orig_bindir = Gem::ConfigMap[:bindir] - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] - orig_exe_ext = Gem::ConfigMap[:EXEEXT] + orig_bindir = RbConfig::CONFIG['bindir'] + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - Gem::ConfigMap[:bindir] = "C:/Ruby18/bin" - Gem::ConfigMap[:ruby_install_name] = "ruby" - Gem::ConfigMap[:EXEEXT] = ".exe" + RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" + RbConfig::CONFIG['ruby_install_name'] = "ruby" + RbConfig::CONFIG['EXEEXT'] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - Gem::ConfigMap[:bindir] = orig_bindir - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name - Gem::ConfigMap[:EXEEXT] = orig_exe_ext + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_api_version - orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1' - orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2' - orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3' + orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3' Gem.instance_variable_set :@ruby_api_version, nil @@ -671,9 +690,7 @@ def test_self_ruby_api_version ensure Gem.instance_variable_set :@ruby_api_version, nil - Gem::ConfigMap[:MAJOR] = orig_MAJOR - Gem::ConfigMap[:MINOR] = orig_MINOR - Gem::ConfigMap[:TEENY] = orig_TEENY + RbConfig::CONFIG['ruby_version'] = orig_ruby_version end def test_self_ruby_version_1_8_5 @@ -825,7 +842,7 @@ def test_self_use_paths def test_self_user_dir parts = [@userhome, '.gem', Gem.ruby_engine] - parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty? + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? assert_equal File.join(parts), Gem.user_dir end @@ -857,6 +874,7 @@ def test_self_needs end def test_self_needs_picks_up_unresolved_deps + skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7" save_loaded_features do util_clear_gems a = util_spec "a", "1" @@ -949,6 +967,7 @@ def test_self_user_home_user_drive_and_path end def test_load_plugins + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" plugin_path = File.join "lib", "rubygems_plugin.rb" Dir.chdir @tempdir do @@ -1102,6 +1121,7 @@ def test_auto_activation_of_specific_gemdeps_file end def test_auto_activation_of_detected_gemdeps_file + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" util_clear_gems a = new_spec "a", "1", nil, "lib/a.rb" @@ -1264,6 +1284,7 @@ def test_use_gemdeps end def test_use_gemdeps_automatic + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' spec = util_spec 'a', 1 @@ -1300,6 +1321,7 @@ def test_use_gemdeps_disabled end def test_use_gemdeps_specific + skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x' spec = util_spec 'a', 1 diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb index d87e84fc829fc0..7f5cf22223cff5 100644 --- a/test/rubygems/test_gem_commands_contents_command.rb +++ b/test/rubygems/test_gem_commands_contents_command.rb @@ -169,9 +169,9 @@ def test_execute_default_gem end expected = [ - File.join(Gem::ConfigMap[:bindir], 'default_command'), - File.join(Gem::ConfigMap[:rubylibdir], 'default/gem.rb'), - File.join(Gem::ConfigMap[:archdir], 'default_gem.so') + File.join(RbConfig::CONFIG['bindir'], 'default_command'), + File.join(RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'), + File.join(RbConfig::CONFIG['archdir'], 'default_gem.so') ].sort.join "\n" assert_equal expected, @ui.output.chomp diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb index 253c459d942840..bb7589f50de1c3 100644 --- a/test/rubygems/test_gem_commands_environment_command.rb +++ b/test/rubygems/test_gem_commands_environment_command.rb @@ -26,7 +26,7 @@ def test_execute assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|, @ui.output assert_match %r|RUBYGEMS PREFIX: |, @ui.output - assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:ruby_install_name]}|, + assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|, @ui.output assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 00bbf7bae7eca2..6315cb5d95b5ed 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -316,6 +316,7 @@ def test_execute_prerelease_skipped_when_non_pre_available end def test_execute_rdoc + skip if RUBY_VERSION <= "1.8.7" specs = spec_fetcher do |fetcher| fetcher.gem 'a', 2 end @@ -559,6 +560,20 @@ def test_install_gem_ignore_dependencies_remote assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name } end + def test_install_gem_ignore_dependencies_specific_file + spec = quick_spec 'a', 2 + + util_build_gem spec + + FileUtils.mv spec.cache_file, @tempdir + + @cmd.options[:ignore_dependencies] = true + + @cmd.install_gem File.join(@tempdir, spec.file_name), nil + + assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name } + end + def test_parses_requirement_from_gemname spec_fetcher do |fetcher| fetcher.gem 'a', 2 diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index 7537c1c9c10532..d259383ba2fbb2 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -217,6 +217,7 @@ def test_execute_dependencies end def test_execute_rdoc + skip if RUBY_VERSION <= "1.8.7" spec_fetcher do |fetcher| fetcher.gem 'a', 2 @@ -239,7 +240,6 @@ def test_execute_rdoc a2 = @specs['a-2'] - assert_path_exists File.join(a2.doc_dir, 'ri') assert_path_exists File.join(a2.doc_dir, 'rdoc') end diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index 0a82fa63cbbd19..352ebbb54ff513 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -551,7 +551,7 @@ def test_install_env_shebang env = "/\\S+/env" unless Gem.win_platform? - assert_match %r|\A#!#{env} #{Gem::ConfigMap[:ruby_install_name]}\n|, + assert_match %r|\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n|, File.read(File.join(@gemhome, 'bin', 'a_bin')) end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 615a9b57ba4afa..54ac853135b9cf 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -84,8 +84,8 @@ def test_check_executable_overwrite_default_bin_dir orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION Object.send :remove_const, :RUBY_FRAMEWORK_VERSION end - orig_bindir = Gem::ConfigMap[:bindir] - Gem::ConfigMap[:bindir] = Gem.bindir + orig_bindir = RbConfig::CONFIG['bindir'] + RbConfig::CONFIG['bindir'] = Gem.bindir util_conflict_executable false @@ -102,7 +102,7 @@ def test_check_executable_overwrite_default_bin_dir ensure Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if orig_RUBY_FRAMEWORK_VERSION - Gem::ConfigMap[:bindir] = orig_bindir + RbConfig::CONFIG['bindir'] = orig_bindir end def test_check_executable_overwrite_format_executable @@ -1192,7 +1192,7 @@ def test_shebang_env_shebang env_shebang = "/usr/bin/env" unless Gem.win_platform? - assert_equal("#!#{env_shebang} #{Gem::ConfigMap[:ruby_install_name]}", + assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}", shebang) end diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb index 9e0cab4d1a8f79..0be69bf92b30d4 100644 --- a/test/rubygems/test_gem_request_set_lockfile.rb +++ b/test/rubygems/test_gem_request_set_lockfile.rb @@ -218,6 +218,7 @@ def test_parse_gem_specs_dependency c (~> 4) d e (~> 5.0, >= 5.0.1) + b (3-x86_64-linux) PLATFORMS #{Gem::Platform::RUBY} @@ -238,7 +239,14 @@ def test_parse_gem_specs_dependency assert lockfile_set, 'could not find a LockSet' - assert_equal %w[a-2], lockfile_set.specs.map { |tuple| tuple.full_name } + assert_equal %w[a-2 b-3], lockfile_set.specs.map { |tuple| tuple.full_name } + + expected = [ + Gem::Platform::RUBY, + Gem::Platform.new('x86_64-linux'), + ] + + assert_equal expected, lockfile_set.specs.map { |tuple| tuple.platform } spec = lockfile_set.specs.first diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 7aa9d5aeb17a4a..b72a5d1baf01cd 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -999,8 +999,8 @@ def test_initialize_copy assert_equal 'summary', spec.summary assert_same spec.summary, new_spec.summary - assert_equal %w[lib/file.rb test/file.rb bin/exec README.txt - ext/extconf.rb].sort, + assert_equal %w[README.txt bin/exec ext/extconf.rb lib/file.rb + test/file.rb].sort, spec.files refute_same spec.files, new_spec.files, 'files' @@ -1109,7 +1109,31 @@ def test_bindir_equals_nil @a2.executable = 'app' assert_equal nil, @a2.bindir - assert_equal %w[lib/code.rb app].sort, @a2.files + assert_equal %w[app lib/code.rb].sort, @a2.files + end + + def test_extensions_equals_nil + @a2.instance_variable_set(:@extensions, nil) + assert_equal nil, @a2.instance_variable_get(:@extensions) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_test_files_equals_nil + @a2.instance_variable_set(:@test_files, nil) + assert_equal nil, @a2.instance_variable_get(:@test_files) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_executables_equals_nil + @a2.instance_variable_set(:@executables, nil) + assert_equal nil, @a2.instance_variable_get(:@executables) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_extra_rdoc_files_equals_nil + @a2.instance_variable_set(:@extra_rdoc_files, nil) + assert_equal nil, @a2.instance_variable_get(:@extra_rdoc_files) + assert_equal %w[lib/code.rb], @a2.files end def test_build_extensions @@ -1437,7 +1461,7 @@ def test_executables def test_executable_equals @a2.executable = 'app' assert_equal 'app', @a2.executable - assert_equal %w[lib/code.rb bin/app].sort, @a2.files + assert_equal %w[bin/app lib/code.rb].sort, @a2.files end def test_extensions @@ -1785,6 +1809,22 @@ def test_source assert_kind_of Gem::Source::Installed, @a1.source end + def test_source_paths + ext_spec + + @ext.require_paths = %w[lib ext foo] + @ext.extensions << 'bar/baz' + + expected = %w[ + lib + ext + foo + bar + ] + + assert_equal expected, @ext.source_paths + end + def test_full_require_paths ext_spec @@ -2435,7 +2475,7 @@ def test_validate_files assert_equal '["lib2"] are not files', e.message end - assert_equal %w[lib/code.rb test/suite.rb bin/exec ext/a/extconf.rb lib2].sort, + assert_equal %w[bin/exec ext/a/extconf.rb lib/code.rb lib2 test/suite.rb].sort, @a1.files end diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 1eea30fb9403d6..11fdaf68e22118 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -131,6 +131,23 @@ def test_remove_executables_user_format_disabled Gem::Installer.exec_format = nil end + def test_remove_not_in_home + uninstaller = Gem::Uninstaller.new nil, :install_dir => "#{@gemhome}2" + + e = assert_raises Gem::GemNotInHomeException do + use_ui ui do + uninstaller.remove @spec + end + end + + expected = + "Gem '#{@spec.full_name}' is not installed in directory #{@gemhome}2" + + assert_equal expected, e.message + + assert_path_exists @spec.gem_dir + end + def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil diff --git a/version.h b/version.h index c361122024b2b0..8553f79047718a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-31" -#define RUBY_PATCHLEVEL 13 +#define RUBY_PATCHLEVEL 14 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From ad5dc285c413cd8f5abda40d3f59ed10a4a2e379 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 1 Feb 2014 08:19:06 +0000 Subject: [PATCH 14/83] Revert r44778 #9375 It breaks test-all if all tests are in a single process git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 -- NEWS | 2 - lib/rubygems.rb | 19 ++-- lib/rubygems/basic_specification.rb | 18 ---- lib/rubygems/commands/contents_command.rb | 6 +- lib/rubygems/commands/install_command.rb | 20 ++-- lib/rubygems/commands/setup_command.rb | 16 +-- lib/rubygems/compatibility.rb | 4 +- lib/rubygems/defaults.rb | 20 ++-- lib/rubygems/deprecate.rb | 2 +- lib/rubygems/installer.rb | 4 +- lib/rubygems/platform.rb | 2 +- lib/rubygems/rdoc.rb | 2 +- lib/rubygems/request_set/lockfile.rb | 7 +- lib/rubygems/resolver.rb | 21 ++++ lib/rubygems/resolver/installer_set.rb | 35 +++++- lib/rubygems/specification.rb | 2 +- lib/rubygems/test_case.rb | 12 +-- lib/rubygems/uninstaller.rb | 2 +- test/rubygems/test_gem.rb | 102 +++++++----------- .../test_gem_commands_contents_command.rb | 6 +- .../test_gem_commands_environment_command.rb | 2 +- .../test_gem_commands_install_command.rb | 15 --- .../test_gem_commands_update_command.rb | 2 +- .../rubygems/test_gem_dependency_installer.rb | 2 +- test/rubygems/test_gem_installer.rb | 8 +- .../rubygems/test_gem_request_set_lockfile.rb | 10 +- test/rubygems/test_gem_specification.rb | 50 +-------- test/rubygems/test_gem_uninstaller.rb | 17 --- version.h | 2 +- 30 files changed, 163 insertions(+), 256 deletions(-) diff --git a/ChangeLog b/ChangeLog index e88b8e13949c57..601436f3261c95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,3 @@ -Fri Jan 31 18:13:43 2014 Eric Hodel - - * lib/rubygems: Update to RubyGems master 21e409d / RubyGems 2.2.1. - - See http://rubygems.rubyforge.org/rubygems-update/History_txt.html - for a list of bug fixes. - - * test/rubygems: ditto. - Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada * proc.c (mnew_from_me): keep iclass as-is, to make inheritance diff --git a/NEWS b/NEWS index f622b9f2ed3ff8..a096ad9d28fc85 100644 --- a/NEWS +++ b/NEWS @@ -276,8 +276,6 @@ String * Improved, iterative resolver (compared to RubyGems 2.1 and earlier) * Support for a sharing a GEM_HOME across ruby platforms and versions - * Updated to 2.2.1. Fixes some minor bugs and performance regressions. - For a complete list of enhancements and bug fixes see: https://github.com/rubygems/rubygems/tree/master/History.txt diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 7afc85bda5174d..73c4846f8274de 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.2.1' + VERSION = '2.2.0' end # Must be first since it unloads the prelude from 1.9.2 @@ -572,7 +572,7 @@ def self.host= host # gem's paths are inserted before site lib directory by default. def self.load_path_insert_index - index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir'] + index = $LOAD_PATH.index ConfigMap[:sitelibdir] index end @@ -743,8 +743,8 @@ def self.pre_uninstall(&hook) def self.prefix prefix = File.dirname RUBYGEMS_DIR - if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and - prefix != File.expand_path(RbConfig::CONFIG['libdir']) and + if prefix != File.expand_path(ConfigMap[:sitelibdir]) and + prefix != File.expand_path(ConfigMap[:libdir]) and 'lib' == File.basename(RUBYGEMS_DIR) then prefix end @@ -765,10 +765,6 @@ def self.read_binary(path) f.flock(File::LOCK_EX) f.read end - rescue Errno::EACCES - open path, 'rb' do |f| - f.read - end end ## @@ -776,8 +772,8 @@ def self.read_binary(path) def self.ruby if @ruby.nil? then - @ruby = File.join(RbConfig::CONFIG['bindir'], - "#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}") + @ruby = File.join(ConfigMap[:bindir], + "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}") @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/ end @@ -789,7 +785,8 @@ def self.ruby # Returns a String containing the API compatibility version of Ruby def self.ruby_api_version - @ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup + @ruby_api_version ||= + "#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}" end ## diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 470a6ebc8b5c43..a52377ff22e067 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -206,24 +206,6 @@ def require_paths [relative_extension_dir].concat @require_paths end - ## - # Returns the paths to the source files for use with analysis and - # documentation tools. These paths are relative to full_gem_path. - - def source_paths - paths = raw_require_paths.dup - - if @extensions then - ext_dirs = @extensions.map do |extension| - extension.split(File::SEPARATOR, 2).first - end.uniq - - paths.concat ext_dirs - end - - paths.uniq - end - ## # Return a Gem::Specification from this gem diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 603f1d072aaa6f..97218848edac15 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -94,11 +94,11 @@ def files_in_default_gem spec spec.files.sort.map do |file| case file when /\A#{spec.bindir}\// - [RbConfig::CONFIG['bindir'], $POSTMATCH] + [Gem::ConfigMap[:bindir], $POSTMATCH] when /\.so\z/ - [RbConfig::CONFIG['archdir'], file] + [Gem::ConfigMap[:archdir], file] else - [RbConfig::CONFIG['rubylibdir'], file] + [Gem::ConfigMap[:rubylibdir], file] end end end diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 8219eef6ead096..4485eb12e81719 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -228,18 +228,7 @@ def install_gem name, version # :nodoc: def install_gem_without_dependencies name, req # :nodoc: gem = nil - if local? then - if name =~ /\.gem$/ and File.file? name then - source = Gem::Source::SpecificFile.new name - spec = source.spec - else - source = Gem::Source::Local.new - spec = source.find_gem name, req - end - gem = source.download spec if spec - end - - if remote? and not gem then + if remote? then dependency = Gem::Dependency.new name, req dependency.prerelease = options[:prerelease] @@ -247,6 +236,13 @@ def install_gem_without_dependencies name, req # :nodoc: gem = fetcher.download_to_cache dependency end + if local? and not gem then + source = Gem::Source::Local.new + spec = source.find_gem name, req + + gem = source.download spec + end + inst = Gem::Installer.new gem, options inst.install diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 681db0dc1d19fc..face77fae9ce28 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -13,7 +13,7 @@ def initialize super 'setup', 'Install RubyGems', :format_executable => true, :document => %w[ri], - :site_or_vendor => 'sitelibdir', + :site_or_vendor => :sitelibdir, :destdir => '', :prefix => '', :previous_version => '' add_option '--previous-version=VERSION', @@ -36,7 +36,7 @@ def initialize add_option '--[no-]vendor', 'Install into vendorlibdir not sitelibdir' do |vendor, options| - options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir' + options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir end add_option '--[no-]format-executable', @@ -343,19 +343,19 @@ def generate_default_dirs(install_destdir) site_or_vendor = options[:site_or_vendor] if prefix.empty? then - lib_dir = RbConfig::CONFIG[site_or_vendor] - bin_dir = RbConfig::CONFIG['bindir'] + lib_dir = Gem::ConfigMap[site_or_vendor] + bin_dir = Gem::ConfigMap[:bindir] else # Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets # confused about installation location, so switch back to # sitelibdir/vendorlibdir. if defined?(APPLE_GEM_HOME) and # just in case Apple and RubyGems don't get this patched up proper. - (prefix == RbConfig::CONFIG['libdir'] or + (prefix == Gem::ConfigMap[:libdir] or # this one is important - prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then - lib_dir = RbConfig::CONFIG[site_or_vendor] - bin_dir = RbConfig::CONFIG['bindir'] + prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then + lib_dir = Gem::ConfigMap[site_or_vendor] + bin_dir = Gem::ConfigMap[:bindir] else lib_dir = File.join prefix, 'lib' bin_dir = File.join prefix, 'bin' diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb index d06ade1fa662ba..5e8618fe39c088 100644 --- a/lib/rubygems/compatibility.rb +++ b/lib/rubygems/compatibility.rb @@ -33,8 +33,6 @@ class << Gem module Gem RubyGemsVersion = VERSION - # TODO remove at RubyGems 3 - RbConfigPriorities = %w[ MAJOR MINOR @@ -47,7 +45,7 @@ module Gem unless defined?(ConfigMap) ## # Configuration settings from ::RbConfig - ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3 + ConfigMap = Hash.new do |cm, key| cm[key] = RbConfig::CONFIG[key.to_s] end else diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 6924f48e5ade92..715c0b71b36181 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -29,22 +29,22 @@ def self.default_spec_cache_dir def self.default_dir path = if defined? RUBY_FRAMEWORK_VERSION then [ - File.dirname(RbConfig::CONFIG['sitedir']), + File.dirname(ConfigMap[:sitedir]), 'Gems', - RbConfig::CONFIG['ruby_version'] + ConfigMap[:ruby_version] ] - elsif RbConfig::CONFIG['rubylibprefix'] then + elsif ConfigMap[:rubylibprefix] then [ - RbConfig::CONFIG['rubylibprefix'], + ConfigMap[:rubylibprefix], 'gems', - RbConfig::CONFIG['ruby_version'] + ConfigMap[:ruby_version] ] else [ - RbConfig::CONFIG['libdir'], + ConfigMap[:libdir], ruby_engine, 'gems', - RbConfig::CONFIG['ruby_version'] + ConfigMap[:ruby_version] ] end @@ -74,7 +74,7 @@ def self.default_rubygems_dirs def self.user_dir parts = [Gem.user_home, '.gem', ruby_engine] - parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty? File.join parts end @@ -100,7 +100,7 @@ def self.default_path # Deduce Ruby's --program-prefix and --program-suffix from its install name def self.default_exec_format - exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s' + exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s' unless exec_format =~ /%s/ then raise Gem::Exception, @@ -117,7 +117,7 @@ def self.default_bindir if defined? RUBY_FRAMEWORK_VERSION then # mac framework support '/usr/bin' else # generic install - RbConfig::CONFIG['bindir'] + ConfigMap[:bindir] end end diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index e19360da13a81f..274d6a5c12023f 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -50,7 +50,7 @@ def deprecate name, repl, year, month class_eval { old = "_deprecated_#{name}" alias_method old, name - define_method name do |*args, &block| + define_method name do |*args, &block| # TODO: really works on 1.8.7? klass = self.kind_of? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 33d2f78d46a429..f8eb2c2145fa1e 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -480,7 +480,7 @@ def generate_bin_symlink(filename, bindir) # def shebang(bin_file_name) - ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang + ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang path = File.join gem_dir, spec.bindir, bin_file_name first_line = File.open(path, "rb") {|file| file.gets} @@ -493,7 +493,7 @@ def shebang(bin_file_name) if which = Gem.configuration[:custom_shebang] # replace bin_file_name with "ruby" to avoid endless loops - which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}") + which = which.gsub(/ #{bin_file_name}$/," #{Gem::ConfigMap[:ruby_install_name]}") which = which.gsub(/\$(\w+)/) do case $1 diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 1bcd7549ad4f79..e050959dc6fde5 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -16,7 +16,7 @@ class Gem::Platform attr_accessor :version def self.local - arch = RbConfig::CONFIG['arch'] + arch = Gem::ConfigMap[:arch] arch = "#{arch}_60" if arch =~ /mswin32$/ @local ||= new(arch) end diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb index 633bd893a5df0c..52249dc267aa88 100644 --- a/lib/rubygems/rdoc.rb +++ b/lib/rubygems/rdoc.rb @@ -193,7 +193,7 @@ def generate ::RDoc::Parser::C.reset args = @spec.rdoc_options - args.concat @spec.source_paths + args.concat @spec.require_paths args.concat @spec.extra_rdoc_files case config_args = Gem.configuration[:rdoc] diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 0433d2a7fc86e5..522caf15026af0 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -303,12 +303,7 @@ def parse_GEM # :nodoc: type, data, = get [:text, :requirement] if type == :text and column == 4 then - version, platform = data.split '-', 2 - - platform = - platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY - - last_spec = set.add name, version, platform + last_spec = set.add name, data, Gem::Platform::RUBY else dependency = parse_dependency name, data diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index 15a96693e95275..d455e03c0576fb 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -178,6 +178,27 @@ def resolve res.to_a end + ## + # Finds the State in +states+ that matches the +conflict+ so that we can try + # other possible sets. + # + # If no good candidate is found, the first state is tried. + + def find_conflict_state conflict, states # :nodoc: + until states.empty? do + state = states.pop + + explain :consider, state.dep, conflict.failed_dep + + if conflict.for_spec? state.spec + state.conflicts << [state.spec, conflict] + return state + end + end + + nil + end + ## # Extracts the specifications that may be able to fulfill +dependency+ and # returns those that match the local platform and all those that match. diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index 27e64551480f61..e35e0aabecc92a 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -28,10 +28,11 @@ def initialize domain @f = Gem::SpecFetcher.fetcher + @all = Hash.new { |h,k| h[k] = [] } @always_install = [] @ignore_dependencies = false @ignore_installed = false - @remote_set = Gem::Resolver::BestSet.new if consider_remote? + @loaded_remote_specs = [] @specs = {} end @@ -78,7 +79,16 @@ def find_all req end end - res.concat @remote_set.find_all req if consider_remote? + if consider_remote? then + load_remote_specs dep + + @all[name].each do |remote_source, n| + if dep.match? n then + res << Gem::Resolver::IndexSpecification.new( + self, n.name, n.version, remote_source, n.platform) + end + end + end res end @@ -91,6 +101,27 @@ def inspect # :nodoc: ] end + ## + # Loads remote prerelease specs if +dep+ is a prerelease dependency + + def load_remote_specs dep # :nodoc: + types = [:released] + types << :prerelease if dep.prerelease? + + types.each do |type| + next if @loaded_remote_specs.include? type + @loaded_remote_specs << type + + list, = @f.available_specs type + + list.each do |uri, specs| + specs.each do |n| + @all[n.name] << [uri, n] + end + end + end + end + ## # Called from IndexSpecification to get a true Specification # object. diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index e98f3284cd0bd2..59d71d378bb3f7 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -327,7 +327,7 @@ def files add_bindir(@executables), @extra_rdoc_files, @extensions, - ].flatten.uniq.compact.sort + ].flatten.sort.uniq.compact end ###################################################################### diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index ff261f7816e796..8dc37d67204dc6 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -294,10 +294,10 @@ def setup Gem.searcher = nil Gem::SpecFetcher.fetcher = nil - @orig_BASERUBY = RbConfig::CONFIG['BASERUBY'] - RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name'] + @orig_BASERUBY = Gem::ConfigMap[:BASERUBY] + Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:ruby_install_name] - @orig_arch = RbConfig::CONFIG['arch'] + @orig_arch = Gem::ConfigMap[:arch] if win_platform? util_set_arch 'i386-mswin32' @@ -315,8 +315,8 @@ def setup def teardown $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH - RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY - RbConfig::CONFIG['arch'] = @orig_arch + Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY + Gem::ConfigMap[:arch] = @orig_arch if defined? Gem::RemoteFetcher then Gem::RemoteFetcher.fetcher = nil @@ -898,7 +898,7 @@ def util_make_gems(prerelease = false) # Set the platform to +arch+ def util_set_arch(arch) - RbConfig::CONFIG['arch'] = arch + Gem::ConfigMap[:arch] = arch platform = Gem::Platform.new arch Gem.instance_variable_set :@platforms, nil diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index fa838333cd4543..4cb2a1d33334ba 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -237,7 +237,7 @@ def remove(spec) unless path_ok?(@gem_home, spec) or (@user_install and path_ok?(Gem.user_dir, spec)) then e = Gem::GemNotInHomeException.new \ - "Gem '#{spec.full_name}' is not installed in directory #{@gem_home}" + "Gem is not installed in directory #{@gem_home}" e.spec = spec raise e diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 513f2d4e58e835..759c2fe9070759 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -199,30 +199,30 @@ def test_self_datadir_nonexistent_package end def test_self_default_exec_format - orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] - RbConfig::CONFIG['ruby_install_name'] = 'ruby' + orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] + Gem::ConfigMap[:ruby_install_name] = 'ruby' assert_equal '%s', Gem.default_exec_format ensure - RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME end def test_self_default_exec_format_18 - orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] - RbConfig::CONFIG['ruby_install_name'] = 'ruby18' + orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] + Gem::ConfigMap[:ruby_install_name] = 'ruby18' assert_equal '%s18', Gem.default_exec_format ensure - RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME end def test_self_default_exec_format_jruby - orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] - RbConfig::CONFIG['ruby_install_name'] = 'jruby' + orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] + Gem::ConfigMap[:ruby_install_name] = 'jruby' assert_equal 'j%s', Gem.default_exec_format ensure - RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME end def test_self_default_sources @@ -230,7 +230,6 @@ def test_self_default_sources end def test_self_detect_gemdeps - skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' FileUtils.mkdir_p 'detect/a/b' @@ -566,43 +565,24 @@ def test_self_prefix end def test_self_prefix_libdir - orig_libdir = RbConfig::CONFIG['libdir'] - RbConfig::CONFIG['libdir'] = @@project_dir + orig_libdir = Gem::ConfigMap[:libdir] + Gem::ConfigMap[:libdir] = @@project_dir assert_nil Gem.prefix ensure - RbConfig::CONFIG['libdir'] = orig_libdir + Gem::ConfigMap[:libdir] = orig_libdir end def test_self_prefix_sitelibdir - orig_sitelibdir = RbConfig::CONFIG['sitelibdir'] - RbConfig::CONFIG['sitelibdir'] = @@project_dir + orig_sitelibdir = Gem::ConfigMap[:sitelibdir] + Gem::ConfigMap[:sitelibdir] = @@project_dir assert_nil Gem.prefix ensure - RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir - end - - def test_self_read_binary - open 'test', 'w' do |io| - io.write "\xCF\x80" - end - - assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a - - skip 'chmod not supported' if Gem.win_platform? - - begin - File.chmod 0444, 'test' - - assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a - ensure - File.chmod 0644, 'test' - end + Gem::ConfigMap[:sitelibdir] = orig_sitelibdir end def test_self_refresh - skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -622,7 +602,6 @@ def test_self_refresh end def test_self_refresh_keeps_loaded_specs_activated - skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -645,44 +624,46 @@ def test_self_refresh_keeps_loaded_specs_activated def test_self_ruby_escaping_spaces_in_path orig_ruby = Gem.ruby - orig_bindir = RbConfig::CONFIG['bindir'] - orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] - orig_exe_ext = RbConfig::CONFIG['EXEEXT'] + orig_bindir = Gem::ConfigMap[:bindir] + orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] + orig_exe_ext = Gem::ConfigMap[:EXEEXT] - RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" - RbConfig::CONFIG['ruby_install_name'] = "ruby" - RbConfig::CONFIG['EXEEXT'] = ".exe" + Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin" + Gem::ConfigMap[:ruby_install_name] = "ruby" + Gem::ConfigMap[:EXEEXT] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name - RbConfig::CONFIG['EXEEXT'] = orig_exe_ext + Gem::ConfigMap[:bindir] = orig_bindir + Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name + Gem::ConfigMap[:EXEEXT] = orig_exe_ext end def test_self_ruby_path_without_spaces orig_ruby = Gem.ruby - orig_bindir = RbConfig::CONFIG['bindir'] - orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] - orig_exe_ext = RbConfig::CONFIG['EXEEXT'] + orig_bindir = Gem::ConfigMap[:bindir] + orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] + orig_exe_ext = Gem::ConfigMap[:EXEEXT] - RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" - RbConfig::CONFIG['ruby_install_name'] = "ruby" - RbConfig::CONFIG['EXEEXT'] = ".exe" + Gem::ConfigMap[:bindir] = "C:/Ruby18/bin" + Gem::ConfigMap[:ruby_install_name] = "ruby" + Gem::ConfigMap[:EXEEXT] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name - RbConfig::CONFIG['EXEEXT'] = orig_exe_ext + Gem::ConfigMap[:bindir] = orig_bindir + Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name + Gem::ConfigMap[:EXEEXT] = orig_exe_ext end def test_self_ruby_api_version - orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3' + orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1' + orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2' + orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3' Gem.instance_variable_set :@ruby_api_version, nil @@ -690,7 +671,9 @@ def test_self_ruby_api_version ensure Gem.instance_variable_set :@ruby_api_version, nil - RbConfig::CONFIG['ruby_version'] = orig_ruby_version + Gem::ConfigMap[:MAJOR] = orig_MAJOR + Gem::ConfigMap[:MINOR] = orig_MINOR + Gem::ConfigMap[:TEENY] = orig_TEENY end def test_self_ruby_version_1_8_5 @@ -842,7 +825,7 @@ def test_self_use_paths def test_self_user_dir parts = [@userhome, '.gem', Gem.ruby_engine] - parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty? assert_equal File.join(parts), Gem.user_dir end @@ -874,7 +857,6 @@ def test_self_needs end def test_self_needs_picks_up_unresolved_deps - skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7" save_loaded_features do util_clear_gems a = util_spec "a", "1" @@ -967,7 +949,6 @@ def test_self_user_home_user_drive_and_path end def test_load_plugins - skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" plugin_path = File.join "lib", "rubygems_plugin.rb" Dir.chdir @tempdir do @@ -1121,7 +1102,6 @@ def test_auto_activation_of_specific_gemdeps_file end def test_auto_activation_of_detected_gemdeps_file - skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" util_clear_gems a = new_spec "a", "1", nil, "lib/a.rb" @@ -1284,7 +1264,6 @@ def test_use_gemdeps end def test_use_gemdeps_automatic - skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' spec = util_spec 'a', 1 @@ -1321,7 +1300,6 @@ def test_use_gemdeps_disabled end def test_use_gemdeps_specific - skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x' spec = util_spec 'a', 1 diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb index 7f5cf22223cff5..d87e84fc829fc0 100644 --- a/test/rubygems/test_gem_commands_contents_command.rb +++ b/test/rubygems/test_gem_commands_contents_command.rb @@ -169,9 +169,9 @@ def test_execute_default_gem end expected = [ - File.join(RbConfig::CONFIG['bindir'], 'default_command'), - File.join(RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'), - File.join(RbConfig::CONFIG['archdir'], 'default_gem.so') + File.join(Gem::ConfigMap[:bindir], 'default_command'), + File.join(Gem::ConfigMap[:rubylibdir], 'default/gem.rb'), + File.join(Gem::ConfigMap[:archdir], 'default_gem.so') ].sort.join "\n" assert_equal expected, @ui.output.chomp diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb index bb7589f50de1c3..253c459d942840 100644 --- a/test/rubygems/test_gem_commands_environment_command.rb +++ b/test/rubygems/test_gem_commands_environment_command.rb @@ -26,7 +26,7 @@ def test_execute assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|, @ui.output assert_match %r|RUBYGEMS PREFIX: |, @ui.output - assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|, + assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:ruby_install_name]}|, @ui.output assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 6315cb5d95b5ed..00bbf7bae7eca2 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -316,7 +316,6 @@ def test_execute_prerelease_skipped_when_non_pre_available end def test_execute_rdoc - skip if RUBY_VERSION <= "1.8.7" specs = spec_fetcher do |fetcher| fetcher.gem 'a', 2 end @@ -560,20 +559,6 @@ def test_install_gem_ignore_dependencies_remote assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name } end - def test_install_gem_ignore_dependencies_specific_file - spec = quick_spec 'a', 2 - - util_build_gem spec - - FileUtils.mv spec.cache_file, @tempdir - - @cmd.options[:ignore_dependencies] = true - - @cmd.install_gem File.join(@tempdir, spec.file_name), nil - - assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name } - end - def test_parses_requirement_from_gemname spec_fetcher do |fetcher| fetcher.gem 'a', 2 diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index d259383ba2fbb2..7537c1c9c10532 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -217,7 +217,6 @@ def test_execute_dependencies end def test_execute_rdoc - skip if RUBY_VERSION <= "1.8.7" spec_fetcher do |fetcher| fetcher.gem 'a', 2 @@ -240,6 +239,7 @@ def test_execute_rdoc a2 = @specs['a-2'] + assert_path_exists File.join(a2.doc_dir, 'ri') assert_path_exists File.join(a2.doc_dir, 'rdoc') end diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index 352ebbb54ff513..0a82fa63cbbd19 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -551,7 +551,7 @@ def test_install_env_shebang env = "/\\S+/env" unless Gem.win_platform? - assert_match %r|\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n|, + assert_match %r|\A#!#{env} #{Gem::ConfigMap[:ruby_install_name]}\n|, File.read(File.join(@gemhome, 'bin', 'a_bin')) end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 54ac853135b9cf..615a9b57ba4afa 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -84,8 +84,8 @@ def test_check_executable_overwrite_default_bin_dir orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION Object.send :remove_const, :RUBY_FRAMEWORK_VERSION end - orig_bindir = RbConfig::CONFIG['bindir'] - RbConfig::CONFIG['bindir'] = Gem.bindir + orig_bindir = Gem::ConfigMap[:bindir] + Gem::ConfigMap[:bindir] = Gem.bindir util_conflict_executable false @@ -102,7 +102,7 @@ def test_check_executable_overwrite_default_bin_dir ensure Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if orig_RUBY_FRAMEWORK_VERSION - RbConfig::CONFIG['bindir'] = orig_bindir + Gem::ConfigMap[:bindir] = orig_bindir end def test_check_executable_overwrite_format_executable @@ -1192,7 +1192,7 @@ def test_shebang_env_shebang env_shebang = "/usr/bin/env" unless Gem.win_platform? - assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}", + assert_equal("#!#{env_shebang} #{Gem::ConfigMap[:ruby_install_name]}", shebang) end diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb index 0be69bf92b30d4..9e0cab4d1a8f79 100644 --- a/test/rubygems/test_gem_request_set_lockfile.rb +++ b/test/rubygems/test_gem_request_set_lockfile.rb @@ -218,7 +218,6 @@ def test_parse_gem_specs_dependency c (~> 4) d e (~> 5.0, >= 5.0.1) - b (3-x86_64-linux) PLATFORMS #{Gem::Platform::RUBY} @@ -239,14 +238,7 @@ def test_parse_gem_specs_dependency assert lockfile_set, 'could not find a LockSet' - assert_equal %w[a-2 b-3], lockfile_set.specs.map { |tuple| tuple.full_name } - - expected = [ - Gem::Platform::RUBY, - Gem::Platform.new('x86_64-linux'), - ] - - assert_equal expected, lockfile_set.specs.map { |tuple| tuple.platform } + assert_equal %w[a-2], lockfile_set.specs.map { |tuple| tuple.full_name } spec = lockfile_set.specs.first diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index b72a5d1baf01cd..7aa9d5aeb17a4a 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -999,8 +999,8 @@ def test_initialize_copy assert_equal 'summary', spec.summary assert_same spec.summary, new_spec.summary - assert_equal %w[README.txt bin/exec ext/extconf.rb lib/file.rb - test/file.rb].sort, + assert_equal %w[lib/file.rb test/file.rb bin/exec README.txt + ext/extconf.rb].sort, spec.files refute_same spec.files, new_spec.files, 'files' @@ -1109,31 +1109,7 @@ def test_bindir_equals_nil @a2.executable = 'app' assert_equal nil, @a2.bindir - assert_equal %w[app lib/code.rb].sort, @a2.files - end - - def test_extensions_equals_nil - @a2.instance_variable_set(:@extensions, nil) - assert_equal nil, @a2.instance_variable_get(:@extensions) - assert_equal %w[lib/code.rb], @a2.files - end - - def test_test_files_equals_nil - @a2.instance_variable_set(:@test_files, nil) - assert_equal nil, @a2.instance_variable_get(:@test_files) - assert_equal %w[lib/code.rb], @a2.files - end - - def test_executables_equals_nil - @a2.instance_variable_set(:@executables, nil) - assert_equal nil, @a2.instance_variable_get(:@executables) - assert_equal %w[lib/code.rb], @a2.files - end - - def test_extra_rdoc_files_equals_nil - @a2.instance_variable_set(:@extra_rdoc_files, nil) - assert_equal nil, @a2.instance_variable_get(:@extra_rdoc_files) - assert_equal %w[lib/code.rb], @a2.files + assert_equal %w[lib/code.rb app].sort, @a2.files end def test_build_extensions @@ -1461,7 +1437,7 @@ def test_executables def test_executable_equals @a2.executable = 'app' assert_equal 'app', @a2.executable - assert_equal %w[bin/app lib/code.rb].sort, @a2.files + assert_equal %w[lib/code.rb bin/app].sort, @a2.files end def test_extensions @@ -1809,22 +1785,6 @@ def test_source assert_kind_of Gem::Source::Installed, @a1.source end - def test_source_paths - ext_spec - - @ext.require_paths = %w[lib ext foo] - @ext.extensions << 'bar/baz' - - expected = %w[ - lib - ext - foo - bar - ] - - assert_equal expected, @ext.source_paths - end - def test_full_require_paths ext_spec @@ -2475,7 +2435,7 @@ def test_validate_files assert_equal '["lib2"] are not files', e.message end - assert_equal %w[bin/exec ext/a/extconf.rb lib/code.rb lib2 test/suite.rb].sort, + assert_equal %w[lib/code.rb test/suite.rb bin/exec ext/a/extconf.rb lib2].sort, @a1.files end diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 11fdaf68e22118..1eea30fb9403d6 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -131,23 +131,6 @@ def test_remove_executables_user_format_disabled Gem::Installer.exec_format = nil end - def test_remove_not_in_home - uninstaller = Gem::Uninstaller.new nil, :install_dir => "#{@gemhome}2" - - e = assert_raises Gem::GemNotInHomeException do - use_ui ui do - uninstaller.remove @spec - end - end - - expected = - "Gem '#{@spec.full_name}' is not installed in directory #{@gemhome}2" - - assert_equal expected, e.message - - assert_path_exists @spec.gem_dir - end - def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil diff --git a/version.h b/version.h index 8553f79047718a..c361122024b2b0 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-01-31" -#define RUBY_PATCHLEVEL 14 +#define RUBY_PATCHLEVEL 13 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 1 From 5d6066e0353d2d2fef71cb592a2ade41a8d32249 Mon Sep 17 00:00:00 2001 From: svn Date: Sat, 1 Feb 2014 08:19:15 +0000 Subject: [PATCH 15/83] * 2014-02-01 git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.h b/version.h index c361122024b2b0..1e17ddec77a182 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-01-31" +#define RUBY_RELEASE_DATE "2014-02-01" #define RUBY_PATCHLEVEL 13 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 31 +#define RUBY_RELEASE_MONTH 2 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" From 21942cdedf15bad4adfa782a39c5a30c8ef2e861 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 1 Feb 2014 08:35:30 +0000 Subject: [PATCH 16/83] merge revision(s) 44373: [Backport #9417] test_alias.rb: rename duplicate name * test/ruby/test_alias.rb (test_alias_wb_miss): rename duplicate name to get rid of redefinition. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_alias.rb | 2 +- version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb index cef39d690f6429..956fdb41f05b0d 100644 --- a/test/ruby/test_alias.rb +++ b/test/ruby/test_alias.rb @@ -121,7 +121,7 @@ def test_super_in_aliased_module_method # fails in 1.8 assert_equal([:Base, :M], SuperInAliasedModuleMethod::Derived.new.bar) end - def test_alias + def test_alias_wb_miss assert_normal_exit %q{ require 'stringio' GC.verify_internal_consistency diff --git a/version.h b/version.h index 1e17ddec77a182..1bc3dec1f1a5ba 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-01" -#define RUBY_PATCHLEVEL 13 +#define RUBY_PATCHLEVEL 14 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 7933cae0ba58a4d4adf3ddb29ce94a2142c26455 Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 2 Feb 2014 13:46:46 +0000 Subject: [PATCH 17/83] merge revision(s) 44630,44631: [Backport #9403] * lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [ruby-core:58572] [Bug #9155] which start and end with '__'. [ruby-core:59718] [Bug #9403] git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++++ lib/delegate.rb | 2 +- test/test_delegate.rb | 57 +++++++++++++++++++++++++++++++++++++++++++ version.h | 6 ++--- 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 601436f3261c95..65ab2491f772e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Feb 2 22:39:28 2014 Nobuyoshi Nakada + + * lib/delegate.rb (Delegator): keep source information methods + which start and end with '__'. [ruby-core:59718] [Bug #9403] + Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada * proc.c (mnew_from_me): keep iclass as-is, to make inheritance diff --git a/lib/delegate.rb b/lib/delegate.rb index c33f7e40df766c..d7902292f03355 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -48,7 +48,7 @@ class Delegator < BasicObject undef_method m end private_instance_methods.each do |m| - if /\Ablock_given\?\z|iterator\?\z|\A__raise__\z/ =~ m + if /\Ablock_given\?\z|iterator\?\z|\A__.*__\z/ =~ m next end undef_method m diff --git a/test/test_delegate.rb b/test/test_delegate.rb index ca65ef3daadb52..6270cc61b6e45d 100644 --- a/test/test_delegate.rb +++ b/test/test_delegate.rb @@ -180,4 +180,61 @@ def test_global_method_if_no_target x = assert_nothing_raised(ArgumentError, bug9155) {break Bug9155.new(1)} assert_equal(1, x.to_i, bug9155) end + + class Bug9403 + Name = '[ruby-core:59718] [Bug #9403]' + SD = SimpleDelegator.new(new) + class << SD + def method_name + __method__ + end + def callee_name + __callee__ + end + alias aliased_name callee_name + def dir_name + __dir__ + end + end + dc = DelegateClass(self) + dc.class_eval do + def method_name + __method__ + end + def callee_name + __callee__ + end + alias aliased_name callee_name + def dir_name + __dir__ + end + end + DC = dc.new(new) + end + + def test_method_in_simple_delegator + assert_equal(:method_name, Bug9403::SD.method_name, Bug9403::Name) + end + + def test_callee_in_simple_delegator + assert_equal(:callee_name, Bug9403::SD.callee_name, Bug9403::Name) + assert_equal(:aliased_name, Bug9403::SD.aliased_name, Bug9403::Name) + end + + def test_dir_in_simple_delegator + assert_equal(__dir__, Bug9403::SD.dir_name, Bug9403::Name) + end + + def test_method_in_delegator_class + assert_equal(:method_name, Bug9403::DC.method_name, Bug9403::Name) + end + + def test_callee_in_delegator_class + assert_equal(:callee_name, Bug9403::DC.callee_name, Bug9403::Name) + assert_equal(:aliased_name, Bug9403::DC.aliased_name, Bug9403::Name) + end + + def test_dir_in_delegator_class + assert_equal(__dir__, Bug9403::DC.dir_name, Bug9403::Name) + end end diff --git a/version.h b/version.h index 1bc3dec1f1a5ba..a62e4f128d9a87 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-01" -#define RUBY_PATCHLEVEL 14 +#define RUBY_RELEASE_DATE "2014-02-02" +#define RUBY_PATCHLEVEL 15 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 1 +#define RUBY_RELEASE_DAY 2 #include "ruby/version.h" From 3e5f9b16d034e3501b47ce19297e8458345080e8 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 02:35:13 +0000 Subject: [PATCH 18/83] merge revision(s) 44803: [Backport #9478] * string.c (rb_str_modify_expand): enable capacity and disable assocation with packed objects when setting capa, so that pack("p") string fails to unpack properly after modified. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ string.c | 1 + test/ruby/test_pack.rb | 1 + version.h | 6 +++--- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65ab2491f772e6..465620e557e9fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 5 11:13:21 2014 Nobuyoshi Nakada + + * string.c (rb_str_modify_expand): enable capacity and disable + assocation with packed objects when setting capa, so that + pack("p") string fails to unpack properly after modified. + Sun Feb 2 22:39:28 2014 Nobuyoshi Nakada * lib/delegate.rb (Delegator): keep source information methods diff --git a/string.c b/string.c index 900f900f160dff..cc307866dbfb68 100644 --- a/string.c +++ b/string.c @@ -1465,6 +1465,7 @@ rb_str_modify_expand(VALUE str, long expand) int termlen = TERM_LEN(str); if (!STR_EMBED_P(str)) { REALLOC_N(RSTRING(str)->as.heap.ptr, char, capa + termlen); + STR_UNSET_NOCAPA(str); RSTRING(str)->as.heap.aux.capa = capa; } else if (capa + termlen > RSTRING_EMBED_LEN_MAX + 1) { diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 621a06beba5b25..3f0931bdc0cfb2 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -181,6 +181,7 @@ def test_pack_p assert_equal a[0], a.pack("p").unpack("p")[0] assert_equal a, a.pack("p").freeze.unpack("p*") assert_raise(ArgumentError) { (a.pack("p") + "").unpack("p*") } + assert_raise(ArgumentError) { (a.pack("p") << "d").unpack("p*") } end def test_format_string_modified diff --git a/version.h b/version.h index a62e4f128d9a87..98bc2a3642a193 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-02" -#define RUBY_PATCHLEVEL 15 +#define RUBY_RELEASE_DATE "2014-02-05" +#define RUBY_PATCHLEVEL 16 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 5 #include "ruby/version.h" From 9b614cb0e947904b8d1543440f34f9c5ca315e00 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 04:05:53 +0000 Subject: [PATCH 19/83] merge revision(s) 44501: [Backport #9353] * struct.c (rb_struct_set): return assigned value from setter method rather than struct object. [Bug #9353] [ruby-core:59509] * test/ruby/test_struct.rb (test_setter_method_returns_value): add test git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ struct.c | 3 ++- test/ruby/test_struct.rb | 6 ++++++ version.h | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 465620e557e9fc..d8aae5a0433d4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Feb 5 11:48:42 2014 Charlie Somerville + + * struct.c (rb_struct_set): return assigned value from setter method + rather than struct object. [Bug #9353] [ruby-core:59509] + + * test/ruby/test_struct.rb (test_setter_method_returns_value): add test + Wed Feb 5 11:13:21 2014 Nobuyoshi Nakada * string.c (rb_str_modify_expand): enable capacity and disable diff --git a/struct.c b/struct.c index 6be512eaee8132..2e026fbc7fdef5 100644 --- a/struct.c +++ b/struct.c @@ -156,7 +156,8 @@ rb_struct_set(VALUE obj, VALUE val) for (i=0; i Date: Wed, 5 Feb 2014 11:29:40 +0000 Subject: [PATCH 20/83] merge revision(s) 44512: [Backport #9340] * array.c (ary_add_hash): Fix consistency issue between Array#uniq and Array#uniq! [Bug #9340] [ruby-core:59457] * test/ruby/test_array.rb (class TestArray): regression test for above. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ array.c | 4 +++- test/ruby/test_array.rb | 5 +++++ version.h | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8aae5a0433d4b..01018edd175a1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 5 17:55:28 2014 Aman Gupta + + * array.c (ary_add_hash): Fix consistency issue between Array#uniq and + Array#uniq! [Bug #9340] [ruby-core:59457] + * test/ruby/test_array.rb (class TestArray): regression test for above. + Wed Feb 5 11:48:42 2014 Charlie Somerville * struct.c (rb_struct_set): return assigned value from setter method diff --git a/array.c b/array.c index 45713c55b03198..ff77a3ed949842 100644 --- a/array.c +++ b/array.c @@ -3904,7 +3904,9 @@ ary_add_hash(VALUE hash, VALUE ary) for (i=0; i Date: Wed, 5 Feb 2014 12:43:19 +0000 Subject: [PATCH 21/83] merge revision(s) 44517,44518,44519,44523: [Backport #9354] * lib/timeout.rb (Timeout#timeout): when a custom exception is given, no instance is needed to be caught, so defer creating new instance until it is raised. [ruby-core:59511] [Bug #9354] * lib/timeout.rb (Timeout#timeout): should not rescue ordinarily raised ExitException, which should not be thrown. * lib/timeout.rb (Timeout::ExitException.catch): set @thread only if it ought to be caught. * lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance. * lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [ruby-dev:47872] [Bug #9380] * lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 23 +++++++++++++++++++++++ lib/timeout.rb | 34 +++++++++++++++++++++++++--------- test/test_timeout.rb | 29 +++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 78 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01018edd175a1e..c585352f63dce0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada + + * lib/timeout.rb (Timeout::ExitException.catch): pass arguments + for new instance. + + * lib/timeout.rb (Timeout::ExitException#exception): fallback to + Timeout::Error if couldn't throw. [ruby-dev:47872] [Bug #9380] + + * lib/timeout.rb (Timeout#timeout): initialize ExitException with + message for the fallback case. + +Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada + + * lib/timeout.rb (Timeout#timeout): should not rescue ordinarily + raised ExitException, which should not be thrown. + + * lib/timeout.rb (Timeout::ExitException.catch): set @thread only if + it ought to be caught. + + * lib/timeout.rb (Timeout#timeout): when a custom exception is given, + no instance is needed to be caught, so defer creating new instance + until it is raised. [ruby-core:59511] [Bug #9354] + Wed Feb 5 17:55:28 2014 Aman Gupta * array.c (ary_add_hash): Fix consistency issue between Array#uniq and diff --git a/lib/timeout.rb b/lib/timeout.rb index ad951d2ffa406e..d805dce2a3fdad 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -26,16 +26,25 @@ module Timeout class Error < RuntimeError end class ExitException < ::Exception # :nodoc: - attr_reader :klass, :thread + attr_reader :thread - def initialize(*) - super - @thread = Thread.current - freeze + def self.catch(*args) + exc = new(*args) + exc.instance_variable_set(:@thread, Thread.current) + exc.freeze + ::Kernel.catch(exc) {yield exc} end def exception(*) - throw(self, caller) if self.thread == Thread.current + if self.thread == Thread.current + bt = caller + begin + throw(self, bt) + rescue ArgumentError => e + raise unless e.message.start_with?("uncaught throw") + raise Error, message, backtrace + end + end self end end @@ -67,7 +76,7 @@ def timeout(sec, klass = nil) #:yield: +sec+ return yield(sec) if sec == nil or sec.zero? message = "execution expired" e = Error - bt = catch((klass||ExitException).new) do |exception| + bl = proc do |exception| begin x = Thread.current y = Thread.start { @@ -80,8 +89,6 @@ def timeout(sec, klass = nil) #:yield: +sec+ end } return yield(sec) - rescue (klass||ExitException) => e - e.backtrace ensure if y y.kill @@ -89,6 +96,15 @@ def timeout(sec, klass = nil) #:yield: +sec+ end end end + if klass + begin + bl.call(klass) + rescue klass => e + bt = e.backtrace + end + else + bt = ExitException.catch(message, &bl) + end rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o bt.reject! {|m| rej =~ m} level = -caller(CALLER_OFFSET).size diff --git a/test/test_timeout.rb b/test/test_timeout.rb index 9d51ca5be3b625..e849cc5741282f 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -57,4 +57,33 @@ def test_rescue_exit end assert_raise_with_message(exc, /execution expired/) {raise e if e} end + + def test_custom_exception + bug9354 = '[ruby-core:59511] [Bug #9354]' + err = Class.new(StandardError) do + def initialize(msg) super end + end + assert_nothing_raised(ArgumentError, bug9354) do + assert_equal(:ok, timeout(100, err) {:ok}) + end + end + + def test_exit_exception + assert_raise_with_message(Timeout::ExitException, "boon") do + Timeout.timeout(10, Timeout::ExitException) do + raise Timeout::ExitException, "boon" + end + end + end + + def test_enumerator_next + bug9380 = '[ruby-dev:47872] [Bug #9380]: timeout in Enumerator#next' + e = (o=Object.new).to_enum + def o.each + sleep + end + assert_raise_with_message(Timeout::Error, 'execution expired', bug9380) do + Timeout.timeout(0.01) {e.next} + end + end end diff --git a/version.h b/version.h index 7e623c538d6eb4..3511d6415dcbc3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 18 +#define RUBY_PATCHLEVEL 19 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 61faac8ed4e574dbfbaa062abe97b9fc56982d17 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 13:08:32 +0000 Subject: [PATCH 22/83] merge revision(s) 44490,44496: [Backport #9352] * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno before calling rb_sys_fail_str to prevent [BUG] errno == 0. Patch by Eric Wong. [ruby-core:59498] [Bug #9352] * ext/socket/socket.c (rsock_sys_fail_path): ditto * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto * ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno argument version anduse rb_syserr_fail_str() instead of rb_sys_fail_str() with restoring errno. * ext/socket/socket.c (rsock_syserr_fail_path): ditto, and rb_syserr_fail(). * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto, use rsock_syserr_fail_raddrinfo(). * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto. * ext/socket/socket.c (setup_domain_and_type): ditto. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 27 ++++++++++++++++++++++++ ext/socket/rubysocket.h | 6 ++++++ ext/socket/socket.c | 46 ++++++++++++++++++++++++++++++++++------- version.h | 2 +- 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index c585352f63dce0..a208fa97384b84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +Wed Feb 5 21:57:40 2014 Nobuyoshi Nakada + + * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno + argument version anduse rb_syserr_fail_str() instead of + rb_sys_fail_str() with restoring errno. + + * ext/socket/socket.c (rsock_syserr_fail_path): ditto, and + rb_syserr_fail(). + + * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto, use + rsock_syserr_fail_raddrinfo(). + + * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto. + + * ext/socket/socket.c (setup_domain_and_type): ditto. + +Wed Feb 5 21:57:40 2014 Eric Wong + + * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno + before calling rb_sys_fail_str to prevent [BUG] errno == 0. + Patch by Eric Wong. [ruby-core:59498] [Bug #9352] + + * ext/socket/socket.c (rsock_sys_fail_path): ditto + * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto + * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto + * ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto + Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada * lib/timeout.rb (Timeout::ExitException.catch): pass arguments diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index 97c02fc4101b89..c74fb326ec16c4 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -374,6 +374,12 @@ void rsock_init_sockopt(void); void rsock_init_sockifaddr(void); void rsock_init_socket_init(void); +NORETURN(void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE)); +NORETURN(void rsock_syserr_fail_path(int err, const char *, VALUE)); +NORETURN(void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len)); +NORETURN(void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai)); +NORETURN(void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai)); + NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE)); NORETURN(void rsock_sys_fail_path(const char *, VALUE)); NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len)); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 5fd74652c629e0..c7fc5b76cbf348 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -14,6 +14,12 @@ static VALUE sock_s_unpack_sockaddr_in(VALUE, VALUE); void rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port) +{ + rsock_syserr_fail_host_port(errno, mesg, host, port); +} + +void +rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port) { VALUE message; @@ -22,13 +28,20 @@ rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port) message = rb_sprintf("%s for \"%s\" port %s", mesg, StringValueCStr(host), StringValueCStr(port)); - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } void rsock_sys_fail_path(const char *mesg, VALUE path) +{ + rsock_syserr_fail_path(errno, mesg, path); +} + +void +rsock_syserr_fail_path(int err, const char *mesg, VALUE path) { VALUE message; + if (RB_TYPE_P(path, T_STRING)) { if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) { path = rb_str_inspect(path); @@ -39,45 +52,64 @@ rsock_sys_fail_path(const char *mesg, VALUE path) message = rb_sprintf("%s for \"%s\"", mesg, StringValueCStr(path)); } - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } else { - rb_sys_fail(mesg); + rb_syserr_fail(err, mesg); } } void rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len) +{ + rsock_syserr_fail_sockaddr(errno, mesg, addr, len); +} + +void +rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len) { VALUE rai; rai = rsock_addrinfo_new(addr, len, PF_UNSPEC, 0, 0, Qnil, Qnil); - rsock_sys_fail_raddrinfo(mesg, rai); + rsock_syserr_fail_raddrinfo(err, mesg, rai); } void rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai) +{ + rsock_syserr_fail_raddrinfo(errno, mesg, rai); +} + +void +rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai) { VALUE str, message; str = rsock_addrinfo_inspect_sockaddr(rai); message = rb_sprintf("%s for %s", mesg, StringValueCStr(str)); - rb_sys_fail_str(message); + rb_syserr_fail_str(err, message); } void rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai) +{ + rsock_syserr_fail_raddrinfo_or_sockaddr(errno, mesg, addr, rai); +} + +void +rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai) { if (NIL_P(rai)) { StringValue(addr); - rsock_sys_fail_sockaddr(mesg, + + rsock_syserr_fail_sockaddr(err, mesg, (struct sockaddr *)RSTRING_PTR(addr), (socklen_t)RSTRING_LEN(addr)); /* overflow should be checked already */ } else - rsock_sys_fail_raddrinfo(mesg, rai); + rsock_syserr_fail_raddrinfo(err, mesg, rai); } static void diff --git a/version.h b/version.h index 3511d6415dcbc3..97d3d9c0745d60 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 19 +#define RUBY_PATCHLEVEL 20 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From b208f1ecd0eaacf554bf8681554a1e70c1377040 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 13:41:03 +0000 Subject: [PATCH 23/83] merge revision(s) 44527,44552,44553: * vm_insnhelper.c (vm_search_super_method): when super called in a bound UnboundMethod generated from a module, no superclass is found since the current defined class is the module, then call method_missing in that case. [ruby-core:59619] [Bug #9377] * vm_insnhelper.c (vm_search_super_method): allow bound method from a module, yet another method transplanting. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ test/ruby/test_super.rb | 13 +++++++++++++ version.h | 2 +- vm_insnhelper.c | 9 ++++++++- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a208fa97384b84..922bdcafdd79f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_search_super_method): allow bound method from a + module, yet another method transplanting. + +Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_search_super_method): when super called in a + bound UnboundMethod generated from a module, no superclass is + found since the current defined class is the module, then call + method_missing in that case. [ruby-core:59619] [Bug #9377] + Wed Feb 5 21:57:40 2014 Nobuyoshi Nakada * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index c5f724ebb8c900..82d6e19ec4ba1c 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -440,4 +440,17 @@ def foo assert_equal(:ok, o.method(:foo).call, bug9315) end end + + def test_missing_super_in_module_unbound_method + bug9377 = '[ruby-core:59619] [Bug #9377]' + + a = Module.new do + def foo; super end + end + + m = a.instance_method(:foo).bind(Object.new) + assert_raise(NoMethodError, bug9377) do + m.call + end + end end diff --git a/version.h b/version.h index 97d3d9c0745d60..0e69916f3cd37b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 20 +#define RUBY_PATCHLEVEL 21 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index c8cbaa07bf4a18..edf4e46652dc37 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2004,7 +2004,8 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf current_defined_class = RCLASS_REFINED_CLASS(current_defined_class); } - if (!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) && + if (BUILTIN_TYPE(current_defined_class) != T_MODULE && + !FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) && !rb_obj_is_kind_of(ci->recv, current_defined_class)) { VALUE m = RB_TYPE_P(current_defined_class, T_ICLASS) ? RBASIC(current_defined_class)->klass : current_defined_class; @@ -2024,6 +2025,12 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf " by define_method() is not supported." " Specify all arguments explicitly."); } + if (!ci->klass) { + /* bound instance method of module */ + ci->aux.missing_reason = NOEX_SUPER; + CI_SET_FASTPATH(ci, vm_call_method_missing, 1); + return; + } /* TODO: use inline cache */ ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class); From 7d53e2be61a800061d7143e6b0735db7bafa01d9 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 14:53:48 +0000 Subject: [PATCH 24/83] merge revision(s) 44525,44534,44537: [Backport #9381] * hash.c (rb_objid_hash): return hash value from object ID with a salt, extract from rb_any_hash(). * object.c (rb_obj_hash): return same value as rb_any_hash(). fix r44125. [ruby-core:59638] [Bug #9381] * hash.c (rb_any_hash): should treat the return value of rb_objid_hash() as `long', because ruby assumes the object id of an object is `long'. this fixes test failures on mswin64 introduced at r44525. * hash.c (rb_objid_hash): should return `long'. brushup r44534. * object.c (rb_obj_hash): follow above change. as `long', because ruby assumes the hash value of the object id of an object is `long'. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 21 +++++++++++++++++++++ hash.c | 15 ++++++++++++--- object.c | 4 ++-- test/ruby/test_hash.rb | 21 +++++++++++++++++++++ version.h | 2 +- 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 922bdcafdd79f8..d8a73d3aec6257 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +Wed Feb 5 23:43:30 2014 NAKAMURA Usaku + + * hash.c (rb_objid_hash): should return `long'. brushup r44534. + + * object.c (rb_obj_hash): follow above change. + +Wed Feb 5 23:43:30 2014 NAKAMURA Usaku + + * hash.c (rb_any_hash): should treat the return value of rb_objid_hash() + as `long', because ruby assumes the hash value of the object id of + an object is `long'. + this fixes test failures on mswin64 introduced at r44525. + +Wed Feb 5 23:43:30 2014 Nobuyoshi Nakada + + * hash.c (rb_objid_hash): return hash value from object ID with a + salt, extract from rb_any_hash(). + + * object.c (rb_obj_hash): return same value as rb_any_hash(). + fix r44125. [ruby-core:59638] [Bug #9381] + Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada * vm_insnhelper.c (vm_search_super_method): allow bound method from a diff --git a/hash.c b/hash.c index 0cbc46baf5f039..1c285c2b232df2 100644 --- a/hash.c +++ b/hash.c @@ -123,6 +123,8 @@ rb_hash(VALUE obj) return hval; } +long rb_objid_hash(st_index_t index); + static st_index_t rb_any_hash(VALUE a) { @@ -131,9 +133,7 @@ rb_any_hash(VALUE a) if (SPECIAL_CONST_P(a)) { if (a == Qundef) return 0; - hnum = rb_hash_start((st_index_t)a); - hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash); - hnum = rb_hash_end(hnum); + hnum = rb_objid_hash((st_index_t)a); } else if (BUILTIN_TYPE(a) == T_STRING) { hnum = rb_str_hash(a); @@ -146,6 +146,15 @@ rb_any_hash(VALUE a) return (st_index_t)RSHIFT(hnum, 1); } +long +rb_objid_hash(st_index_t index) +{ + st_index_t hnum = rb_hash_start(index); + hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash); + hnum = rb_hash_end(hnum); + return hnum; +} + static const struct st_hash_type objhash = { rb_any_cmp, rb_any_hash, diff --git a/object.c b/object.c index 466ec754929987..bb43b4617e5cd1 100644 --- a/object.c +++ b/object.c @@ -161,6 +161,7 @@ rb_obj_equal(VALUE obj1, VALUE obj2) VALUE rb_obj_hash(VALUE obj) { + long rb_objid_hash(st_index_t index); VALUE oid = rb_obj_id(obj); #if SIZEOF_LONG == SIZEOF_VOIDP st_index_t index = NUM2LONG(oid); @@ -169,8 +170,7 @@ rb_obj_hash(VALUE obj) #else # error not supported #endif - st_index_t h = rb_hash_end(rb_hash_start(index)); - return LONG2FIX(h); + return LONG2FIX(rb_objid_hash(index)); } /* diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 910da9374a1106..c872b11a3c6c97 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1228,6 +1228,27 @@ def hash assert_no_memory_leak([], prepare, code, bug9187) end + def test_wrapper_of_special_const + bug9381 = '[ruby-core:59638] [Bug #9381]' + + wrapper = Class.new do + def initialize(obj) + @obj = obj + end + + def hash + @obj.hash + end + + def eql?(other) + @obj.eql?(other) + end + end + + hash = {5 => bug9381} + assert_equal(bug9381, hash[wrapper.new(5)]) + end + class TestSubHash < TestHash class SubHash < Hash def reject(*) diff --git a/version.h b/version.h index 0e69916f3cd37b..7b9f857e619f87 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 21 +#define RUBY_PATCHLEVEL 22 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 9a372faf3edf52c37f15460b05144f49fcbc4f3c Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 14:57:11 +0000 Subject: [PATCH 25/83] merge revision(s) 44583: [Backport #9302] * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong. [Bug #9302] [ruby-core:59324] * test/thread/test_queue.rb: add test git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/thread/thread.c | 2 +- test/thread/test_queue.rb | 23 +++++++++++++++++++++++ version.h | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8a73d3aec6257..1a2ad053669539 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Feb 5 23:57:05 2014 Charlie Somerville + + * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS + instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong. + [Bug #9302] [ruby-core:59324] + + * test/thread/test_queue.rb: add test + Wed Feb 5 23:43:30 2014 NAKAMURA Usaku * hash.c (rb_objid_hash): should return `long'. brushup r44534. diff --git a/ext/thread/thread.c b/ext/thread/thread.c index b8be5d883ff3f4..208d1172dfb3ab 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -459,7 +459,7 @@ static VALUE rb_szqueue_push(VALUE self, VALUE obj) { struct waiting_delete args; - args.waiting = GET_QUEUE_WAITERS(self); + args.waiting = GET_SZQUEUE_WAITERS(self); args.th = rb_thread_current(); while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) { diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 563b91e748e72b..438e1e75e3edd4 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -134,6 +134,29 @@ def test_sized_queue_clear_return_value assert_same q, retval end + def test_sized_queue_throttle + q = SizedQueue.new(1) + i = 0 + consumer = Thread.new do + while q.pop + i += 1 + Thread.pass + end + end + nprod = 4 + npush = 100 + + producer = nprod.times.map do + Thread.new do + npush.times { q.push(true) } + end + end + producer.each(&:join) + q.push(nil) + consumer.join + assert_equal(nprod * npush, i) + end + def test_queue_thread_raise q = Queue.new th1 = Thread.new do diff --git a/version.h b/version.h index 7b9f857e619f87..4ebbd65adfe68d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 22 +#define RUBY_PATCHLEVEL 23 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 898c29a58bb09894fbd0464ad6c40c8f7bcbe553 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 15:47:37 +0000 Subject: [PATCH 26/83] merge revision(s) 44555: test_weakref.rb: find collected weakref * test/test_weakref.rb (test_recycled): retry and find a WeakRef whose the target is collected, to fix circumstance dependent. git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_weakref.rb | 11 ++++++++--- version.h | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/test_weakref.rb b/test/test_weakref.rb index 85820b17b8af70..f12e943423c61c 100644 --- a/test/test_weakref.rb +++ b/test/test_weakref.rb @@ -19,9 +19,14 @@ def test_ref end def test_recycled - weak = make_weakref - ObjectSpace.garbage_collect - ObjectSpace.garbage_collect + weaks = [] + weak = nil + 100.times do + weaks << make_weakref + ObjectSpace.garbage_collect + ObjectSpace.garbage_collect + break if weak = weaks.find {|w| !w.weakref_alive?} + end assert_raise(WeakRef::RefError) {weak.to_s} assert_not_predicate(weak, :weakref_alive?) end diff --git a/version.h b/version.h index 4ebbd65adfe68d..a7c0dc8624a296 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 23 +#define RUBY_RELEASE_DATE "2014-02-06" +#define RUBY_PATCHLEVEL 24 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 6 #include "ruby/version.h" From c464602cc1da1497541af1fc4ee9fb3804094004 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 02:24:40 +0000 Subject: [PATCH 27/83] merge revision(s) 44853: [Backport #9490] * gc.c (ruby_gc_set_params): if RUBY_GC_OLDMALLOC_LIMIT is provided, then set objspace->rgengc.oldmalloc_increase_limit. Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT does not work. * gc.c (get_envparam_int): accept a value equals to lowerbounds. * gc.c (get_envparam_double): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ gc.c | 13 +++++++++---- version.h | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a2ad053669539..465c45dec77b2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Feb 6 11:23:59 2014 Koichi Sasada + + * gc.c (ruby_gc_set_params): if RUBY_GC_OLDMALLOC_LIMIT is provided, + then set objspace->rgengc.oldmalloc_increase_limit. + Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT + does not work. + + * gc.c (get_envparam_int): accept a value equals to lowerbounds. + + * gc.c (get_envparam_double): ditto. + Wed Feb 5 23:57:05 2014 Charlie Somerville * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS diff --git a/gc.c b/gc.c index 19e942d77db094..e51b727ecd5f84 100644 --- a/gc.c +++ b/gc.c @@ -2916,7 +2916,9 @@ gc_before_sweep(rb_objspace_t *objspace) } } - if (0) fprintf(stderr, "%d\t%d\t%u\t%u\t%d\n", (int)rb_gc_count(), objspace->rgengc.need_major_gc, + if (0) fprintf(stderr, "%d\t%d\t%u\t%u\t%d\n", + (int)rb_gc_count(), + (int)objspace->rgengc.need_major_gc, (unsigned int)objspace->rgengc.oldmalloc_increase, (unsigned int)objspace->rgengc.oldmalloc_increase_limit, (unsigned int)gc_params.oldmalloc_limit_max); @@ -5647,7 +5649,7 @@ get_envparam_int(const char *name, unsigned int *default_value, int lower_bound) if (ptr != NULL) { val = atoi(ptr); - if (val > lower_bound) { + if (val >= lower_bound) { if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (%d)\n", name, val, *default_value); *default_value = val; return 1; @@ -5667,7 +5669,7 @@ get_envparam_double(const char *name, double *default_value, double lower_bound) if (ptr != NULL) { val = strtod(ptr, NULL); - if (val > lower_bound) { + if (val >= lower_bound) { if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (%f)\n", name, val, *default_value); *default_value = val; return 1; @@ -5746,7 +5748,10 @@ ruby_gc_set_params(int safe_level) get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0); #ifdef RGENGC_ESTIMATE_OLDMALLOC - get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0); + if (get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) { + rb_objspace_t *objspace = &rb_objspace; + objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min; + } get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT_MAX", &gc_params.oldmalloc_limit_max, 0); get_envparam_double("RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR", &gc_params.oldmalloc_limit_growth_factor, 1.0); #endif diff --git a/version.h b/version.h index a7c0dc8624a296..ffd78c8e59fe29 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-06" -#define RUBY_PATCHLEVEL 24 +#define RUBY_PATCHLEVEL 25 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 7b3834378dc0f5a873dca8ff49378f322d2911f2 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 02:59:36 +0000 Subject: [PATCH 28/83] * lib/rubygems: RubyGems 2.2.2 which contains the following bug fixes: http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.2.2+%2F+2014-02-05 https://bugs.ruby-lang.org/issues/9489 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 + NEWS | 2 + lib/rubygems.rb | 19 ++- lib/rubygems/available_set.rb | 3 + lib/rubygems/basic_specification.rb | 18 +++ lib/rubygems/commands/contents_command.rb | 6 +- .../commands/generate_index_command.rb | 2 +- lib/rubygems/commands/install_command.rb | 20 ++- lib/rubygems/commands/setup_command.rb | 16 +- lib/rubygems/compatibility.rb | 4 +- lib/rubygems/config_file.rb | 5 +- lib/rubygems/defaults.rb | 20 +-- lib/rubygems/dependency_installer.rb | 1 + lib/rubygems/deprecate.rb | 2 +- lib/rubygems/ext/ext_conf_builder.rb | 6 +- lib/rubygems/installer.rb | 6 +- lib/rubygems/package/tar_header.rb | 2 +- lib/rubygems/platform.rb | 2 +- lib/rubygems/rdoc.rb | 2 +- lib/rubygems/remote_fetcher.rb | 40 +++-- lib/rubygems/request.rb | 8 +- lib/rubygems/request_set.rb | 8 + lib/rubygems/request_set/lockfile.rb | 7 +- lib/rubygems/resolver.rb | 23 +-- lib/rubygems/resolver/api_set.rb | 7 +- lib/rubygems/resolver/best_set.rb | 21 ++- lib/rubygems/resolver/composed_set.rb | 11 ++ lib/rubygems/resolver/git_set.rb | 3 + lib/rubygems/resolver/index_set.rb | 4 + lib/rubygems/resolver/installer_set.rb | 49 ++---- lib/rubygems/resolver/lock_set.rb | 2 + lib/rubygems/resolver/set.rb | 17 +++ lib/rubygems/resolver/vendor_set.rb | 2 + lib/rubygems/security.rb | 6 +- lib/rubygems/source/git.rb | 14 ++ lib/rubygems/specification.rb | 46 +++--- lib/rubygems/test_case.rb | 40 ++++- lib/rubygems/uninstaller.rb | 2 +- lib/rubygems/version.rb | 28 ++-- test/rubygems/test_gem.rb | 142 ++++++++++-------- .../test_gem_commands_contents_command.rb | 6 +- .../test_gem_commands_environment_command.rb | 2 +- .../test_gem_commands_install_command.rb | 15 ++ .../test_gem_commands_update_command.rb | 2 +- .../rubygems/test_gem_dependency_installer.rb | 2 +- .../rubygems/test_gem_ext_ext_conf_builder.rb | 68 +++++---- test/rubygems/test_gem_installer.rb | 14 +- test/rubygems/test_gem_package_tar_header.rb | 14 ++ test/rubygems/test_gem_platform.rb | 6 +- test/rubygems/test_gem_remote_fetcher.rb | 6 +- test/rubygems/test_gem_request.rb | 69 +++++++++ test/rubygems/test_gem_request_set.rb | 21 +++ .../rubygems/test_gem_request_set_lockfile.rb | 10 +- test/rubygems/test_gem_resolver.rb | 8 + test/rubygems/test_gem_resolver_api_set.rb | 41 +++++ test/rubygems/test_gem_resolver_best_set.rb | 50 ++++++ test/rubygems/test_gem_resolver_git_set.rb | 15 ++ test/rubygems/test_gem_resolver_index_set.rb | 35 +++++ .../test_gem_resolver_installer_set.rb | 70 +++++++++ test/rubygems/test_gem_source_git.rb | 43 ++++++ test/rubygems/test_gem_specification.rb | 71 ++++++--- test/rubygems/test_gem_uninstaller.rb | 17 +++ test/rubygems/test_gem_version.rb | 10 ++ version.h | 2 +- 64 files changed, 927 insertions(+), 292 deletions(-) diff --git a/ChangeLog b/ChangeLog index 465c45dec77b2e..86fbbe34019209 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Feb 6 11:27:39 2014 Eric Hodel + + * lib/rubygems: RubyGems 2.2.2 which contains the following bug fixes: + http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.2.2+%2F+2014-02-05 + https://bugs.ruby-lang.org/issues/9489 + Thu Feb 6 11:23:59 2014 Koichi Sasada * gc.c (ruby_gc_set_params): if RUBY_GC_OLDMALLOC_LIMIT is provided, diff --git a/NEWS b/NEWS index a096ad9d28fc85..afd15faf3b128c 100644 --- a/NEWS +++ b/NEWS @@ -276,6 +276,8 @@ String * Improved, iterative resolver (compared to RubyGems 2.1 and earlier) * Support for a sharing a GEM_HOME across ruby platforms and versions + * Updated to 2.2.2. Fixes some minor bugs and performance regressions. + For a complete list of enhancements and bug fixes see: https://github.com/rubygems/rubygems/tree/master/History.txt diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 73c4846f8274de..456273ed19d763 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.2.0' + VERSION = '2.2.2' end # Must be first since it unloads the prelude from 1.9.2 @@ -572,7 +572,7 @@ def self.host= host # gem's paths are inserted before site lib directory by default. def self.load_path_insert_index - index = $LOAD_PATH.index ConfigMap[:sitelibdir] + index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir'] index end @@ -743,8 +743,8 @@ def self.pre_uninstall(&hook) def self.prefix prefix = File.dirname RUBYGEMS_DIR - if prefix != File.expand_path(ConfigMap[:sitelibdir]) and - prefix != File.expand_path(ConfigMap[:libdir]) and + if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and + prefix != File.expand_path(RbConfig::CONFIG['libdir']) and 'lib' == File.basename(RUBYGEMS_DIR) then prefix end @@ -765,6 +765,10 @@ def self.read_binary(path) f.flock(File::LOCK_EX) f.read end + rescue Errno::EACCES + open path, 'rb' do |f| + f.read + end end ## @@ -772,8 +776,8 @@ def self.read_binary(path) def self.ruby if @ruby.nil? then - @ruby = File.join(ConfigMap[:bindir], - "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}") + @ruby = File.join(RbConfig::CONFIG['bindir'], + "#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}") @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/ end @@ -785,8 +789,7 @@ def self.ruby # Returns a String containing the API compatibility version of Ruby def self.ruby_api_version - @ruby_api_version ||= - "#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}" + @ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup end ## diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb index d8655afc34a000..fabdd6e79d71c3 100644 --- a/lib/rubygems/available_set.rb +++ b/lib/rubygems/available_set.rb @@ -4,9 +4,12 @@ class Gem::AvailableSet Tuple = Struct.new(:spec, :source) + attr_accessor :remote # :nodoc: + def initialize @set = [] @sorted = nil + @remote = true end attr_reader :set diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index a52377ff22e067..470a6ebc8b5c43 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -206,6 +206,24 @@ def require_paths [relative_extension_dir].concat @require_paths end + ## + # Returns the paths to the source files for use with analysis and + # documentation tools. These paths are relative to full_gem_path. + + def source_paths + paths = raw_require_paths.dup + + if @extensions then + ext_dirs = @extensions.map do |extension| + extension.split(File::SEPARATOR, 2).first + end.uniq + + paths.concat ext_dirs + end + + paths.uniq + end + ## # Return a Gem::Specification from this gem diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 97218848edac15..603f1d072aaa6f 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -94,11 +94,11 @@ def files_in_default_gem spec spec.files.sort.map do |file| case file when /\A#{spec.bindir}\// - [Gem::ConfigMap[:bindir], $POSTMATCH] + [RbConfig::CONFIG['bindir'], $POSTMATCH] when /\.so\z/ - [Gem::ConfigMap[:archdir], file] + [RbConfig::CONFIG['archdir'], file] else - [Gem::ConfigMap[:rubylibdir], file] + [RbConfig::CONFIG['rubylibdir'], file] end end end diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb index a7db013caf9deb..ca6f694bc56d7d 100644 --- a/lib/rubygems/commands/generate_index_command.rb +++ b/lib/rubygems/commands/generate_index_command.rb @@ -62,7 +62,7 @@ def description # :nodoc: end def execute - # This is always true becasue it's the only way now. + # This is always true because it's the only way now. options[:build_modern] = true if not File.exist?(options[:directory]) or diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 4485eb12e81719..8219eef6ead096 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -228,7 +228,18 @@ def install_gem name, version # :nodoc: def install_gem_without_dependencies name, req # :nodoc: gem = nil - if remote? then + if local? then + if name =~ /\.gem$/ and File.file? name then + source = Gem::Source::SpecificFile.new name + spec = source.spec + else + source = Gem::Source::Local.new + spec = source.find_gem name, req + end + gem = source.download spec if spec + end + + if remote? and not gem then dependency = Gem::Dependency.new name, req dependency.prerelease = options[:prerelease] @@ -236,13 +247,6 @@ def install_gem_without_dependencies name, req # :nodoc: gem = fetcher.download_to_cache dependency end - if local? and not gem then - source = Gem::Source::Local.new - spec = source.find_gem name, req - - gem = source.download spec - end - inst = Gem::Installer.new gem, options inst.install diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index face77fae9ce28..681db0dc1d19fc 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -13,7 +13,7 @@ def initialize super 'setup', 'Install RubyGems', :format_executable => true, :document => %w[ri], - :site_or_vendor => :sitelibdir, + :site_or_vendor => 'sitelibdir', :destdir => '', :prefix => '', :previous_version => '' add_option '--previous-version=VERSION', @@ -36,7 +36,7 @@ def initialize add_option '--[no-]vendor', 'Install into vendorlibdir not sitelibdir' do |vendor, options| - options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir + options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir' end add_option '--[no-]format-executable', @@ -343,19 +343,19 @@ def generate_default_dirs(install_destdir) site_or_vendor = options[:site_or_vendor] if prefix.empty? then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + lib_dir = RbConfig::CONFIG[site_or_vendor] + bin_dir = RbConfig::CONFIG['bindir'] else # Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets # confused about installation location, so switch back to # sitelibdir/vendorlibdir. if defined?(APPLE_GEM_HOME) and # just in case Apple and RubyGems don't get this patched up proper. - (prefix == Gem::ConfigMap[:libdir] or + (prefix == RbConfig::CONFIG['libdir'] or # this one is important - prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then + lib_dir = RbConfig::CONFIG[site_or_vendor] + bin_dir = RbConfig::CONFIG['bindir'] else lib_dir = File.join prefix, 'lib' bin_dir = File.join prefix, 'bin' diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb index 5e8618fe39c088..d06ade1fa662ba 100644 --- a/lib/rubygems/compatibility.rb +++ b/lib/rubygems/compatibility.rb @@ -33,6 +33,8 @@ class << Gem module Gem RubyGemsVersion = VERSION + # TODO remove at RubyGems 3 + RbConfigPriorities = %w[ MAJOR MINOR @@ -45,7 +47,7 @@ module Gem unless defined?(ConfigMap) ## # Configuration settings from ::RbConfig - ConfigMap = Hash.new do |cm, key| + ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3 cm[key] = RbConfig::CONFIG[key.to_s] end else diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index 1acae9b52942e3..cf14017ea2d5be 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -137,9 +137,10 @@ class Gem::ConfigFile attr_reader :ssl_verify_mode ## - # Path name of directory or file of openssl CA certificate, used for remote https connection + # Path name of directory or file of openssl CA certificate, used for remote + # https connection - attr_reader :ssl_ca_cert + attr_accessor :ssl_ca_cert ## # Path name of directory or file of openssl client certificate, used for remote https connection with client authentication diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 715c0b71b36181..6924f48e5ade92 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -29,22 +29,22 @@ def self.default_spec_cache_dir def self.default_dir path = if defined? RUBY_FRAMEWORK_VERSION then [ - File.dirname(ConfigMap[:sitedir]), + File.dirname(RbConfig::CONFIG['sitedir']), 'Gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] - elsif ConfigMap[:rubylibprefix] then + elsif RbConfig::CONFIG['rubylibprefix'] then [ - ConfigMap[:rubylibprefix], + RbConfig::CONFIG['rubylibprefix'], 'gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] else [ - ConfigMap[:libdir], + RbConfig::CONFIG['libdir'], ruby_engine, 'gems', - ConfigMap[:ruby_version] + RbConfig::CONFIG['ruby_version'] ] end @@ -74,7 +74,7 @@ def self.default_rubygems_dirs def self.user_dir parts = [Gem.user_home, '.gem', ruby_engine] - parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty? + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? File.join parts end @@ -100,7 +100,7 @@ def self.default_path # Deduce Ruby's --program-prefix and --program-suffix from its install name def self.default_exec_format - exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s' + exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s' unless exec_format =~ /%s/ then raise Gem::Exception, @@ -117,7 +117,7 @@ def self.default_bindir if defined? RUBY_FRAMEWORK_VERSION then # mac framework support '/usr/bin' else # generic install - ConfigMap[:bindir] + RbConfig::CONFIG['bindir'] end end diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb index b7babf6d386e41..da6994a9beb4d3 100644 --- a/lib/rubygems/dependency_installer.rb +++ b/lib/rubygems/dependency_installer.rb @@ -419,6 +419,7 @@ def resolve_dependencies dep_or_name, version # :nodoc: request_set = as.to_request_set install_development_deps request_set.soft_missing = @force + request_set.remote = false unless consider_remote? installer_set = Gem::Resolver::InstallerSet.new @domain installer_set.always_install.concat request_set.always_install diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 274d6a5c12023f..e19360da13a81f 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -50,7 +50,7 @@ def deprecate name, repl, year, month class_eval { old = "_deprecated_#{name}" alias_method old, name - define_method name do |*args, &block| # TODO: really works on 1.8.7? + define_method name do |*args, &block| klass = self.kind_of? Module target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index 402aa966c07791..990fd18524caac 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -34,7 +34,11 @@ def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil) ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ') cmd = [Gem.ruby, File.basename(extension), *args].join ' ' - run cmd, results + begin + run cmd, results + ensure + FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log' + end ENV["DESTDIR"] = nil ENV["RUBYOPT"] = rubyopt diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index f8eb2c2145fa1e..c80981682f14b1 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -480,7 +480,7 @@ def generate_bin_symlink(filename, bindir) # def shebang(bin_file_name) - ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang + ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang path = File.join gem_dir, spec.bindir, bin_file_name first_line = File.open(path, "rb") {|file| file.gets} @@ -493,7 +493,7 @@ def shebang(bin_file_name) if which = Gem.configuration[:custom_shebang] # replace bin_file_name with "ruby" to avoid endless loops - which = which.gsub(/ #{bin_file_name}$/," #{Gem::ConfigMap[:ruby_install_name]}") + which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}") which = which.gsub(/\$(\w+)/) do case $1 @@ -641,7 +641,7 @@ def app_script_text(bin_file_name) if ARGV.first str = ARGV.first str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding - if str =~ /\\A_(.*)_\\z/ + if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then version = $1 ARGV.shift end diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb index 28da1db0b508fa..f9ab13aca77447 100644 --- a/lib/rubygems/package/tar_header.rb +++ b/lib/rubygems/package/tar_header.rb @@ -134,7 +134,7 @@ def initialize(vals) vals[:gid] ||= 0 vals[:mtime] ||= 0 vals[:checksum] ||= "" - vals[:typeflag] ||= "0" + vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty? vals[:magic] ||= "ustar" vals[:version] ||= "00" vals[:uname] ||= "wheel" diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index e050959dc6fde5..1bcd7549ad4f79 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -16,7 +16,7 @@ class Gem::Platform attr_accessor :version def self.local - arch = Gem::ConfigMap[:arch] + arch = RbConfig::CONFIG['arch'] arch = "#{arch}_60" if arch =~ /mswin32$/ @local ||= new(arch) end diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb index 52249dc267aa88..633bd893a5df0c 100644 --- a/lib/rubygems/rdoc.rb +++ b/lib/rubygems/rdoc.rb @@ -193,7 +193,7 @@ def generate ::RDoc::Parser::C.reset args = @spec.rdoc_options - args.concat @spec.require_paths + args.concat @spec.source_paths args.concat @spec.extra_rdoc_files case config_args = Gem.configuration[:rdoc] diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index e32c0249896f53..58991caeda93da 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -131,11 +131,19 @@ def download(spec, source_uri, install_dir = Gem.dir) FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir - # Always escape URI's to deal with potential spaces and such - unless URI::Generic === source_uri - source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ? - URI::DEFAULT_PARSER.escape(source_uri.to_s) : - URI.escape(source_uri.to_s)) + # Always escape URI's to deal with potential spaces and such + # It should also be considered that source_uri may already be + # a valid URI with escaped characters. e.g. "{DESede}" is encoded + # as "%7BDESede%7D". If this is escaped again the percentage + # symbols will be escaped. + unless source_uri.is_a?(URI::Generic) + begin + source_uri = URI.parse(source_uri) + rescue + source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ? + URI::DEFAULT_PARSER.escape(source_uri.to_s) : + URI.escape(source_uri.to_s)) + end end scheme = source_uri.scheme @@ -285,20 +293,20 @@ def fetch_path(uri, mtime = nil, head = false) def cache_update_path uri, path = nil, update = true mtime = path && File.stat(path).mtime rescue nil - if mtime && Net::HTTPNotModified === fetch_path(uri, mtime, true) - Gem.read_binary(path) - else - data = fetch_path(uri) + data = fetch_path(uri, mtime) - if update and path then - open(path, 'wb') do |io| - io.flock(File::LOCK_EX) - io.write data - end - end + if data == nil # indicates the server returned 304 Not Modified + return Gem.read_binary(path) + end - data + if update and path + open(path, 'wb') do |io| + io.flock(File::LOCK_EX) + io.write data + end end + + data end ## diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb index e8707630c5b1fb..d2f076f58110ce 100644 --- a/lib/rubygems/request.rb +++ b/lib/rubygems/request.rb @@ -48,15 +48,14 @@ def configure_connection_for_https(connection) connection.key = OpenSSL::PKey::RSA.new pem end + store.set_default_paths + add_rubygems_trusted_certs(store) if Gem.configuration.ssl_ca_cert if File.directory? Gem.configuration.ssl_ca_cert store.add_path Gem.configuration.ssl_ca_cert else store.add_file Gem.configuration.ssl_ca_cert end - else - store.set_default_paths - add_rubygems_trusted_certs(store) end connection.cert_store = store rescue LoadError => e @@ -106,7 +105,8 @@ def fetch request = @request_class.new @uri.request_uri unless @uri.nil? || @uri.user.nil? || @uri.user.empty? then - request.basic_auth @uri.user, @uri.password + request.basic_auth Gem::UriFormatter.new(@uri.user).unescape, + Gem::UriFormatter.new(@uri.password).unescape end request.add_field 'User-Agent', @user_agent diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb index aa3f27c9c1a191..fb54e344bdfd3d 100644 --- a/lib/rubygems/request_set.rb +++ b/lib/rubygems/request_set.rb @@ -38,6 +38,11 @@ class Gem::RequestSet attr_accessor :ignore_dependencies + ## + # When false no remote sets are used for resolving gems. + + attr_accessor :remote + ## # Sets used for resolution @@ -71,6 +76,7 @@ def initialize *deps @git_set = nil @ignore_dependencies = false @install_dir = Gem.dir + @remote = true @requests = [] @sets = [] @soft_missing = false @@ -150,6 +156,7 @@ def install_from_gemdeps options, &block gemdeps = options[:gemdeps] @install_dir = options[:install_dir] || Gem.dir + @remote = options[:domain] != :local load_gemdeps gemdeps, options[:without_groups] @@ -235,6 +242,7 @@ def resolve set = Gem::Resolver::BestSet.new @sets << @vendor_set set = Gem::Resolver.compose_sets(*@sets) + set.remote = @remote resolver = Gem::Resolver.new @dependencies, set resolver.development = @development diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 522caf15026af0..0433d2a7fc86e5 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -303,7 +303,12 @@ def parse_GEM # :nodoc: type, data, = get [:text, :requirement] if type == :text and column == 4 then - last_spec = set.add name, data, Gem::Platform::RUBY + version, platform = data.split '-', 2 + + platform = + platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY + + last_spec = set.add name, version, platform else dependency = parse_dependency name, data diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index d455e03c0576fb..65e92bbf29b409 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -59,6 +59,8 @@ def self.compose_sets *sets sets = sets.map do |set| case set + when Gem::Resolver::BestSet then + set when Gem::Resolver::ComposedSet then set.sets else @@ -178,27 +180,6 @@ def resolve res.to_a end - ## - # Finds the State in +states+ that matches the +conflict+ so that we can try - # other possible sets. - # - # If no good candidate is found, the first state is tried. - - def find_conflict_state conflict, states # :nodoc: - until states.empty? do - state = states.pop - - explain :consider, state.dep, conflict.failed_dep - - if conflict.for_spec? state.spec - state.conflicts << [state.spec, conflict] - return state - end - end - - nil - end - ## # Extracts the specifications that may be able to fulfill +dependency+ and # returns those that match the local platform and all those that match. diff --git a/lib/rubygems/resolver/api_set.rb b/lib/rubygems/resolver/api_set.rb index 89ee3c9b15c2a6..5475e626e6e70b 100644 --- a/lib/rubygems/resolver/api_set.rb +++ b/lib/rubygems/resolver/api_set.rb @@ -25,10 +25,12 @@ class Gem::Resolver::APISet < Gem::Resolver::Set # http://guides.rubygems.org/rubygems-org-api def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies' + super() + dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8 @dep_uri = dep_uri - @uri = dep_uri + '../../..' + @uri = dep_uri + '../..' @data = Hash.new { |h,k| h[k] = [] } @source = Gem::Source.new @uri @@ -41,6 +43,8 @@ def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies' def find_all req res = [] + return res unless @remote + versions(req.name).each do |ver| if req.dependency.match? req.name, ver[:number] res << Gem::Resolver::APISpecification.new(self, ver) @@ -55,6 +59,7 @@ def find_all req # data for DependencyRequests +reqs+. def prefetch reqs + return unless @remote names = reqs.map { |r| r.dependency.name } needed = names - @data.keys diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb index fa6c9f84c0ee90..20bb94827b0f27 100644 --- a/lib/rubygems/resolver/best_set.rb +++ b/lib/rubygems/resolver/best_set.rb @@ -12,11 +12,30 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet def initialize sources = Gem.sources super() - sources.each_source do |source| + @sources = sources + end + + ## + # Picks which sets to use for the configured sources. + + def pick_sets # :nodoc: + @sources.each_source do |source| @sets << source.dependency_resolver_set end end + def find_all req # :nodoc: + pick_sets if @remote and @sets.empty? + + super + end + + def prefetch reqs # :nodoc: + pick_sets if @remote and @sets.empty? + + super + end + def pretty_print q # :nodoc: q.group 2, '[BestSet', ']' do q.breakable diff --git a/lib/rubygems/resolver/composed_set.rb b/lib/rubygems/resolver/composed_set.rb index 19227e095b6b0a..6f912b0afe1cdc 100644 --- a/lib/rubygems/resolver/composed_set.rb +++ b/lib/rubygems/resolver/composed_set.rb @@ -16,9 +16,20 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set # Gem::Resolver::compose_sets instead. def initialize *sets + super() + @sets = sets end + ## + # Sets the remote network access for all composed sets. + + def remote= remote + super + + @sets.each { |set| set.remote = remote } + end + ## # Finds all specs matching +req+ in all sets. diff --git a/lib/rubygems/resolver/git_set.rb b/lib/rubygems/resolver/git_set.rb index 1a2b230b809367..d32710e3d61ca8 100644 --- a/lib/rubygems/resolver/git_set.rb +++ b/lib/rubygems/resolver/git_set.rb @@ -33,6 +33,8 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set attr_reader :specs # :nodoc: def initialize # :nodoc: + super() + @git = ENV['git'] || 'git' @need_submodules = {} @repositories = {} @@ -91,6 +93,7 @@ def prefetch reqs @repositories.each do |name, (repository, reference)| source = Gem::Source::Git.new name, repository, reference source.root_dir = @root_dir + source.remote = @remote source.specs.each do |spec| git_spec = Gem::Resolver::GitSpecification.new self, spec, source diff --git a/lib/rubygems/resolver/index_set.rb b/lib/rubygems/resolver/index_set.rb index a6ef56bb7f3ea8..ef01f0f0ad5cc2 100644 --- a/lib/rubygems/resolver/index_set.rb +++ b/lib/rubygems/resolver/index_set.rb @@ -5,6 +5,8 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set def initialize source = nil # :nodoc: + super() + @f = if source then sources = Gem::SourceList.from [source] @@ -34,6 +36,8 @@ def initialize source = nil # :nodoc: def find_all req res = [] + return res unless @remote + name = req.dependency.name @all[name].each do |uri, n| diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index e35e0aabecc92a..045c893fdc4f3d 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -24,15 +24,17 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set # Creates a new InstallerSet that will look for gems in +domain+. def initialize domain + super() + @domain = domain + @remote = consider_remote? @f = Gem::SpecFetcher.fetcher - @all = Hash.new { |h,k| h[k] = [] } @always_install = [] @ignore_dependencies = false @ignore_installed = false - @loaded_remote_specs = [] + @remote_set = Gem::Resolver::BestSet.new @specs = {} end @@ -79,16 +81,7 @@ def find_all req end end - if consider_remote? then - load_remote_specs dep - - @all[name].each do |remote_source, n| - if dep.match? n then - res << Gem::Resolver::IndexSpecification.new( - self, n.name, n.version, remote_source, n.platform) - end - end - end + res.concat @remote_set.find_all req if consider_remote? res end @@ -101,27 +94,6 @@ def inspect # :nodoc: ] end - ## - # Loads remote prerelease specs if +dep+ is a prerelease dependency - - def load_remote_specs dep # :nodoc: - types = [:released] - types << :prerelease if dep.prerelease? - - types.each do |type| - next if @loaded_remote_specs.include? type - @loaded_remote_specs << type - - list, = @f.available_specs type - - list.each do |uri, specs| - specs.each do |n| - @all[n.name] << [uri, n] - end - end - end - end - ## # Called from IndexSpecification to get a true Specification # object. @@ -151,5 +123,16 @@ def pretty_print q # :nodoc: end end + def remote= remote # :nodoc: + case @domain + when :local then + @domain = :both if remote + when :remote then + @domain = nil unless remote + when :both then + @domain = :local unless remote + end + end + end diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb index cdb41b22bf2292..f4987576ec1993 100644 --- a/lib/rubygems/resolver/lock_set.rb +++ b/lib/rubygems/resolver/lock_set.rb @@ -9,6 +9,8 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set # Creates a new LockSet from the given +source+ def initialize source + super() + @source = Gem::Source::Lock.new source @specs = [] end diff --git a/lib/rubygems/resolver/set.rb b/lib/rubygems/resolver/set.rb index 32c137ef6b1c0d..f053b65e1564d9 100644 --- a/lib/rubygems/resolver/set.rb +++ b/lib/rubygems/resolver/set.rb @@ -4,6 +4,15 @@ class Gem::Resolver::Set + ## + # Set to true to disable network access for this set + + attr_accessor :remote + + def initialize # :nodoc: + @remote = true + end + ## # The find_all method must be implemented. It returns all Resolver # Specification objects matching the given DependencyRequest +req+. @@ -23,5 +32,13 @@ def find_all req def prefetch reqs end + ## + # When true, this set is allowed to access the network when looking up + # specifications or dependencies. + + def remote? # :nodoc: + @remote + end + end diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb index 3db637f4a3d353..6e867073be74f6 100644 --- a/lib/rubygems/resolver/vendor_set.rb +++ b/lib/rubygems/resolver/vendor_set.rb @@ -21,6 +21,8 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set attr_reader :specs # :nodoc: def initialize # :nodoc: + super() + @directories = {} @specs = {} end diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb index bfd6fd225b47ba..8c5fb7d9f2e146 100644 --- a/lib/rubygems/security.rb +++ b/lib/rubygems/security.rb @@ -120,11 +120,11 @@ # * HighSecurity - Here's the bugger that got us into this mess. # The HighSecurity policy is identical to the MediumSecurity policy, # except that it does not allow unsigned gems. A malicious user -# doesn't have a whole lot of options here; he can't modify the -# package contents without invalidating the signature, and he can't +# doesn't have a whole lot of options here; they can't modify the +# package contents without invalidating the signature, and they can't # modify or remove signature or the signing certificate chain, or # RubyGems will simply refuse to install the package. Oh well, maybe -# he'll have better luck causing problems for CPAN users instead :). +# they'll have better luck causing problems for CPAN users instead :). # # The reason RubyGems refused to install your shiny new signed gem was because # it was from an untrusted source. Well, your code is infallible (naturally), diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb index 28178a5f4f1bb6..2e3fa037309e27 100644 --- a/lib/rubygems/source/git.rb +++ b/lib/rubygems/source/git.rb @@ -23,6 +23,11 @@ class Gem::Source::Git < Gem::Source attr_reader :reference + ## + # When false the cache for this repository will not be updated. + + attr_accessor :remote + ## # The git repository this gem is sourced from. @@ -53,6 +58,7 @@ def initialize name, repository, reference, submodules = false @reference = reference @need_submodules = submodules + @remote = true @root_dir = Gem.dir @git = ENV['git'] || 'git' end @@ -85,6 +91,8 @@ def == other # :nodoc: def checkout # :nodoc: cache + return false unless File.exist? repo_cache_dir + unless File.exist? install_dir then system @git, 'clone', '--quiet', '--no-checkout', repo_cache_dir, install_dir @@ -107,6 +115,8 @@ def checkout # :nodoc: # Creates a local cache repository for the git gem. def cache # :nodoc: + return unless @remote + if File.exist? repo_cache_dir then Dir.chdir repo_cache_dir do system @git, 'fetch', '--quiet', '--force', '--tags', @@ -142,6 +152,8 @@ def download full_spec, path # :nodoc: # The directory where the git gem will be installed. def install_dir # :nodoc: + return unless File.exist? repo_cache_dir + File.join base_dir, 'gems', "#{@name}-#{dir_shortref}" end @@ -177,6 +189,8 @@ def rev_parse # :nodoc: def specs checkout + return [] unless install_dir + Dir.chdir install_dir do Dir['{,*,*/*}.gemspec'].map do |spec_file| directory = File.dirname spec_file diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 59d71d378bb3f7..f4e609a5eb4742 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -240,6 +240,28 @@ class Gem::Specification < Gem::BasicSpecification attr_reader :summary + ## + # Singular writer for #authors + # + # Usage: + # + # spec.author = 'John Jones' + + def author= o + self.authors = [o] + end + + ## + # Sets the list of authors, ensuring it is an array. + # + # Usage: + # + # spec.authors = ['John Jones', 'Mary Smith'] + + def authors= value + @authors = Array(value).flatten.grep(String) + end + ## # The platform this gem runs on. # @@ -327,7 +349,7 @@ def files add_bindir(@executables), @extra_rdoc_files, @extensions, - ].flatten.sort.uniq.compact + ].flatten.uniq.compact.sort end ###################################################################### @@ -442,28 +464,6 @@ def add_runtime_dependency(gem, *requirements) add_dependency_with_type(gem, :runtime, *requirements) end - ## - # Singular writer for #authors - # - # Usage: - # - # spec.author = 'John Jones' - - def author= o - self.authors = [o] - end - - ## - # Sets the list of authors, ensuring it is an array. - # - # Usage: - # - # spec.authors = ['John Jones', 'Mary Smith'] - - def authors= value - @authors = Array(value).flatten.grep(String) - end - ## # Executables included in the gem. # diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 8dc37d67204dc6..328731d4eac729 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -115,6 +115,23 @@ def assert_path_exists path, msg = nil assert File.exist?(path), msg end + ## + # Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores + # the original value when the block ends + + def enable_shared value + enable_shared = RbConfig::CONFIG['ENABLE_SHARED'] + RbConfig::CONFIG['ENABLE_SHARED'] = value + + yield + ensure + if enable_shared then + RbConfig::CONFIG['enable_shared'] = enable_shared + else + RbConfig::CONFIG.delete 'enable_shared' + end + end + # TODO: move to minitest def refute_path_exists path, msg = nil msg = message(msg) { "Expected path '#{path}' to not exist" } @@ -294,10 +311,10 @@ def setup Gem.searcher = nil Gem::SpecFetcher.fetcher = nil - @orig_BASERUBY = Gem::ConfigMap[:BASERUBY] - Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:ruby_install_name] + @orig_BASERUBY = RbConfig::CONFIG['BASERUBY'] + RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name'] - @orig_arch = Gem::ConfigMap[:arch] + @orig_arch = RbConfig::CONFIG['arch'] if win_platform? util_set_arch 'i386-mswin32' @@ -315,8 +332,12 @@ def setup def teardown $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH - Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY - Gem::ConfigMap[:arch] = @orig_arch + if @orig_BASERUBY + RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY + else + RbConfig::CONFIG.delete('BASERUBY') + end + RbConfig::CONFIG['arch'] = @orig_arch if defined? Gem::RemoteFetcher then Gem::RemoteFetcher.fetcher = nil @@ -898,7 +919,7 @@ def util_make_gems(prerelease = false) # Set the platform to +arch+ def util_set_arch(arch) - Gem::ConfigMap[:arch] = arch + RbConfig::CONFIG['arch'] = arch platform = Gem::Platform.new arch Gem.instance_variable_set :@platforms, nil @@ -1244,11 +1265,18 @@ def vendor_gem name = 'a', version = 1 class StaticSet + ## + # A StaticSet ignores remote because it has a fixed set of gems. + + attr_accessor :remote + ## # Creates a new StaticSet for the given +specs+ def initialize(specs) @specs = specs + + @remote = true end ## diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index 4cb2a1d33334ba..fa838333cd4543 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -237,7 +237,7 @@ def remove(spec) unless path_ok?(@gem_home, spec) or (@user_install and path_ok?(Gem.user_dir, spec)) then e = Gem::GemNotInHomeException.new \ - "Gem is not installed in directory #{@gem_home}" + "Gem '#{spec.full_name}' is not installed in directory #{@gem_home}" e.spec = spec raise e diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index fda8b0b5d49407..20663326ef4b01 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -22,6 +22,11 @@ # 3. 1.0.a.2 # 4. 0.9 # +# If you want to specify a version restriction that includes both prereleases +# and regular releases of the 1.x series this is the best way: +# +# s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0' +# # == How Software Changes # # Users expect to be able to specify a version constraint that gives them @@ -81,8 +86,8 @@ # # * Any "public" release of a gem should have a different version. Normally # that means incrementing the build number. This means a developer can -# generate builds all day long for himself, but as soon as he/she makes a -# public release, the version must be updated. +# generate builds all day long, but as soon as they make a public release, +# the version must be updated. # # === Examples # @@ -99,26 +104,25 @@ # Version 1.1.1:: Fixed a bug in the linked list implementation. # Version 1.1.2:: Fixed a bug introduced in the last fix. # -# Client A needs a stack with basic push/pop capability. He writes to the -# original interface (no top), so his version constraint looks -# like: +# Client A needs a stack with basic push/pop capability. They write to the +# original interface (no top), so their version constraint looks like: # # gem 'stack', '~> 0.0' # # Essentially, any version is OK with Client A. An incompatible change to -# the library will cause him grief, but he is willing to take the chance (we -# call Client A optimistic). +# the library will cause them grief, but they are willing to take the chance +# (we call Client A optimistic). # -# Client B is just like Client A except for two things: (1) He uses the -# depth method and (2) he is worried about future -# incompatibilities, so he writes his version constraint like this: +# Client B is just like Client A except for two things: (1) They use the +# depth method and (2) they are worried about future +# incompatibilities, so they write their version constraint like this: # # gem 'stack', '~> 0.1' # # The depth method was introduced in version 0.1.0, so that version # or anything later is fine, as long as the version stays below version 1.0 # where incompatibilities are introduced. We call Client B pessimistic -# because he is worried about incompatible future changes (it is OK to be +# because they are worried about incompatible future changes (it is OK to be # pessimistic!). # # == Preventing Version Catastrophe: @@ -185,6 +189,8 @@ def self.create input @@all = {} def self.new version # :nodoc: + return super unless Gem::VERSION == self.class + @@all[version] ||= super end diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 759c2fe9070759..e33742049ce68b 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -199,30 +199,21 @@ def test_self_datadir_nonexistent_package end def test_self_default_exec_format - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'ruby' - - assert_equal '%s', Gem.default_exec_format - ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + ruby_install_name 'ruby' do + assert_equal '%s', Gem.default_exec_format + end end def test_self_default_exec_format_18 - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'ruby18' - - assert_equal '%s18', Gem.default_exec_format - ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + ruby_install_name 'ruby18' do + assert_equal '%s18', Gem.default_exec_format + end end def test_self_default_exec_format_jruby - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name] - Gem::ConfigMap[:ruby_install_name] = 'jruby' - - assert_equal 'j%s', Gem.default_exec_format - ensure - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME + ruby_install_name 'jruby' do + assert_equal 'j%s', Gem.default_exec_format + end end def test_self_default_sources @@ -230,6 +221,7 @@ def test_self_default_sources end def test_self_detect_gemdeps + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' FileUtils.mkdir_p 'detect/a/b' @@ -339,21 +331,15 @@ def test_self_ensure_gem_directories_write_protected_parents end def test_self_extension_dir_shared - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] = - RbConfig::CONFIG['ENABLE_SHARED'], 'yes' - - assert_equal Gem.ruby_api_version, Gem.extension_api_version - ensure - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + enable_shared 'yes' do + assert_equal Gem.ruby_api_version, Gem.extension_api_version + end end def test_self_extension_dir_static - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] = - RbConfig::CONFIG['ENABLE_SHARED'], 'no' - - assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version - ensure - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + enable_shared 'no' do + assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version + end end def test_self_find_files @@ -565,24 +551,43 @@ def test_self_prefix end def test_self_prefix_libdir - orig_libdir = Gem::ConfigMap[:libdir] - Gem::ConfigMap[:libdir] = @@project_dir + orig_libdir = RbConfig::CONFIG['libdir'] + RbConfig::CONFIG['libdir'] = @@project_dir assert_nil Gem.prefix ensure - Gem::ConfigMap[:libdir] = orig_libdir + RbConfig::CONFIG['libdir'] = orig_libdir end def test_self_prefix_sitelibdir - orig_sitelibdir = Gem::ConfigMap[:sitelibdir] - Gem::ConfigMap[:sitelibdir] = @@project_dir + orig_sitelibdir = RbConfig::CONFIG['sitelibdir'] + RbConfig::CONFIG['sitelibdir'] = @@project_dir assert_nil Gem.prefix ensure - Gem::ConfigMap[:sitelibdir] = orig_sitelibdir + RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir + end + + def test_self_read_binary + open 'test', 'w' do |io| + io.write "\xCF\x80" + end + + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + + skip 'chmod not supported' if Gem.win_platform? + + begin + File.chmod 0444, 'test' + + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + ensure + File.chmod 0644, 'test' + end end def test_self_refresh + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -602,6 +607,7 @@ def test_self_refresh end def test_self_refresh_keeps_loaded_specs_activated + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7" util_make_gems a1_spec = @a1.spec_file @@ -624,46 +630,44 @@ def test_self_refresh_keeps_loaded_specs_activated def test_self_ruby_escaping_spaces_in_path orig_ruby = Gem.ruby - orig_bindir = Gem::ConfigMap[:bindir] - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] - orig_exe_ext = Gem::ConfigMap[:EXEEXT] + orig_bindir = RbConfig::CONFIG['bindir'] + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin" - Gem::ConfigMap[:ruby_install_name] = "ruby" - Gem::ConfigMap[:EXEEXT] = ".exe" + RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" + RbConfig::CONFIG['ruby_install_name'] = "ruby" + RbConfig::CONFIG['EXEEXT'] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - Gem::ConfigMap[:bindir] = orig_bindir - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name - Gem::ConfigMap[:EXEEXT] = orig_exe_ext + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_path_without_spaces orig_ruby = Gem.ruby - orig_bindir = Gem::ConfigMap[:bindir] - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name] - orig_exe_ext = Gem::ConfigMap[:EXEEXT] + orig_bindir = RbConfig::CONFIG['bindir'] + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - Gem::ConfigMap[:bindir] = "C:/Ruby18/bin" - Gem::ConfigMap[:ruby_install_name] = "ruby" - Gem::ConfigMap[:EXEEXT] = ".exe" + RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" + RbConfig::CONFIG['ruby_install_name'] = "ruby" + RbConfig::CONFIG['EXEEXT'] = ".exe" Gem.instance_variable_set("@ruby", nil) assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby ensure Gem.instance_variable_set("@ruby", orig_ruby) - Gem::ConfigMap[:bindir] = orig_bindir - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name - Gem::ConfigMap[:EXEEXT] = orig_exe_ext + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_api_version - orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1' - orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2' - orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3' + orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3' Gem.instance_variable_set :@ruby_api_version, nil @@ -671,9 +675,7 @@ def test_self_ruby_api_version ensure Gem.instance_variable_set :@ruby_api_version, nil - Gem::ConfigMap[:MAJOR] = orig_MAJOR - Gem::ConfigMap[:MINOR] = orig_MINOR - Gem::ConfigMap[:TEENY] = orig_TEENY + RbConfig::CONFIG['ruby_version'] = orig_ruby_version end def test_self_ruby_version_1_8_5 @@ -825,7 +827,7 @@ def test_self_use_paths def test_self_user_dir parts = [@userhome, '.gem', Gem.ruby_engine] - parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty? + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? assert_equal File.join(parts), Gem.user_dir end @@ -857,6 +859,7 @@ def test_self_needs end def test_self_needs_picks_up_unresolved_deps + skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7" save_loaded_features do util_clear_gems a = util_spec "a", "1" @@ -949,6 +952,7 @@ def test_self_user_home_user_drive_and_path end def test_load_plugins + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" plugin_path = File.join "lib", "rubygems_plugin.rb" Dir.chdir @tempdir do @@ -1102,6 +1106,7 @@ def test_auto_activation_of_specific_gemdeps_file end def test_auto_activation_of_detected_gemdeps_file + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" util_clear_gems a = new_spec "a", "1", nil, "lib/a.rb" @@ -1264,6 +1269,7 @@ def test_use_gemdeps end def test_use_gemdeps_automatic + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' spec = util_spec 'a', 1 @@ -1300,6 +1306,7 @@ def test_use_gemdeps_disabled end def test_use_gemdeps_specific + skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7" rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x' spec = util_spec 'a', 1 @@ -1317,6 +1324,19 @@ def test_use_gemdeps_specific ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps end + def ruby_install_name name + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['ruby_install_name'] = name + + yield + ensure + if orig_RUBY_INSTALL_NAME then + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + else + RbConfig::CONFIG.delete 'ruby_install_name' + end + end + def with_plugin(path) test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}", @@project_dir) diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb index d87e84fc829fc0..7f5cf22223cff5 100644 --- a/test/rubygems/test_gem_commands_contents_command.rb +++ b/test/rubygems/test_gem_commands_contents_command.rb @@ -169,9 +169,9 @@ def test_execute_default_gem end expected = [ - File.join(Gem::ConfigMap[:bindir], 'default_command'), - File.join(Gem::ConfigMap[:rubylibdir], 'default/gem.rb'), - File.join(Gem::ConfigMap[:archdir], 'default_gem.so') + File.join(RbConfig::CONFIG['bindir'], 'default_command'), + File.join(RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'), + File.join(RbConfig::CONFIG['archdir'], 'default_gem.so') ].sort.join "\n" assert_equal expected, @ui.output.chomp diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb index 253c459d942840..bb7589f50de1c3 100644 --- a/test/rubygems/test_gem_commands_environment_command.rb +++ b/test/rubygems/test_gem_commands_environment_command.rb @@ -26,7 +26,7 @@ def test_execute assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|, @ui.output assert_match %r|RUBYGEMS PREFIX: |, @ui.output - assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:ruby_install_name]}|, + assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|, @ui.output assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 00bbf7bae7eca2..6315cb5d95b5ed 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -316,6 +316,7 @@ def test_execute_prerelease_skipped_when_non_pre_available end def test_execute_rdoc + skip if RUBY_VERSION <= "1.8.7" specs = spec_fetcher do |fetcher| fetcher.gem 'a', 2 end @@ -559,6 +560,20 @@ def test_install_gem_ignore_dependencies_remote assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name } end + def test_install_gem_ignore_dependencies_specific_file + spec = quick_spec 'a', 2 + + util_build_gem spec + + FileUtils.mv spec.cache_file, @tempdir + + @cmd.options[:ignore_dependencies] = true + + @cmd.install_gem File.join(@tempdir, spec.file_name), nil + + assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name } + end + def test_parses_requirement_from_gemname spec_fetcher do |fetcher| fetcher.gem 'a', 2 diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index 7537c1c9c10532..d259383ba2fbb2 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -217,6 +217,7 @@ def test_execute_dependencies end def test_execute_rdoc + skip if RUBY_VERSION <= "1.8.7" spec_fetcher do |fetcher| fetcher.gem 'a', 2 @@ -239,7 +240,6 @@ def test_execute_rdoc a2 = @specs['a-2'] - assert_path_exists File.join(a2.doc_dir, 'ri') assert_path_exists File.join(a2.doc_dir, 'rdoc') end diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index 0a82fa63cbbd19..352ebbb54ff513 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -551,7 +551,7 @@ def test_install_env_shebang env = "/\\S+/env" unless Gem.win_platform? - assert_match %r|\A#!#{env} #{Gem::ConfigMap[:ruby_install_name]}\n|, + assert_match %r|\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n|, File.read(File.join(@gemhome, 'bin', 'a_bin')) end diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb index aa9008c7937d69..367c933a4cd6ad 100644 --- a/test/rubygems/test_gem_ext_ext_conf_builder.rb +++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb @@ -42,47 +42,46 @@ def test_class_build end def test_class_build_rbconfig_make_prog - configure_args = RbConfig::CONFIG['configure_args'] + configure_args do - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| - extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" - end + File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" + end - output = [] + output = [] - Dir.chdir @ext do - Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output - end + Dir.chdir @ext do + Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output + end - assert_equal "creating Makefile\n", output[1] - assert_contains_make_command 'clean', output[2] - assert_contains_make_command '', output[4] - assert_contains_make_command 'install', output[6] - ensure - RbConfig::CONFIG['configure_args'] = configure_args + assert_equal "creating Makefile\n", output[1] + assert_contains_make_command 'clean', output[2] + assert_contains_make_command '', output[4] + assert_contains_make_command 'install', output[6] + end end def test_class_build_env_make - configure_args, env_make = RbConfig::CONFIG['configure_args'], ENV.delete('make') - RbConfig::CONFIG['configure_args'] = '' + env_make = ENV.delete 'make' ENV['make'] = 'anothermake' - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| - extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" - end + configure_args '' do + File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" + end - output = [] + output = [] - assert_raises Gem::InstallError do - Dir.chdir @ext do - Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output + assert_raises Gem::InstallError do + Dir.chdir @ext do + Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output + end end - end - assert_equal "creating Makefile\n", output[1] - assert_contains_make_command 'clean', output[2] + assert_equal "creating Makefile\n", output[1] + assert_contains_make_command 'clean', output[2] + end ensure - RbConfig::CONFIG['configure_args'] = configure_args ENV['make'] = env_make end @@ -108,6 +107,7 @@ def test_class_build_extconf_fail assert_equal 'extconf failed, exit code 1', error.message assert_equal("#{Gem.ruby} extconf.rb", output[0]) + assert_path_exists File.join @dest_path, 'mkmf.log' end def test_class_build_unconventional @@ -188,5 +188,19 @@ def test_class_make_no_Makefile assert_equal 'Makefile not found', error.message end + def configure_args args = nil + configure_args = RbConfig::CONFIG['configure_args'] + RbConfig::CONFIG['configure_args'] = args if args + + yield + + ensure + if configure_args then + RbConfig::CONFIG['configure_args'] = configure_args + else + RbConfig::CONFIG.delete 'configure_args' + end + end + end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 615a9b57ba4afa..eff62ab28b2886 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -41,7 +41,7 @@ def test_app_script_text if ARGV.first str = ARGV.first str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding - if str =~ /\\A_(.*)_\\z/ + if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then version = $1 ARGV.shift end @@ -84,8 +84,8 @@ def test_check_executable_overwrite_default_bin_dir orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION Object.send :remove_const, :RUBY_FRAMEWORK_VERSION end - orig_bindir = Gem::ConfigMap[:bindir] - Gem::ConfigMap[:bindir] = Gem.bindir + orig_bindir = RbConfig::CONFIG['bindir'] + RbConfig::CONFIG['bindir'] = Gem.bindir util_conflict_executable false @@ -102,7 +102,11 @@ def test_check_executable_overwrite_default_bin_dir ensure Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if orig_RUBY_FRAMEWORK_VERSION - Gem::ConfigMap[:bindir] = orig_bindir + if orig_bindir then + RbConfig::CONFIG['bindir'] = orig_bindir + else + RbConfig::CONFIG.delete 'bindir' + end end def test_check_executable_overwrite_format_executable @@ -1192,7 +1196,7 @@ def test_shebang_env_shebang env_shebang = "/usr/bin/env" unless Gem.win_platform? - assert_equal("#!#{env_shebang} #{Gem::ConfigMap[:ruby_install_name]}", + assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}", shebang) end diff --git a/test/rubygems/test_gem_package_tar_header.rb b/test/rubygems/test_gem_package_tar_header.rb index 5d855435ec69f9..8f1f0c45619679 100644 --- a/test/rubygems/test_gem_package_tar_header.rb +++ b/test/rubygems/test_gem_package_tar_header.rb @@ -72,6 +72,20 @@ def test_initialize_bad end end + def test_initialize_typeflag + header = { + :mode => '', + :name => '', + :prefix => '', + :size => '', + :typeflag => '', + } + + tar_header = Gem::Package::TarHeader.new header + + assert_equal '0', tar_header.typeflag + end + def test_empty_eh refute_empty @tar_header diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb index 5966710dad30b5..17577dc744a8de 100644 --- a/test/rubygems/test_gem_platform.rb +++ b/test/rubygems/test_gem_platform.rb @@ -116,7 +116,11 @@ def test_initialize_mswin32_vc6 assert_equal expected, platform.to_a, 'i386-mswin32 VC6' ensure - RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME + if orig_RUBY_SO_NAME then + RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME + else + RbConfig::CONFIG.delete 'RUBY_SO_NAME' + end end def test_initialize_platform diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index 7e6d9c76934881..79f3a58bfb07ef 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -208,15 +208,15 @@ def util_fuck_with_fetcher data, blow = false fetcher.instance_variable_set :@test_data, data unless blow then - def fetcher.fetch_path arg + def fetcher.fetch_path arg, *rest @test_arg = arg @test_data end else - def fetcher.fetch_path arg + def fetcher.fetch_path arg, *rest # OMG I'm such an ass class << self; remove_method :fetch_path; end - def self.fetch_path arg + def self.fetch_path arg, *rest @test_arg = arg @test_data end diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb index 04ff50786f85c3..bcbbcf1f99ef6e 100644 --- a/test/rubygems/test_gem_request.rb +++ b/test/rubygems/test_gem_request.rb @@ -1,9 +1,16 @@ require 'rubygems/test_case' require 'rubygems/request' require 'ostruct' +require 'base64' class TestGemRequest < Gem::TestCase + CA_CERT_FILE = cert_path 'ca' + CHILD_CERT = load_cert 'child' + PUBLIC_CERT = load_cert 'public' + PUBLIC_CERT_FILE = cert_path 'public' + SSL_CERT = load_cert 'ssl' + def setup @proxies = %w[http_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY] @old_proxies = @proxies.map {|k| ENV[k] } @@ -62,6 +69,44 @@ def test_initialize_proxy_ENV_https assert_equal URI(@proxy_uri), proxy end + def test_configure_connection_for_https + connection = Net::HTTP.new 'localhost', 443 + + request = Gem::Request.new URI('https://example'), nil, nil, nil + + def request.add_rubygems_trusted_certs store + store.add_cert TestGemRequest::PUBLIC_CERT + end + + request.configure_connection_for_https connection + + cert_store = connection.cert_store + + assert cert_store.verify CHILD_CERT + end + + def test_configure_connection_for_https_ssl_ca_cert + ssl_ca_cert, Gem.configuration.ssl_ca_cert = + Gem.configuration.ssl_ca_cert, CA_CERT_FILE + + connection = Net::HTTP.new 'localhost', 443 + + request = Gem::Request.new URI('https://example'), nil, nil, nil + + def request.add_rubygems_trusted_certs store + store.add_cert TestGemRequest::PUBLIC_CERT + end + + request.configure_connection_for_https connection + + cert_store = connection.cert_store + + assert cert_store.verify CHILD_CERT + assert cert_store.verify SSL_CERT + ensure + Gem.configuration.ssl_ca_cert = ssl_ca_cert + end + def test_get_proxy_from_env_fallback ENV['http_proxy'] = @proxy_uri @@ -124,6 +169,30 @@ def test_fetch assert_equal :junk, response.body end + def test_fetch_basic_auth + uri = URI.parse "https://user:pass@example.rubygems/specs.#{Gem.marshal_version}" + @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil) + conn = util_stub_connection_for :body => :junk, :code => 200 + + @request.fetch + + auth_header = conn.payload['Authorization'] + + assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header + end + + def test_fetch_basic_auth_encoded + uri = URI.parse "https://user:%7BDEScede%7Dpass@example.rubygems/specs.#{Gem.marshal_version}" + @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil) + conn = util_stub_connection_for :body => :junk, :code => 200 + + @request.fetch + + auth_header = conn.payload['Authorization'] + + assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header + end + def test_fetch_head uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}" @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil) diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb index 82757958c82517..a5fcdcc2fb31f7 100644 --- a/test/rubygems/test_gem_request_set.rb +++ b/test/rubygems/test_gem_request_set.rb @@ -59,6 +59,8 @@ def test_install_from_gemdeps assert_includes installed, 'a-2' assert_path_exists File.join @gemhome, 'gems', 'a-2' assert_path_exists 'gem.deps.rb.lock' + + assert rs.remote end def test_install_from_gemdeps_install_dir @@ -89,6 +91,25 @@ def test_install_from_gemdeps_install_dir refute_path_exists File.join Gem.dir, 'gems', 'a-2' end + def test_install_from_gemdeps_local + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end + + rs = Gem::RequestSet.new + + open 'gem.deps.rb', 'w' do |io| + io.puts 'gem "a"' + io.flush + + assert_raises Gem::UnsatisfiableDependencyError do + rs.install_from_gemdeps :gemdeps => io.path, :domain => :local + end + end + + refute rs.remote + end + def test_install_from_gemdeps_lockfile spec_fetcher do |fetcher| fetcher.gem 'a', 1 diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb index 9e0cab4d1a8f79..0be69bf92b30d4 100644 --- a/test/rubygems/test_gem_request_set_lockfile.rb +++ b/test/rubygems/test_gem_request_set_lockfile.rb @@ -218,6 +218,7 @@ def test_parse_gem_specs_dependency c (~> 4) d e (~> 5.0, >= 5.0.1) + b (3-x86_64-linux) PLATFORMS #{Gem::Platform::RUBY} @@ -238,7 +239,14 @@ def test_parse_gem_specs_dependency assert lockfile_set, 'could not find a LockSet' - assert_equal %w[a-2], lockfile_set.specs.map { |tuple| tuple.full_name } + assert_equal %w[a-2 b-3], lockfile_set.specs.map { |tuple| tuple.full_name } + + expected = [ + Gem::Platform::RUBY, + Gem::Platform.new('x86_64-linux'), + ] + + assert_equal expected, lockfile_set.specs.map { |tuple| tuple.platform } spec = lockfile_set.specs.first diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb index 7d3311c14ce47a..c97e9e710cc0b4 100644 --- a/test/rubygems/test_gem_resolver.rb +++ b/test/rubygems/test_gem_resolver.rb @@ -33,6 +33,14 @@ def test_self_compatibility assert_same Gem::Resolver, Gem::DependencyResolver end + def test_self_compose_sets_best_set + best_set = @DR::BestSet.new + + composed = @DR.compose_sets best_set + + assert_equal best_set, composed + end + def test_self_compose_sets_multiple index_set = @DR::IndexSet.new vendor_set = @DR::VendorSet.new diff --git a/test/rubygems/test_gem_resolver_api_set.rb b/test/rubygems/test_gem_resolver_api_set.rb index 288f496c931ff8..245f6c1d24cad2 100644 --- a/test/rubygems/test_gem_resolver_api_set.rb +++ b/test/rubygems/test_gem_resolver_api_set.rb @@ -17,6 +17,14 @@ def test_initialize assert_equal Gem::Source.new(URI('https://rubygems.org')), set.source end + def test_initialize_deeper_uri + set = @DR::APISet.new 'https://rubygemsserver.com/mygems/api/v1/dependencies' + + assert_equal URI('https://rubygemsserver.com/mygems/api/v1/dependencies'), set.dep_uri + assert_equal URI('https://rubygemsserver.com/mygems/'), set.uri + assert_equal Gem::Source.new(URI('https://rubygemsserver.com/mygems/')), set.source + end + def test_initialize_uri set = @DR::APISet.new @dep_uri @@ -74,6 +82,15 @@ def test_find_all_cache assert_equal expected, set.find_all(a_dep) end + def test_find_all_local + set = @DR::APISet.new @dep_uri + set.remote = false + + a_dep = @DR::DependencyRequest.new dep('a'), nil + + assert_empty set.find_all(a_dep) + end + def test_find_all_missing spec_fetcher @@ -163,5 +180,29 @@ def test_prefetch_cache_missing set.prefetch [a_dep, b_dep] end + def test_prefetch_local + spec_fetcher + + data = [ + { :name => 'a', + :number => '1', + :platform => 'ruby', + :dependencies => [], }, + ] + + @fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data + @fetcher.data["#{@dep_uri}?gems=b"] = Marshal.dump [] + + set = @DR::APISet.new @dep_uri + set.remote = false + + a_dep = @DR::DependencyRequest.new dep('a'), nil + b_dep = @DR::DependencyRequest.new dep('b'), nil + + set.prefetch [a_dep, b_dep] + + assert_empty set.instance_variable_get :@data + end + end diff --git a/test/rubygems/test_gem_resolver_best_set.rb b/test/rubygems/test_gem_resolver_best_set.rb index 5bcff4aca7d66e..2d16f8b701a88b 100644 --- a/test/rubygems/test_gem_resolver_best_set.rb +++ b/test/rubygems/test_gem_resolver_best_set.rb @@ -8,6 +8,12 @@ def setup @DR = Gem::Resolver end + def test_initialize + set = @DR::BestSet.new + + assert_empty set.sets + end + def test_find_all_index spec_fetcher do |fetcher| fetcher.spec 'a', 1 @@ -26,5 +32,49 @@ def test_find_all_index assert_equal %w[a-1], found.map { |s| s.full_name } end + def test_find_all_local + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'b', 1 + end + + set = @DR::BestSet.new + set.remote = false + + dependency = dep 'a', '~> 1' + + req = @DR::DependencyRequest.new dependency, nil + + found = set.find_all req + + assert_empty found + end + + def test_prefetch + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + end + + set = @DR::BestSet.new + + set.prefetch [] + + refute_empty set.sets + end + + def test_prefetch_local + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + end + + set = @DR::BestSet.new + set.remote = false + + set.prefetch [] + + assert_empty set.sets + end + end diff --git a/test/rubygems/test_gem_resolver_git_set.rb b/test/rubygems/test_gem_resolver_git_set.rb index 4643624ee02eaa..f82b9427775ba7 100644 --- a/test/rubygems/test_gem_resolver_git_set.rb +++ b/test/rubygems/test_gem_resolver_git_set.rb @@ -70,6 +70,21 @@ def test_find_all assert_equal [@set.specs['a']], found end + def test_find_all_local + name, _, repository, = git_gem + + @set.add_git_gem name, repository, 'master', false + @set.remote = false + + dependency = dep 'a', '~> 1.0' + req = Gem::Resolver::DependencyRequest.new dependency, nil + @reqs.add req + + @set.prefetch @reqs + + assert_empty @set.find_all dependency + end + def test_root_dir assert_equal Gem.dir, @set.root_dir diff --git a/test/rubygems/test_gem_resolver_index_set.rb b/test/rubygems/test_gem_resolver_index_set.rb index 137e9b5cacabec..b0adc511c997e1 100644 --- a/test/rubygems/test_gem_resolver_index_set.rb +++ b/test/rubygems/test_gem_resolver_index_set.rb @@ -24,5 +24,40 @@ def test_initialize_source refute_same Gem::SpecFetcher.fetcher, fetcher end + def test_find_all + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'b', 1 + end + + set = @DR::BestSet.new + + dependency = dep 'a', '~> 1' + + req = @DR::DependencyRequest.new dependency, nil + + found = set.find_all req + + assert_equal %w[a-1], found.map { |s| s.full_name } + end + + def test_find_all_local + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'b', 1 + end + + set = @DR::BestSet.new + set.remote = false + + dependency = dep 'a', '~> 1' + + req = @DR::DependencyRequest.new dependency, nil + + assert_empty set.find_all req + end + end diff --git a/test/rubygems/test_gem_resolver_installer_set.rb b/test/rubygems/test_gem_resolver_installer_set.rb index af4db646a9ddeb..258f9bc8034669 100644 --- a/test/rubygems/test_gem_resolver_installer_set.rb +++ b/test/rubygems/test_gem_resolver_installer_set.rb @@ -2,6 +2,34 @@ class TestGemResolverInstallerSet < Gem::TestCase + def test_consider_local_eh + set = Gem::Resolver::InstallerSet.new :remote + + refute set.consider_local? + + set = Gem::Resolver::InstallerSet.new :both + + assert set.consider_local? + + set = Gem::Resolver::InstallerSet.new :local + + assert set.consider_local? + end + + def test_consider_remote_eh + set = Gem::Resolver::InstallerSet.new :remote + + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :both + + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :local + + refute set.consider_remote? + end + def test_load_spec specs = spec_fetcher do |fetcher| fetcher.spec 'a', 2 @@ -18,5 +46,47 @@ def test_load_spec assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name end + def test_remote_equals_both + set = Gem::Resolver::InstallerSet.new :both + set.remote = true + + assert set.consider_local? + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :both + set.remote = false + + assert set.consider_local? + refute set.consider_remote? + end + + def test_remote_equals_local + set = Gem::Resolver::InstallerSet.new :local + set.remote = true + + assert set.consider_local? + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :local + set.remote = false + + assert set.consider_local? + refute set.consider_remote? + end + + def test_remote_equals_remote + set = Gem::Resolver::InstallerSet.new :remote + set.remote = true + + refute set.consider_local? + assert set.consider_remote? + + set = Gem::Resolver::InstallerSet.new :remote + set.remote = false + + refute set.consider_local? + refute set.consider_remote? + end + end diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb index 026492ece02efa..58bff844906c1b 100644 --- a/test/rubygems/test_gem_source_git.rb +++ b/test/rubygems/test_gem_source_git.rb @@ -27,6 +27,26 @@ def test_checkout assert_path_exists File.join @source.install_dir, 'a.gemspec' end + def test_checkout_local + @source.remote = false + + @source.checkout + + install_dir = File.join Gem.dir, 'bundler', 'gems', "a-#{@head[0..11]}" + + refute_path_exists File.join install_dir, 'a.gemspec' + end + + def test_checkout_local_cached + @source.cache + + @source.remote = false + + @source.checkout + + assert_path_exists File.join @source.install_dir, 'a.gemspec' + end + def test_checkout_submodules source = Gem::Source::Git.new @name, @repository, 'master', true @@ -54,6 +74,14 @@ def test_cache end end + def test_cache_local + @source.remote = false + + @source.cache + + refute_path_exists @source.repo_cache_dir + end + def test_dir_shortref @source.cache @@ -99,6 +127,12 @@ def test_install_dir assert_equal expected, @source.install_dir end + def test_install_dir_local + @source.remote = false + + assert_nil @source.install_dir + end + def test_repo_cache_dir expected = File.join Gem.dir, 'cache', 'bundler', 'git', "a-#{@hash}" @@ -211,6 +245,15 @@ def test_specs assert_equal extension_dir, b_spec.extension_dir end + def test_specs_local + source = Gem::Source::Git.new @name, @repository, 'master', true + source.remote = false + + capture_io do + assert_empty source.specs + end + end + def test_uri_hash assert_equal @hash, @source.uri_hash diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 7aa9d5aeb17a4a..1afb5ba247c414 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -999,8 +999,8 @@ def test_initialize_copy assert_equal 'summary', spec.summary assert_same spec.summary, new_spec.summary - assert_equal %w[lib/file.rb test/file.rb bin/exec README.txt - ext/extconf.rb].sort, + assert_equal %w[README.txt bin/exec ext/extconf.rb lib/file.rb + test/file.rb].sort, spec.files refute_same spec.files, new_spec.files, 'files' @@ -1109,7 +1109,31 @@ def test_bindir_equals_nil @a2.executable = 'app' assert_equal nil, @a2.bindir - assert_equal %w[lib/code.rb app].sort, @a2.files + assert_equal %w[app lib/code.rb].sort, @a2.files + end + + def test_extensions_equals_nil + @a2.instance_variable_set(:@extensions, nil) + assert_equal nil, @a2.instance_variable_get(:@extensions) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_test_files_equals_nil + @a2.instance_variable_set(:@test_files, nil) + assert_equal nil, @a2.instance_variable_get(:@test_files) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_executables_equals_nil + @a2.instance_variable_set(:@executables, nil) + assert_equal nil, @a2.instance_variable_get(:@executables) + assert_equal %w[lib/code.rb], @a2.files + end + + def test_extra_rdoc_files_equals_nil + @a2.instance_variable_set(:@extra_rdoc_files, nil) + assert_equal nil, @a2.instance_variable_get(:@extra_rdoc_files) + assert_equal %w[lib/code.rb], @a2.files end def test_build_extensions @@ -1437,7 +1461,7 @@ def test_executables def test_executable_equals @a2.executable = 'app' assert_equal 'app', @a2.executable - assert_equal %w[lib/code.rb bin/app].sort, @a2.files + assert_equal %w[bin/app lib/code.rb].sort, @a2.files end def test_extensions @@ -1765,26 +1789,39 @@ def test_prerelease_spec_adds_required_rubygems_version end def test_require_paths - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] = - RbConfig::CONFIG['ENABLE_SHARED'], 'no' + enable_shared 'no' do + ext_spec - ext_spec - - @ext.require_path = 'lib' + @ext.require_path = 'lib' - ext_install_dir = Pathname(@ext.extension_dir) - full_gem_path = Pathname(@ext.full_gem_path) - relative_install_dir = ext_install_dir.relative_path_from full_gem_path + ext_install_dir = Pathname(@ext.extension_dir) + full_gem_path = Pathname(@ext.full_gem_path) + relative_install_dir = ext_install_dir.relative_path_from full_gem_path - assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths - ensure - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths + end end def test_source assert_kind_of Gem::Source::Installed, @a1.source end + def test_source_paths + ext_spec + + @ext.require_paths = %w[lib ext foo] + @ext.extensions << 'bar/baz' + + expected = %w[ + lib + ext + foo + bar + ] + + assert_equal expected, @ext.source_paths + end + def test_full_require_paths ext_spec @@ -2435,7 +2472,7 @@ def test_validate_files assert_equal '["lib2"] are not files', e.message end - assert_equal %w[lib/code.rb test/suite.rb bin/exec ext/a/extconf.rb lib2].sort, + assert_equal %w[bin/exec ext/a/extconf.rb lib/code.rb lib2 test/suite.rb].sort, @a1.files end @@ -2911,9 +2948,9 @@ def util_setup_validate def with_syck begin + verbose, $VERBOSE = $VERBOSE, nil require "yaml" old_engine = YAML::ENGINE.yamler - verbose, $VERBOSE = $VERBOSE, nil YAML::ENGINE.yamler = 'syck' load 'rubygems/syck_hack.rb' rescue NameError diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 1eea30fb9403d6..11fdaf68e22118 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -131,6 +131,23 @@ def test_remove_executables_user_format_disabled Gem::Installer.exec_format = nil end + def test_remove_not_in_home + uninstaller = Gem::Uninstaller.new nil, :install_dir => "#{@gemhome}2" + + e = assert_raises Gem::GemNotInHomeException do + use_ui ui do + uninstaller.remove @spec + end + end + + expected = + "Gem '#{@spec.full_name}' is not installed in directory #{@gemhome}2" + + assert_equal expected, e.message + + assert_path_exists @spec.gem_dir + end + def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb index e0499fe73f9783..5a65b5c9c7b506 100644 --- a/test/rubygems/test_gem_version.rb +++ b/test/rubygems/test_gem_version.rb @@ -3,6 +3,9 @@ class TestGemVersion < Gem::TestCase + class V < ::Gem::Version + end + def test_bump assert_bumped_version_equal "5.3", "5.2.4" end @@ -37,6 +40,13 @@ def test_class_create assert_equal v('1.1'), Gem::Version.create(ver) end + def test_class_new_subclass + v1 = Gem::Version.new '1' + v2 = V.new '1' + + refute_same v1, v2 + end + def test_eql_eh assert_version_eql "1.2", "1.2" refute_version_eql "1.2", "1.2.0" diff --git a/version.h b/version.h index ffd78c8e59fe29..e3174fd8e53b32 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-06" -#define RUBY_PATCHLEVEL 25 +#define RUBY_PATCHLEVEL 26 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 1ef33a5cb6bcbc56d6bfac165fe890fecd7b87d4 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 07:24:46 +0000 Subject: [PATCH 29/83] merge revision(s) 44852: [Backport #9343] * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and limit wakeups. [Bug #9343][ruby-core:60517] * test/thread/test_queue.rb (test_sized_queue_assign_max): test for bug git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/thread/thread.c | 2 +- test/thread/test_queue.rb | 7 +++++++ version.h | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 86fbbe34019209..66ef0e4b6b2c90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Feb 6 08:23:28 2014 Eric Wong + + * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and + limit wakeups. [Bug #9343][ruby-core:60517] + * test/thread/test_queue.rb (test_sized_queue_assign_max): + test for bug + Thu Feb 6 11:27:39 2014 Eric Hodel * lib/rubygems: RubyGems 2.2.2 which contains the following bug fixes: diff --git a/ext/thread/thread.c b/ext/thread/thread.c index 208d1172dfb3ab..a8f675c55ba309 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -437,7 +437,7 @@ rb_szqueue_max_set(VALUE self, VALUE vmax) diff = max - GET_SZQUEUE_ULONGMAX(self); } RSTRUCT_SET(self, SZQUEUE_MAX, vmax); - while (diff > 0 && !NIL_P(t = rb_ary_shift(GET_QUEUE_QUE(self)))) { + while (diff-- > 0 && !NIL_P(t = rb_ary_shift(GET_SZQUEUE_WAITERS(self)))) { rb_thread_wakeup_alive(t); } return vmax; diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 438e1e75e3edd4..2126500bd81d70 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -55,6 +55,13 @@ def test_sized_queue_assign_max assert_equal(1, q.max) assert_raise(ArgumentError) { q.max = -1 } assert_equal(1, q.max) + + before = q.max + q.max.times { q << 1 } + t1 = Thread.new { q << 1 } + sleep 0.01 until t1.stop? + q.max = q.max + 1 + assert_equal before + 1, q.max end def test_queue_pop_interrupt diff --git a/version.h b/version.h index e3174fd8e53b32..d4e9771d69bf78 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-06" -#define RUBY_PATCHLEVEL 26 +#define RUBY_PATCHLEVEL 27 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 3557554a5080275fefc9c2d111f11df3e01aed92 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 18:11:13 +0000 Subject: [PATCH 30/83] Add missing file of r44858 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- .../rubygems/test_gem_resolver_composed_set.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/rubygems/test_gem_resolver_composed_set.rb diff --git a/test/rubygems/test_gem_resolver_composed_set.rb b/test/rubygems/test_gem_resolver_composed_set.rb new file mode 100644 index 00000000000000..85026f7eb98f95 --- /dev/null +++ b/test/rubygems/test_gem_resolver_composed_set.rb @@ -0,0 +1,18 @@ +require 'rubygems/test_case' + +class TestGemResolverComposedSet < Gem::TestCase + + def test_remote_equals + best_set = Gem::Resolver::BestSet.new + current_set = Gem::Resolver::CurrentSet.new + + set = Gem::Resolver::ComposedSet.new best_set, current_set + + set.remote = false + + refute best_set.remote? + refute current_set.remote? + end + +end + From 7895c200fb47315c864f8ffe2124f6e7129d587b Mon Sep 17 00:00:00 2001 From: svn Date: Thu, 6 Feb 2014 18:11:17 +0000 Subject: [PATCH 31/83] * 2014-02-07 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index d4e9771d69bf78..d24a723923a949 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-06" +#define RUBY_RELEASE_DATE "2014-02-07" #define RUBY_PATCHLEVEL 27 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 7 #include "ruby/version.h" From 783bcdacaebbf4e846e1796e80e6ff7277840e2d Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 6 Feb 2014 19:21:40 +0000 Subject: [PATCH 32/83] merge revision(s) 44861,44862: [Backport #9493] * gc.c (get_envparam_int): don't accept a value equals to lowerbound (changed by last commit) because "" or "foo" (not a number) strings are parsed as 0. They should be rejected. * gc.c (get_envparam_double): ditto. * gc.c (get_envparam_int): accept a value equals to lowerbound. * gc.c (get_envparam_int): correct warning messsages. * gc.c (get_envparam_double): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 16 +++++++++++++++- gc.c | 10 +++++----- version.h | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66ef0e4b6b2c90..7f7d3e092c1ab0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri Feb 7 04:19:19 2014 Koichi Sasada + + * gc.c (get_envparam_int): correct warning messsages. + + * gc.c (get_envparam_double): ditto. + +Fri Feb 7 04:19:19 2014 Koichi Sasada + + * gc.c (get_envparam_int): don't accept a value equals to lowerbound + (changed by last commit) because "" or "foo" (not a number) strings + are parsed as 0. They should be rejected. + + * gc.c (get_envparam_double): ditto. + Thu Feb 6 08:23:28 2014 Eric Wong * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and @@ -18,7 +32,7 @@ Thu Feb 6 11:23:59 2014 Koichi Sasada Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT does not work. - * gc.c (get_envparam_int): accept a value equals to lowerbounds. + * gc.c (get_envparam_int): accept a value equals to lowerbound. * gc.c (get_envparam_double): ditto. diff --git a/gc.c b/gc.c index e51b727ecd5f84..1d182310e0f066 100644 --- a/gc.c +++ b/gc.c @@ -5649,13 +5649,13 @@ get_envparam_int(const char *name, unsigned int *default_value, int lower_bound) if (ptr != NULL) { val = atoi(ptr); - if (val >= lower_bound) { - if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (%d)\n", name, val, *default_value); + if (val > lower_bound) { + if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (default value: %d)\n", name, val, *default_value); *default_value = val; return 1; } else { - if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (%d), but ignored because lower than %d\n", name, val, *default_value, lower_bound); + if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (default value: %d) is ignored because it must be greater than %d.\n", name, val, *default_value, lower_bound); } } return 0; @@ -5669,13 +5669,13 @@ get_envparam_double(const char *name, double *default_value, double lower_bound) if (ptr != NULL) { val = strtod(ptr, NULL); - if (val >= lower_bound) { + if (val > lower_bound) { if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (%f)\n", name, val, *default_value); *default_value = val; return 1; } else { - if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (%f), but ignored because lower than %f\n", name, val, *default_value, lower_bound); + if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be greater than %f.\n", name, val, *default_value, lower_bound); } } return 0; diff --git a/version.h b/version.h index d24a723923a949..1f780eb14d11f5 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-07" -#define RUBY_PATCHLEVEL 27 +#define RUBY_PATCHLEVEL 28 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From a21d16ce12dfe6a270e4229e7067c2a155ab728b Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 10 Feb 2014 11:45:14 +0000 Subject: [PATCH 33/83] merge revision(s) 44572,44578,44591,44592: [Backport #9490] ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUE git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/dl/cptr.c | 5 ++-- ext/fiddle/pointer.c | 6 ++-- ext/openssl/ossl.c | 18 +++++++----- ext/pty/pty.c | 6 ++-- ext/strscan/strscan.c | 61 ++++++++++++++++++----------------------- ext/tk/tcltklib.c | 7 ++--- ext/win32ole/win32ole.c | 11 ++++---- ext/zlib/zlib.c | 7 ++--- version.h | 6 ++-- 9 files changed, 58 insertions(+), 69 deletions(-) diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index 9e59139fc9d0a0..3f8858c4b37c2e 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -391,9 +391,8 @@ rb_dlptr_inspect(VALUE self) char str[1024]; TypedData_Get_Struct(self, struct ptr_data, &dlptr_data_type, data); - snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>", - rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free); - return rb_str_new2(str); + return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>", + rb_obj_class(self), data, data->ptr, data->size, data->free); } /* diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c index 4f4842fc334d53..0129363a8df2de 100644 --- a/ext/fiddle/pointer.c +++ b/ext/fiddle/pointer.c @@ -427,12 +427,10 @@ static VALUE rb_fiddle_ptr_inspect(VALUE self) { struct ptr_data *data; - char str[1024]; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); - snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>", - rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free); - return rb_str_new2(str); + return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>", + rb_obj_class(self), data, data->ptr, data->size, data->free); } /* diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 43ccf4c3fdf7fe..3961d3ea33424c 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -293,10 +293,9 @@ ossl_to_der_if_possible(VALUE obj) static VALUE ossl_make_error(VALUE exc, const char *fmt, va_list args) { - char buf[BUFSIZ]; + VALUE str = Qnil; const char *msg; long e; - int len = 0; #ifdef HAVE_ERR_PEEK_LAST_ERROR e = ERR_peek_last_error(); @@ -304,14 +303,19 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args) e = ERR_peek_error(); #endif if (fmt) { - len = vsnprintf(buf, BUFSIZ, fmt, args); + str = rb_vsprintf(fmt, args); } - if (len < BUFSIZ && e) { + if (e) { if (dOSSL == Qtrue) /* FULL INFO */ msg = ERR_error_string(e, NULL); else msg = ERR_reason_error_string(e); - len += snprintf(buf+len, BUFSIZ-len, "%s%s", (len ? ": " : ""), msg); + if (NIL_P(str)) { + str = rb_str_new_cstr(msg); + } + else { + rb_str_cat2(rb_str_cat2(str, ": "), msg); + } } if (dOSSL == Qtrue){ /* show all errors on the stack */ while ((e = ERR_get_error()) != 0){ @@ -320,8 +324,8 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args) } ERR_clear_error(); - if(len > BUFSIZ) len = rb_long2int(strlen(buf)); - return rb_exc_new(exc, buf, len); + if (NIL_P(str)) str = rb_str_new(0, 0); + return rb_exc_new3(exc, str); } void diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 4ba1cba6212b91..f54bbb52e58a91 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -613,7 +613,7 @@ static void raise_from_check(rb_pid_t pid, int status) { const char *state; - char buf[1024]; + VALUE msg; VALUE exc; #if defined(WIFSTOPPED) @@ -631,8 +631,8 @@ raise_from_check(rb_pid_t pid, int status) else { state = "exited"; } - snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)pid); - exc = rb_exc_new2(eChildExited, buf); + msg = rb_sprintf("pty - %s: %ld", state, (long)pid); + exc = rb_exc_new_str(eChildExited, msg); rb_iv_set(exc, "status", rb_last_status_get()); rb_exc_raise(exc); } diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index f020ba780dd8e4..ec983e1f5046e8 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -1155,76 +1155,69 @@ static VALUE strscan_inspect(VALUE self) { struct strscanner *p; - char buf[BUFSIZE]; - long len; VALUE a, b; p = check_strscan(self); if (NIL_P(p->str)) { - len = snprintf(buf, BUFSIZE, "#<%s (uninitialized)>", - rb_class2name(CLASS_OF(self))); - return infect(rb_str_new(buf, len), p); + a = rb_sprintf("#<%"PRIsVALUE" (uninitialized)>", rb_obj_class(self)); + return infect(a, p); } if (EOS_P(p)) { - len = snprintf(buf, BUFSIZE, "#<%s fin>", - rb_class2name(CLASS_OF(self))); - return infect(rb_str_new(buf, len), p); + a = rb_sprintf("#<%"PRIsVALUE" fin>", rb_obj_class(self)); + return infect(a, p); } if (p->curr == 0) { - b = inspect2(p); - len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld @ %s>", - rb_class2name(CLASS_OF(self)), - p->curr, S_LEN(p), - RSTRING_PTR(b)); - return infect(rb_str_new(buf, len), p); + b = inspect2(p); + a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld @ %"PRIsVALUE">", + rb_obj_class(self), + p->curr, S_LEN(p), + b); + return infect(a, p); } a = inspect1(p); b = inspect2(p); - len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld %s @ %s>", - rb_class2name(CLASS_OF(self)), - p->curr, S_LEN(p), - RSTRING_PTR(a), - RSTRING_PTR(b)); - return infect(rb_str_new(buf, len), p); + a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld %"PRIsVALUE" @ %"PRIsVALUE">", + rb_obj_class(self), + p->curr, S_LEN(p), + a, b); + return infect(a, p); } static VALUE inspect1(struct strscanner *p) { - char buf[BUFSIZE]; - char *bp = buf; + VALUE str; long len; if (p->curr == 0) return rb_str_new2(""); if (p->curr > INSPECT_LENGTH) { - strcpy(bp, "..."); bp += 3; - len = INSPECT_LENGTH; + str = rb_str_new_cstr("..."); + len = INSPECT_LENGTH; } else { - len = p->curr; + str = rb_str_new(0, 0); + len = p->curr; } - memcpy(bp, CURPTR(p) - len, len); bp += len; - return rb_str_dump(rb_str_new(buf, bp - buf)); + rb_str_cat(str, CURPTR(p) - len, len); + return rb_str_dump(str); } static VALUE inspect2(struct strscanner *p) { - char buf[BUFSIZE]; - char *bp = buf; + VALUE str; long len; if (EOS_P(p)) return rb_str_new2(""); len = S_LEN(p) - p->curr; if (len > INSPECT_LENGTH) { - len = INSPECT_LENGTH; - memcpy(bp, CURPTR(p), len); bp += len; - strcpy(bp, "..."); bp += 3; + str = rb_str_new(CURPTR(p), INSPECT_LENGTH); + rb_str_cat2(str, "..."); } else { - memcpy(bp, CURPTR(p), len); bp += len; + str = rb_str_new(CURPTR(p), len); } - return rb_str_dump(rb_str_new(buf, bp - buf)); + return rb_str_dump(str); } /* ======================================================================= diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index d269f9c43ed6f4..237462fc3b3894 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -848,15 +848,14 @@ create_ip_exc(interp, exc, fmt, va_alist) #endif { va_list args; - char buf[BUFSIZ]; + VALUE msg; VALUE einfo; struct tcltkip *ptr = get_ip(interp); va_init_list(args,fmt); - vsnprintf(buf, BUFSIZ, fmt, args); - buf[BUFSIZ - 1] = '\0'; + msg = rb_vsprintf(fmt, args); va_end(args); - einfo = rb_exc_new2(exc, buf); + einfo = rb_exc_new_str(exc, msg); rb_ivar_set(einfo, ID_at_interp, interp); if (ptr) { Tcl_ResetResult(ptr->ip); diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 9765929f345423..072638a10b5920 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -1209,19 +1209,18 @@ static void ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...) { va_list args; - char buf[BUFSIZ]; + VALUE msg; VALUE err_msg; va_init_list(args, fmt); - vsnprintf(buf, BUFSIZ, fmt, args); + msg = rb_vsprintf(fmt, args); va_end(args); err_msg = ole_hresult2msg(hr); if(err_msg != Qnil) { - rb_raise(ecs, "%s\n%s", buf, StringValuePtr(err_msg)); - } - else { - rb_raise(ecs, "%s", buf); + rb_str_cat2(msg, "\n"); + rb_str_append(msg, err_msg); } + rb_exc_raise(rb_exc_new_str(ecs, msg)); } void diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index df2a2501b21031..391bec17226f8a 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -337,11 +337,8 @@ raise_zlib_error(int err, const char *msg) rb_sys_fail(msg); /* no return */ default: - { - char buf[BUFSIZ]; - snprintf(buf, BUFSIZ, "unknown zlib error %d: %s", err, msg); - exc = rb_exc_new2(cZError, buf); - } + exc = rb_exc_new_str(cZError, + rb_sprintf("unknown zlib error %d: %s", err, msg)); } rb_exc_raise(exc); diff --git a/version.h b/version.h index 1f780eb14d11f5..017ef2810c5a6e 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-07" -#define RUBY_PATCHLEVEL 28 +#define RUBY_RELEASE_DATE "2014-02-10" +#define RUBY_PATCHLEVEL 29 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 10 #include "ruby/version.h" From aeb412e419f56abae17275ac8c44b03cc4b87693 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 10 Feb 2014 13:35:07 +0000 Subject: [PATCH 34/83] merge revision(s) 44579: [Backport #9500] ext: use PRIsVALUE for rb_raise and rb_warn * ext/bigdecimal/bigdecimal.c (BigDecimal_new): use PRIsVALUE for rb_raise() and rb_warn(). * ext/openssl/ossl_cipher.c (ossl_cipher_init): ditto. * ext/racc/cparse/cparse.c (extract_user_token): ditto. * ext/syslog/syslog.c (mSyslog_log): ditto. * ext/openssl/ossl.h (OSSL_Check_Kind, OSSL_Check_Instance): now ossl_raise() also accepts PRIsVALUE. * ext/openssl/ossl_asn1.c (ossl_asn1_default_tag): git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/bigdecimal.c | 4 ++-- ext/openssl/ossl.h | 8 ++++---- ext/openssl/ossl_asn1.c | 4 ++-- ext/openssl/ossl_cipher.c | 6 +++--- ext/racc/cparse/cparse.c | 4 ++-- ext/syslog/syslog.c | 2 +- version.h | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 8537817e86b636..8c470fc2b77d82 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2519,8 +2519,8 @@ BigDecimal_new(int argc, VALUE *argv) case T_RATIONAL: if (NIL_P(nFig)) { rb_raise(rb_eArgError, - "can't omit precision for a %s.", - rb_class2name(CLASS_OF(iniValue))); + "can't omit precision for a %"PRIsVALUE".", + rb_obj_class(iniValue)); } return GetVpValueWithPrec(iniValue, mf, 1); diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h index 96d0ade11e0d24..83a927dabe585e 100644 --- a/ext/openssl/ossl.h +++ b/ext/openssl/ossl.h @@ -95,15 +95,15 @@ extern VALUE eOSSLError; */ #define OSSL_Check_Kind(obj, klass) do {\ if (!rb_obj_is_kind_of((obj), (klass))) {\ - ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\ - rb_obj_classname(obj), rb_class2name(klass));\ + ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\ + rb_obj_class(obj), (klass));\ }\ } while (0) #define OSSL_Check_Instance(obj, klass) do {\ if (!rb_obj_is_instance_of((obj), (klass))) {\ - ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\ - rb_obj_classname(obj), rb_class2name(klass));\ + ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected instance of %"PRIsVALUE")",\ + rb_obj_class(obj), (klass));\ }\ } while (0) diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index e3f59bfe1e16f7..c2344affa69145 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -624,8 +624,8 @@ ossl_asn1_default_tag(VALUE obj) } tmp_class = rb_class_superclass(tmp_class); } - ossl_raise(eASN1Error, "universal tag for %s not found", - rb_class2name(CLASS_OF(obj))); + ossl_raise(eASN1Error, "universal tag for %"PRIsVALUE" not found", + rb_obj_class(obj)); return -1; /* dummy */ } diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c index 03374372ad0d6a..df6fd108878b40 100644 --- a/ext/openssl/ossl_cipher.c +++ b/ext/openssl/ossl_cipher.c @@ -213,9 +213,9 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode) * We deprecated the arguments for this method, but we decided * keeping this behaviour for backward compatibility. */ - const char *cname = rb_class2name(rb_obj_class(self)); - rb_warn("arguments for %s#encrypt and %s#decrypt were deprecated; " - "use %s#pkcs5_keyivgen to derive key and IV", + VALUE cname = rb_class_path(rb_obj_class(self)); + rb_warn("arguments for %"PRIsVALUE"#encrypt and %"PRIsVALUE"#decrypt were deprecated; " + "use %"PRIsVALUE"#pkcs5_keyivgen to derive key and IV", cname, cname, cname); StringValue(pass); GetCipher(self, ctx); diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c index 9bb40e74830f8e..36ad9592229463 100644 --- a/ext/racc/cparse/cparse.c +++ b/ext/racc/cparse/cparse.c @@ -418,10 +418,10 @@ extract_user_token(struct cparse_params *v, VALUE block_args, if (!RB_TYPE_P(block_args, T_ARRAY)) { rb_raise(rb_eTypeError, - "%s() %s %s (must be Array[2])", + "%s() %s %"PRIsVALUE" (must be Array[2])", v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token", v->lex_is_iterator ? "yielded" : "returned", - rb_class2name(CLASS_OF(block_args))); + rb_obj_class(block_args)); } if (RARRAY_LEN(block_args) != 2) { rb_raise(rb_eArgError, diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c index 17c5ef89697e0e..482a0a2eeeb541 100644 --- a/ext/syslog/syslog.c +++ b/ext/syslog/syslog.c @@ -312,7 +312,7 @@ static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self) pri = *argv++; if (!FIXNUM_P(pri)) { - rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(pri))); + rb_raise(rb_eTypeError, "type mismatch: %"PRIsVALUE" given", rb_obj_class(pri)); } syslog_write(FIX2INT(pri), argc, argv); diff --git a/version.h b/version.h index 017ef2810c5a6e..1f1fb66024ff2f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-10" -#define RUBY_PATCHLEVEL 29 +#define RUBY_PATCHLEVEL 30 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 84fe2b2f1db84d029a0d68a26ae9b9aa59281244 Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 16 Feb 2014 00:13:51 +0000 Subject: [PATCH 35/83] merge revision(s) 44474,44538,44539,44890,44896: [Backport #9495] * configure.in: use SSE2 instructions for drop unexpected precisions. [ruby-core:54738] [Bug #8358] * configure.in: use SSE2 instructions to drop unexpected precisions on other than mingw. [ruby-core:59472] [Bug #8358] * configure.in: -mstackrealign is necessary for -msse2 working. [ruby-core:54716] [Bug #8349] * configure.in: -mstackrealign is necessary for -msse2 working. [ruby-core:54716] [Bug #8349] * configure.in: add qouting brackets and append wildcard for the rest after target_cpu, to properly detect platform for SSE2 instructions. [ruby-core:60576] [Bug #8358] * configure.in: Fix compilation error. https://bugs.ruby-lang.org/issues/8358#note-16 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 29 +++++++++++++++++++++++++++++ configure.in | 16 ++++++++++++++++ version.h | 6 +++--- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f7d3e092c1ab0..cdc4eb6fc032ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +Sun Feb 16 07:13:36 2014 Tanaka Akira + + * configure.in: Fix compilation error. + https://bugs.ruby-lang.org/issues/8358#note-16 + +Sun Feb 16 07:13:36 2014 Vit Ondruch + + * configure.in: add qouting brackets and append wildcard for the + rest after target_cpu, to properly detect platform for SSE2 + instructions. [ruby-core:60576] [Bug #8358] + +Sun Feb 16 07:13:36 2014 Nobuyoshi Nakada + + * configure.in: -mstackrealign is necessary for -msse2 working. + [ruby-core:54716] [Bug #8349] + +Sun Feb 16 07:13:36 2014 Nobuyoshi Nakada + + * configure.in: -mstackrealign is necessary for -msse2 working. + [ruby-core:54716] [Bug #8349] + + * configure.in: use SSE2 instructions to drop unexpected precisions on + other than mingw. [ruby-core:59472] [Bug #8358] + +Sun Feb 16 07:13:36 2014 Nobuyoshi Nakada + + * configure.in: use SSE2 instructions for drop unexpected + precisions. [ruby-core:54738] [Bug #8358] + Fri Feb 7 04:19:19 2014 Koichi Sasada * gc.c (get_envparam_int): correct warning messsages. diff --git a/configure.in b/configure.in index 84f176dd9415be..95ab2723a44eb2 100644 --- a/configure.in +++ b/configure.in @@ -856,6 +856,22 @@ if test "$GCC" = yes; then for oflag in -fno-fast-math; do RUBY_TRY_CFLAGS($oflag, [RUBY_APPEND_OPTION(optflags, $oflag)]) done + AS_CASE(["$target"], + [*-darwin*], [ + # doesn't seem necessary on Mac OS X + ], + [[i[4-6]86*]], [ + RUBY_TRY_CFLAGS(-msse2 -mfpmath=sse, [ + RUBY_APPEND_OPTION(XCFLAGS, -msse2 -mfpmath=sse) + ]) + AS_CASE(["$XCFLAGS"], + [[*-msse2*]], [ + RUBY_TRY_CFLAGS(-mstackrealign, [ + RUBY_APPEND_OPTION(XCFLAGS, -mstackrealign) + ]) + ]) + ] + ) fi AC_ARG_WITH(opt-dir, diff --git a/version.h b/version.h index 1f1fb66024ff2f..183459c52550f2 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-10" -#define RUBY_PATCHLEVEL 30 +#define RUBY_RELEASE_DATE "2014-02-16" +#define RUBY_PATCHLEVEL 31 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 16 #include "ruby/version.h" From b258a1547513192278ef6069178766855a947248 Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 16 Feb 2014 21:28:55 +0000 Subject: [PATCH 36/83] merge revision(s) 44476: [Backport #9317] * configure.in: reset LDFLAGS and DLDFLAGS for opt-dir again after LIBPATHFLAG and RPATHFLAG are set. [ruby-dev:47868] [Bug #9317] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ configure.in | 29 +++++++++++++++++++---------- version.h | 6 +++--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index cdc4eb6fc032ac..f83313a6592863 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Feb 17 05:43:20 2014 Nobuyoshi Nakada + + * configure.in: reset LDFLAGS and DLDFLAGS for opt-dir again after + LIBPATHFLAG and RPATHFLAG are set. [ruby-dev:47868] [Bug #9317] + Sun Feb 16 07:13:36 2014 Tanaka Akira * configure.in: Fix compilation error. diff --git a/configure.in b/configure.in index 95ab2723a44eb2..a920fd5675a71b 100644 --- a/configure.in +++ b/configure.in @@ -880,17 +880,11 @@ AC_ARG_WITH(opt-dir, [ val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -I\1/include|g;s/^ //"` CPPFLAGS="$CPPFLAGS $val" - val=`IFS="$PATH_SEPARATOR" - for dir in $withval; do - echo x ${LIBPATHFLAG} ${RPATHFLAG} | - sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g" - done | tr '\012' ' '` + val=`echo "$PATH_SEPARATOR$withval" | sed "s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -L\1/lib|g;s/^ //"` + LDFLAGS="$LDFLAGS $val" LDFLAGS_OPTDIR="$val" - test x"${LDFLAGS}" = x || LDFLAGS="$LDFLAGS " - LDFLAGS="$LDFLAGS$val" - test x"${DLDFLAGS}" = x || DLDFLAGS="$DLDFLAGS " - DLDFLAGS="$DLDFLAGS$val" - ]) + OPT_DIR="$withval" + ], [OPT_DIR=]) test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\"" test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\"" @@ -2777,6 +2771,21 @@ AC_SUBST(RPATHFLAG) AC_SUBST(LIBPATHENV, "${LIBPATHENV-LD_LIBRARY_PATH}") AC_SUBST(TRY_LINK) +if test "x$OPT_DIR" != x; then + pat=`echo "${LDFLAGS_OPTDIR}" | sed ['s/[][\\.*|]/\\\\&/']` + LDFLAGS=`echo "${LDFLAGS}" | sed "s| ${pat}||"` + val=`IFS="$PATH_SEPARATOR" + for dir in $OPT_DIR; do + echo x ${LIBPATHFLAG} ${RPATHFLAG} | + sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g" + done | tr '\012' ' '` + test x"${LDFLAGS}" = x || LDFLAGS="$LDFLAGS " + LDFLAGS="$LDFLAGS$val" + test x"${DLDFLAGS}" = x || DLDFLAGS="$DLDFLAGS " + DLDFLAGS="$DLDFLAGS$val" + LDFLAGS_OPTDIR="$val" +fi + AS_CASE(["$target_cpu-$target_os"], [*-darwin*], [ AC_CHECK_HEADERS([execinfo.h]) diff --git a/version.h b/version.h index 183459c52550f2..2f767ea943ed6a 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-16" -#define RUBY_PATCHLEVEL 31 +#define RUBY_RELEASE_DATE "2014-02-17" +#define RUBY_PATCHLEVEL 32 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_DAY 17 #include "ruby/version.h" From 7eaa356fa213455e2aba88f7bcbd21c589ab36b8 Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 18 Feb 2014 23:07:51 +0000 Subject: [PATCH 37/83] merge revision(s) 44492: [Backport #9351] * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use ipv4_multicast_loop option for portability. Patch by Jeremy Evans. [ruby-trunk - Bug #9351] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/rinda/ring.rb | 2 +- version.h | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f83313a6592863..b09dc5a0ea6fc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 19 07:51:02 2014 Eric Hodel + + * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use + ipv4_multicast_loop option for portability. Patch by Jeremy Evans. + [ruby-trunk - Bug #9351] + Mon Feb 17 05:43:20 2014 Nobuyoshi Nakada * configure.in: reset LDFLAGS and DLDFLAGS for opt-dir again after diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb index 1ecc56a4f5b75b..4e9efadc357317 100644 --- a/lib/rinda/ring.rb +++ b/lib/rinda/ring.rb @@ -413,7 +413,7 @@ def make_socket(address) # :nodoc: soc = Socket.new(addrinfo.pfamily, addrinfo.socktype, addrinfo.protocol) if addrinfo.ipv4_multicast? then - soc.setsockopt(:IPPROTO_IP, :IP_MULTICAST_LOOP, true) + soc.setsockopt(Socket::Option.ipv4_multicast_loop(1)) soc.setsockopt(:IPPROTO_IP, :IP_MULTICAST_TTL, [@multicast_hops].pack('c')) elsif addrinfo.ipv6_multicast? then diff --git a/version.h b/version.h index 2f767ea943ed6a..faa1c6aa3e46ef 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-17" -#define RUBY_PATCHLEVEL 32 +#define RUBY_RELEASE_DATE "2014-02-19" +#define RUBY_PATCHLEVEL 33 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" From 0af103bff1aa9bacda780f24ae1e21ca6f804f0c Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 19 Feb 2014 06:00:46 +0000 Subject: [PATCH 38/83] merge revision(s) 45021,45022,45028: [Backport #9524] * gc.c: introduce new environment variable "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC frequency. Do full GC when the number of old objects is more than R * N where R is this factor and * test/ruby/test_gc.rb: add a test. * gc.c (get_envparam_double): fix a warning message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 21 +++++++++++++++++++++ gc.c | 20 ++++++++++++++++---- test/ruby/test_gc.rb | 10 ++++++++++ version.h | 2 +- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b09dc5a0ea6fc2..0d20e2821919c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +Wed Feb 19 14:25:55 2014 Koichi Sasada + + * test/ruby/test_gc.rb: ignore warning messages for running with -w + option such as chkbuild. + +Wed Feb 19 14:25:55 2014 Koichi Sasada + + * gc.c (get_envparam_double): fix a warning message. + +Wed Feb 19 14:25:55 2014 Koichi Sasada + + * gc.c: introduce new environment variable + "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC + frequency. + + Do full GC when the number of old objects is more than R * N + where R is this factor and + N is the number of old objects just after last full GC. + + * test/ruby/test_gc.rb: add a test. + Wed Feb 19 07:51:02 2014 Eric Hodel * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use diff --git a/gc.c b/gc.c index 1d182310e0f066..bcf4769b7f9e4b 100644 --- a/gc.c +++ b/gc.c @@ -108,6 +108,9 @@ rb_gc_guarded_ptr(volatile VALUE *ptr) #ifndef GC_HEAP_GROWTH_MAX_SLOTS #define GC_HEAP_GROWTH_MAX_SLOTS 0 /* 0 is disable */ #endif +#ifndef GC_HEAP_OLDOBJECT_LIMIT_FACTOR +#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0 +#endif #ifndef GC_MALLOC_LIMIT_MIN #define GC_MALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */) @@ -134,6 +137,7 @@ typedef struct { unsigned int heap_free_slots; double growth_factor; unsigned int growth_max_slots; + double oldobject_limit_factor; unsigned int malloc_limit_min; unsigned int malloc_limit_max; double malloc_limit_growth_factor; @@ -150,6 +154,7 @@ static ruby_gc_params_t gc_params = { GC_HEAP_INIT_SLOTS, GC_HEAP_GROWTH_FACTOR, GC_HEAP_GROWTH_MAX_SLOTS, + GC_HEAP_OLDOBJECT_LIMIT_FACTOR, GC_MALLOC_LIMIT_MIN, GC_MALLOC_LIMIT_MAX, GC_MALLOC_LIMIT_GROWTH_FACTOR, @@ -4498,10 +4503,12 @@ gc_marks(rb_objspace_t *objspace, int full_mark) #endif gc_marks_body(objspace, TRUE); - - /* Do full GC if old/remembered_shady object counts is greater than counts two times at last full GC counts */ - objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * 2; - objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * 2; + { + /* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */ + const double r = gc_params.oldobject_limit_factor; + objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * r; + objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * r; + } } else { /* minor GC */ gc_marks_body(objspace, FALSE); @@ -5706,6 +5713,10 @@ gc_set_initial_pages(void) * - (next slots number) = (current slots number) * (this factor) * * RUBY_GC_HEAP_GROWTH_MAX_SLOTS (new from 2.1) * - Allocation rate is limited to this factor. + * * RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR (new from 2.1.1) + * - Do full GC when the number of old objects is more than R * N + * where R is this factor and + * N is the number of old objects just after last full GC. * * * obsolete * * RUBY_FREE_MIN -> RUBY_GC_HEAP_FREE_SLOTS (from 2.1) @@ -5742,6 +5753,7 @@ ruby_gc_set_params(int safe_level) get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0); get_envparam_int ("RUBY_GC_HEAP_GROWTH_MAX_SLOTS", &gc_params.growth_max_slots, 0); + get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0); get_envparam_int("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0); get_envparam_int("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0); diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 7c13978dc1bb13..c644aa5d9a2e81 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -177,6 +177,16 @@ def test_gc_parameter assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_GROWTH_FACTOR=2.0/, "") assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_GROWTH_MAX_SLOTS=10000/, "[ruby-core:57928]") + env = { + "RUBY_GC_HEAP_INIT_SLOTS" => "100000", + "RUBY_GC_HEAP_FREE_SLOTS" => "10000", + "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" => "0.9", + } + assert_normal_exit("exit", "", :child_env => env) + assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0\.9/, "") + # always full GC when RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR < 1.0 + assert_in_out_err([env, "-e", "1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "") + # check obsolete assert_in_out_err([{'RUBY_FREE_MIN' => '100'}, '-w', '-eexit'], '', [], /RUBY_FREE_MIN is obsolete. Use RUBY_GC_HEAP_FREE_SLOTS instead/) diff --git a/version.h b/version.h index faa1c6aa3e46ef..89fbf00c34981e 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-19" -#define RUBY_PATCHLEVEL 33 +#define RUBY_PATCHLEVEL 34 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 41950b1c85d6c03ed0c969ed2ff2776cd98ae96e Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 19 Feb 2014 21:24:30 +0000 Subject: [PATCH 39/83] merge revision(s) 44327: [Backport #9276] * gc.c (ruby_gc_set_params): don't show obsolete warnings for RUBY_FREE_MIN/RUBY_HEAP_MIN_SLOTS if RUBY_GC_HEAP_FREE_SLOTS/RUBY_GC_HEAP_INIT_SLOTS are given. [Bug #9276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ gc.c | 12 +++++++----- version.h | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d20e2821919c5..b15412cae54216 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Feb 19 15:25:13 2014 Koichi Sasada + + * gc.c (ruby_gc_set_params): don't show obsolete warnings for + RUBY_FREE_MIN/RUBY_HEAP_MIN_SLOTS if + RUBY_GC_HEAP_FREE_SLOTS/RUBY_GC_HEAP_INIT_SLOTS are given. + [Bug #9276] + Wed Feb 19 14:25:55 2014 Koichi Sasada * test/ruby/test_gc.rb: ignore warning messages for running with -w diff --git a/gc.c b/gc.c index bcf4769b7f9e4b..2762db4529a9ad 100644 --- a/gc.c +++ b/gc.c @@ -5737,17 +5737,19 @@ ruby_gc_set_params(int safe_level) if (safe_level > 0) return; /* RUBY_GC_HEAP_FREE_SLOTS */ - if (get_envparam_int ("RUBY_FREE_MIN", &gc_params.heap_free_slots, 0)) { + if (get_envparam_int("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0)) { + /* ok */ + } + else if (get_envparam_int("RUBY_FREE_MIN", &gc_params.heap_free_slots, 0)) { rb_warn("RUBY_FREE_MIN is obsolete. Use RUBY_GC_HEAP_FREE_SLOTS instead."); } - get_envparam_int ("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0); /* RUBY_GC_HEAP_INIT_SLOTS */ - if (get_envparam_int("RUBY_HEAP_MIN_SLOTS", &gc_params.heap_init_slots, 0)) { - rb_warn("RUBY_HEAP_MIN_SLOTS is obsolete. Use RUBY_GC_HEAP_INIT_SLOTS instead."); + if (get_envparam_int("RUBY_GC_HEAP_INIT_SLOTS", &gc_params.heap_init_slots, 0)) { gc_set_initial_pages(); } - if (get_envparam_int("RUBY_GC_HEAP_INIT_SLOTS", &gc_params.heap_init_slots, 0)) { + else if (get_envparam_int("RUBY_HEAP_MIN_SLOTS", &gc_params.heap_init_slots, 0)) { + rb_warn("RUBY_HEAP_MIN_SLOTS is obsolete. Use RUBY_GC_HEAP_INIT_SLOTS instead."); gc_set_initial_pages(); } diff --git a/version.h b/version.h index 89fbf00c34981e..a1b9f3b9d6e358 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-19" -#define RUBY_PATCHLEVEL 34 +#define RUBY_PATCHLEVEL 35 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 54c00c0b8b1be727302b228035743370c49af7f8 Mon Sep 17 00:00:00 2001 From: svn Date: Wed, 19 Feb 2014 21:24:33 +0000 Subject: [PATCH 40/83] * 2014-02-20 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.h b/version.h index a1b9f3b9d6e358..7f46c320f44aa1 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-19" +#define RUBY_RELEASE_DATE "2014-02-20" #define RUBY_PATCHLEVEL 35 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 20 #include "ruby/version.h" From 2fe30c1de6b683401ada17ccaacaba5274bd1f00 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 20 Feb 2014 01:56:10 +0000 Subject: [PATCH 41/83] merge revision(s) 44638: [Backport #9350] * ext/socket/option.c: IP_MULTICAST_LOOP and IP_MULTICAST_TTL socket option takes a byte on OpenBSD. Fixed by Jeremy Evans. [ruby-core:59496] [Bug #9350] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/socket/option.c | 14 +++++++------- version.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b15412cae54216..f97112c5fc0302 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Feb 20 10:19:40 2014 Tanaka Akira + + * ext/socket/option.c: IP_MULTICAST_LOOP and IP_MULTICAST_TTL socket + option takes a byte on OpenBSD. + Fixed by Jeremy Evans. [ruby-core:59496] [Bug #9350] + Wed Feb 19 15:25:13 2014 Koichi Sasada * gc.c (ruby_gc_set_params): don't show obsolete warnings for diff --git a/ext/socket/option.c b/ext/socket/option.c index 3e32230aabcd95..28bdc07db621e4 100644 --- a/ext/socket/option.c +++ b/ext/socket/option.c @@ -357,7 +357,7 @@ static VALUE sockopt_s_ipv4_multicast_loop(VALUE klass, VALUE value) { #if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP) -# ifdef __NetBSD__ +# if defined(__NetBSD__) || defined(__OpenBSD__) unsigned char i = NUM2CHR(rb_to_int(value)); # else int i = NUM2INT(rb_to_int(value)); @@ -387,7 +387,7 @@ sockopt_ipv4_multicast_loop(VALUE self) #if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP) if (family == AF_INET && level == IPPROTO_IP && optname == IP_MULTICAST_LOOP) { -# ifdef __NetBSD__ +# if defined(__NetBSD__) || defined(__OpenBSD__) return sockopt_byte(self); # else return sockopt_int(self); @@ -398,7 +398,7 @@ sockopt_ipv4_multicast_loop(VALUE self) UNREACHABLE; } -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__OpenBSD__) # define inspect_ipv4_multicast_loop(a,b,c,d) inspect_byte(a,b,c,d) #else # define inspect_ipv4_multicast_loop(a,b,c,d) inspect_int(a,b,c,d) @@ -420,7 +420,7 @@ static VALUE sockopt_s_ipv4_multicast_ttl(VALUE klass, VALUE value) { #if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL) -# ifdef __NetBSD__ +# if defined(__NetBSD__) || defined(__OpenBSD__) unsigned char i = NUM2CHR(rb_to_int(value)); # else int i = NUM2INT(rb_to_int(value)); @@ -450,7 +450,7 @@ sockopt_ipv4_multicast_ttl(VALUE self) #if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL) if (family == AF_INET && level == IPPROTO_IP && optname == IP_MULTICAST_TTL) { -# ifdef __NetBSD__ +# if defined(__NetBSD__) || defined(__OpenBSD__) return sockopt_byte(self); # else return sockopt_int(self); @@ -461,7 +461,7 @@ sockopt_ipv4_multicast_ttl(VALUE self) UNREACHABLE; } -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__OpenBSD__) # define inspect_ipv4_multicast_ttl(a,b,c,d) inspect_byte(a,b,c,d) #else # define inspect_ipv4_multicast_ttl(a,b,c,d) inspect_int(a,b,c,d) @@ -481,7 +481,7 @@ inspect_int(int level, int optname, VALUE data, VALUE ret) } } -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__OpenBSD__) static int inspect_byte(int level, int optname, VALUE data, VALUE ret) { diff --git a/version.h b/version.h index 7f46c320f44aa1..ad83d4db76b1ae 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 35 +#define RUBY_PATCHLEVEL 36 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 5b05fa5cc43ef21ac45a8ca7ad40a6a1dbd36da2 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 20 Feb 2014 03:25:08 +0000 Subject: [PATCH 42/83] merge revision(s) 44494: * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use ipv4_multicast_ttl option for portability. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/rinda/ring.rb | 3 +-- version.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f97112c5fc0302..c861fb89390640 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Feb 20 12:24:59 2014 Eric Hodel + + * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use + ipv4_multicast_ttl option for portability. + Thu Feb 20 10:19:40 2014 Tanaka Akira * ext/socket/option.c: IP_MULTICAST_LOOP and IP_MULTICAST_TTL socket diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb index 4e9efadc357317..2c29977d11bdbe 100644 --- a/lib/rinda/ring.rb +++ b/lib/rinda/ring.rb @@ -414,8 +414,7 @@ def make_socket(address) # :nodoc: if addrinfo.ipv4_multicast? then soc.setsockopt(Socket::Option.ipv4_multicast_loop(1)) - soc.setsockopt(:IPPROTO_IP, :IP_MULTICAST_TTL, - [@multicast_hops].pack('c')) + soc.setsockopt(Socket::Option.ipv4_multicast_ttl(@multicast_hops)) elsif addrinfo.ipv6_multicast? then soc.setsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_LOOP, true) soc.setsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_HOPS, diff --git a/version.h b/version.h index ad83d4db76b1ae..2c6e0abeb2d096 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 36 +#define RUBY_PATCHLEVEL 37 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 05558c9f6dd6ae15ce77216c2d39b88cc27bb54d Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 20 Feb 2014 04:44:35 +0000 Subject: [PATCH 43/83] merge revision(s) 44687,44706,44727: [Backport #8770] * process.c (recv_child_error): Fix deadlock in rb_fork_internal when a signal is sent to the parent process while Ruby is forking in IO.popen. Patch by Scott Francis. Closes GH-513. * process.c (send_child_error): retry write on EINTR to fix occasional Errno::EINTR from Process.spawn. * process.c (recv_child_error): retry read on EINTR to fix occasional Errno::EINTR from Process.spawn. * process.c (READ_FROM_CHILD): Apply the last hunk of 0001-process.c-avoid-EINTR-from-Process.spawn.patch written by Eric Wong in [Bug #8770]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++++ process.c | 34 +++++++++++++++++++++++++++++----- version.h | 2 +- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c861fb89390640..21fae88fde84d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Feb 20 12:58:45 2014 Tanaka Akira + + * process.c (READ_FROM_CHILD): Apply the last hunk of + 0001-process.c-avoid-EINTR-from-Process.spawn.patch written by + Eric Wong in [Bug #8770]. + +Thu Feb 20 12:58:45 2014 Eric Wong + + * process.c (send_child_error): retry write on EINTR to fix + occasional Errno::EINTR from Process.spawn. + + * process.c (recv_child_error): retry read on EINTR to fix + occasional Errno::EINTR from Process.spawn. + Thu Feb 20 12:24:59 2014 Eric Hodel * lib/rinda/ring.rb (Rinda::RingFinger#make_socket): Use diff --git a/process.c b/process.c index f5d84973c40533..e50a047c8634da 100644 --- a/process.c +++ b/process.c @@ -3296,6 +3296,30 @@ retry_fork(int *status, int *ep, int chfunc_is_async_signal_safe) } } +static ssize_t +write_retry(int fd, const void *buf, size_t len) +{ + ssize_t w; + + do { + w = write(fd, buf, len); + } while (w < 0 && errno == EINTR); + + return w; +} + +static ssize_t +read_retry(int fd, void *buf, size_t len) +{ + ssize_t r; + + do { + r = read(fd, buf, len); + } while (r < 0 && errno == EINTR); + + return r; +} + static void send_child_error(int fd, int state, char *errmsg, size_t errmsg_buflen, int chfunc_is_async_signal_safe) { @@ -3303,7 +3327,7 @@ send_child_error(int fd, int state, char *errmsg, size_t errmsg_buflen, int chfu int err; if (!chfunc_is_async_signal_safe) { - if (write(fd, &state, sizeof(state)) == sizeof(state) && state) { + if (write_retry(fd, &state, sizeof(state)) == sizeof(state) && state) { VALUE errinfo = rb_errinfo(); io = rb_io_fdopen(fd, O_WRONLY|O_BINARY, NULL); rb_marshal_dump(errinfo, io); @@ -3311,11 +3335,11 @@ send_child_error(int fd, int state, char *errmsg, size_t errmsg_buflen, int chfu } } err = errno; - if (write(fd, &err, sizeof(err)) < 0) err = errno; + if (write_retry(fd, &err, sizeof(err)) < 0) err = errno; if (errmsg && 0 < errmsg_buflen) { errmsg[errmsg_buflen-1] = '\0'; errmsg_buflen = strlen(errmsg); - if (errmsg_buflen > 0 && write(fd, errmsg, errmsg_buflen) < 0) + if (errmsg_buflen > 0 && write_retry(fd, errmsg, errmsg_buflen) < 0) err = errno; } if (!NIL_P(io)) rb_io_close(io); @@ -3329,7 +3353,7 @@ recv_child_error(int fd, int *statep, VALUE *excp, int *errp, char *errmsg, size ssize_t size; VALUE exc = Qnil; if (!chfunc_is_async_signal_safe) { - if ((read(fd, &state, sizeof(state))) == sizeof(state) && state) { + if ((read_retry(fd, &state, sizeof(state))) == sizeof(state) && state) { io = rb_io_fdopen(fd, O_RDONLY|O_BINARY, NULL); exc = rb_marshal_load(io); rb_set_errinfo(exc); @@ -3338,7 +3362,7 @@ recv_child_error(int fd, int *statep, VALUE *excp, int *errp, char *errmsg, size *excp = exc; } #define READ_FROM_CHILD(ptr, len) \ - (NIL_P(io) ? read(fd, (ptr), (len)) : rb_io_bufread(io, (ptr), (len))) + (NIL_P(io) ? read_retry(fd, (ptr), (len)) : rb_io_bufread(io, (ptr), (len))) if ((size = READ_FROM_CHILD(&err, sizeof(err))) < 0) { err = errno; } diff --git a/version.h b/version.h index 2c6e0abeb2d096..9cb1376d7a0def 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 37 +#define RUBY_PATCHLEVEL 38 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From b0578a2d9d17d50e1340eb7062b44b7f0fc2ef74 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 20 Feb 2014 07:30:24 +0000 Subject: [PATCH 44/83] merge revision(s) 44654: [Backport #9426] tracepoint.c: disable tracepoint * ext/-test-/tracepoint/tracepoint.c (tracepoint_track_objspace_events): ensure tracepoint disabled. [ruby-dev:47901] [Bug #9426] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/-test-/tracepoint/tracepoint.c | 3 +-- version.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/-test-/tracepoint/tracepoint.c b/ext/-test-/tracepoint/tracepoint.c index 245dbd6191673b..aa8c212f99b71d 100644 --- a/ext/-test-/tracepoint/tracepoint.c +++ b/ext/-test-/tracepoint/tracepoint.c @@ -64,8 +64,7 @@ tracepoint_track_objspace_events(VALUE self) VALUE result = rb_ary_new(); rb_tracepoint_enable(tpval); - rb_yield(Qundef); - rb_tracepoint_disable(tpval); + rb_ensure(rb_yield, Qundef, rb_tracepoint_disable, tpval); rb_ary_push(result, SIZET2NUM(track.newobj_count)); rb_ary_push(result, SIZET2NUM(track.free_count)); diff --git a/version.h b/version.h index 9cb1376d7a0def..024fb772fa7174 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 38 +#define RUBY_PATCHLEVEL 39 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 42f1c520b9dc9c1bf38e2594790a52600e26f20c Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 05:52:00 +0000 Subject: [PATCH 45/83] merge revision(s) 44720: [Backport #9455] * compile.c (iseq_build_from_ary_body): Use :blockptr instead of :block as hash key when loading serialized instruction sequences from arrays. [Bug #9455] [ruby-core:60146] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ compile.c | 2 +- version.h | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21fae88fde84d7..e13d7c5e9ce025 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Feb 21 13:39:21 2014 Charlie Somerville + + * compile.c (iseq_build_from_ary_body): Use :blockptr instead of :block + as hash key when loading serialized instruction sequences from arrays. + [Bug #9455] [ruby-core:60146] + Thu Feb 20 12:58:45 2014 Tanaka Akira * process.c (READ_FROM_CHILD): Apply the last hunk of diff --git a/compile.c b/compile.c index 48479338c995c0..3d6a4627e9f475 100644 --- a/compile.c +++ b/compile.c @@ -5766,7 +5766,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, VALUE vmid = rb_hash_aref(op, ID2SYM(rb_intern("mid"))); VALUE vflag = rb_hash_aref(op, ID2SYM(rb_intern("flag"))); VALUE vorig_argc = rb_hash_aref(op, ID2SYM(rb_intern("orig_argc"))); - VALUE vblock = rb_hash_aref(op, ID2SYM(rb_intern("block"))); + VALUE vblock = rb_hash_aref(op, ID2SYM(rb_intern("blockptr"))); if (!NIL_P(vmid)) mid = SYM2ID(vmid); if (!NIL_P(vflag)) flag = NUM2ULONG(vflag); diff --git a/version.h b/version.h index 024fb772fa7174..dc6ac3919e5477 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-20" -#define RUBY_PATCHLEVEL 39 +#define RUBY_RELEASE_DATE "2014-02-21" +#define RUBY_PATCHLEVEL 40 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 21 #include "ruby/version.h" From d25384cef7e54346d8ff0f36b9dda83e088aff93 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 08:34:35 +0000 Subject: [PATCH 46/83] merge revision(s) 44604,44605,44606: [Backport #9415] test_m17n.rb: split tests for inspect * test/ruby/test_m17n.rb (test_utf_16_32_inspect): split tests for each encodings. * string.c (get_actual_encoding): get actual encoding according to the BOM if exists. * string.c (rb_str_inspect): use according encoding, instead of pseudo encodings, UTF-{16,32}. [ruby-core:59757] [Bug #8940] * string.c (get_encoding): respect BOM on pseudo encodings. [ruby-dev:47895] [Bug #9415] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 ++++++++ encoding.c | 6 ++++ string.c | 69 +++++++++++++++++++++++++++--------------- test/ruby/test_m17n.rb | 35 +++++++++++++-------- version.h | 2 +- 5 files changed, 88 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index e13d7c5e9ce025..45f26694185572 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Fri Feb 21 16:47:20 2014 Nobuyoshi Nakada + + * string.c (get_encoding): respect BOM on pseudo encodings. + [ruby-dev:47895] [Bug #9415] + +Fri Feb 21 16:47:20 2014 Nobuyoshi Nakada + + * string.c (get_actual_encoding): get actual encoding according to + the BOM if exists. + + * string.c (rb_str_inspect): use according encoding, instead of + pseudo encodings, UTF-{16,32}. [ruby-core:59757] [Bug #8940] + Fri Feb 21 13:39:21 2014 Charlie Somerville * compile.c (iseq_build_from_ary_body): Use :blockptr instead of :block diff --git a/encoding.c b/encoding.c index aede0fb08a9e20..9bfda11f380ee6 100644 --- a/encoding.c +++ b/encoding.c @@ -598,6 +598,12 @@ rb_enc_from_index(int index) return enc_table.list[index].enc; } +rb_encoding * +rb_enc_get_from_index(int index) +{ + return must_encindex(index); +} + int rb_enc_registered(const char *name) { diff --git a/string.c b/string.c index cc307866dbfb68..983c2a11661fa3 100644 --- a/string.c +++ b/string.c @@ -121,7 +121,45 @@ VALUE rb_cSymbol; #define STR_HEAP_PTR(str) (RSTRING(str)->as.heap.ptr) #define STR_HEAP_SIZE(str) (RSTRING(str)->as.heap.aux.capa + TERM_LEN(str)) -#define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str)) +#define STR_ENC_GET(str) get_encoding(str) + +rb_encoding *rb_enc_get_from_index(int index); + +static rb_encoding * +get_actual_encoding(const int encidx, VALUE str) +{ + const unsigned char *q; + + switch (encidx) { + case ENCINDEX_UTF_16: + if (RSTRING_LEN(str) < 2) break; + q = (const unsigned char *)RSTRING_PTR(str); + if (q[0] == 0xFE && q[1] == 0xFF) { + return rb_enc_get_from_index(ENCINDEX_UTF_16BE); + } + if (q[0] == 0xFF && q[1] == 0xFE) { + return rb_enc_get_from_index(ENCINDEX_UTF_16LE); + } + return rb_ascii8bit_encoding(); + case ENCINDEX_UTF_32: + if (RSTRING_LEN(str) < 4) break; + q = (const unsigned char *)RSTRING_PTR(str); + if (q[0] == 0 && q[1] == 0 && q[2] == 0xFE && q[3] == 0xFF) { + return rb_enc_get_from_index(ENCINDEX_UTF_32BE); + } + if (q[3] == 0 && q[2] == 0 && q[1] == 0xFE && q[0] == 0xFF) { + return rb_enc_get_from_index(ENCINDEX_UTF_32LE); + } + return rb_ascii8bit_encoding(); + } + return rb_enc_from_index(encidx); +} + +static rb_encoding * +get_encoding(VALUE str) +{ + return get_actual_encoding(ENCODING_GET(str), str); +} static int fstring_cmp(VALUE a, VALUE b); @@ -4750,8 +4788,8 @@ rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p) VALUE rb_str_inspect(VALUE str) { - rb_encoding *enc = STR_ENC_GET(str); - int encidx = rb_enc_to_index(enc); + int encidx = ENCODING_GET(str); + rb_encoding *enc = rb_enc_from_index(encidx), *actenc; const char *p, *pend, *prev; char buf[CHAR_ESC_LEN + 1]; VALUE result = rb_str_buf_new(0); @@ -4766,27 +4804,10 @@ rb_str_inspect(VALUE str) p = RSTRING_PTR(str); pend = RSTRING_END(str); prev = p; - if (encidx == ENCINDEX_UTF_16 && p + 2 <= pend) { - const unsigned char *q = (const unsigned char *)p; - if (q[0] == 0xFE && q[1] == 0xFF) - enc = rb_enc_from_index(ENCINDEX_UTF_16BE); - else if (q[0] == 0xFF && q[1] == 0xFE) - enc = rb_enc_from_index(ENCINDEX_UTF_16LE); - else { - enc = rb_ascii8bit_encoding(); - unicode_p = 0; - } - } - else if (encidx == ENCINDEX_UTF_32 && p + 4 <= pend) { - const unsigned char *q = (const unsigned char *)p; - if (q[0] == 0 && q[1] == 0 && q[2] == 0xFE && q[3] == 0xFF) - enc = rb_enc_from_index(ENCINDEX_UTF_32BE); - else if (q[3] == 0 && q[2] == 0 && q[1] == 0xFE && q[0] == 0xFF) - enc = rb_enc_from_index(ENCINDEX_UTF_32LE); - else { - enc = rb_ascii8bit_encoding(); - unicode_p = 0; - } + actenc = get_actual_encoding(encidx, str); + if (actenc != enc) { + enc = actenc; + if (unicode_p) unicode_p = rb_enc_unicode_p(enc); } while (p < pend) { unsigned int c, cc; diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 2e4f67c48afe66..b9b85b21293afb 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -226,24 +226,35 @@ def test_string_inspect_encoding end end - def test_utf_16_32_inspect - str = "\u3042" - %w/UTF-16 UTF-32/.each do |enc| - %w/BE LE/.each do |endian| - s = str.encode(enc + endian) + STR_WITHOUT_BOM = "\u3042".freeze + STR_WITH_BOM = "\uFEFF\u3042".freeze + bug8940 = '[ruby-core:59757] [Bug #8940]' + bug9415 = '[ruby-dev:47895] [Bug #9415]' + %w/UTF-16 UTF-32/.each do |enc| + %w/BE LE/.each do |endian| + bom = "\uFEFF".encode("#{enc}#{endian}").force_encoding(enc) + + define_method("test_utf_16_32_inspect(#{enc}#{endian})") do + s = STR_WITHOUT_BOM.encode(enc + endian) # When a UTF-16/32 string doesn't have a BOM, # inspect as a dummy encoding string. assert_equal(s.dup.force_encoding("ISO-2022-JP").inspect, s.dup.force_encoding(enc).inspect) + assert_normal_exit("#{bom.b.dump}.force_encoding('#{enc}').inspect", bug8940) end - end - str = "\uFEFF\u3042" - %w/UTF-16 UTF-32/.each do |enc| - %w/BE LE/.each do |endian| - s = str.encode(enc + endian) - # When a UTF-16/32 string doesn't have a BOM, - # inspect as a dummy encoding string. + define_method("test_utf_16_32_codepoints(#{enc}#{endian})") do + assert_equal([0xFEFF], bom.codepoints, bug9415) + end + + define_method("test_utf_16_32_ord(#{enc}#{endian})") do + assert_equal(0xFEFF, bom.ord, bug9415) + end + + define_method("test_utf_16_32_inspect(#{enc}#{endian}-BOM)") do + s = STR_WITH_BOM.encode(enc + endian) + # When a UTF-16/32 string has a BOM, + # inspect as a particular encoding string. assert_equal(s.inspect, s.dup.force_encoding(enc).inspect) end diff --git a/version.h b/version.h index dc6ac3919e5477..c91aedde32fcc3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 40 +#define RUBY_PATCHLEVEL 41 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 210995b265d892ed6867dc92ff0b9a86d60d3835 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 09:08:45 +0000 Subject: [PATCH 47/83] merge revision(s) 44312,44318: [Backport #9273] * lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not consider encodings in hosts file. [ruby-core:59239] [Bug #9273] * lib/resolv.rb (Resolv::Config.parse_resolv_conf): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/resolv.rb | 4 ++-- test/resolv/test_addr.rb | 12 ++++++++++++ test/resolv/test_dns.rb | 11 +++++++++++ version.h | 2 +- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 45f26694185572..26614f3183be92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 21 17:42:42 2014 Nobuyoshi Nakada + + * lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not + consider encodings in hosts file. [ruby-core:59239] [Bug #9273] + + * lib/resolv.rb (Resolv::Config.parse_resolv_conf): ditto. + Fri Feb 21 16:47:20 2014 Nobuyoshi Nakada * string.c (get_encoding): respect BOM on pseudo encodings. diff --git a/lib/resolv.rb b/lib/resolv.rb index 6d34a67e099666..0c2b68ec27c687 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -187,7 +187,7 @@ def lazy_initialize # :nodoc: unless @initialized @name2addr = {} @addr2name = {} - open(@filename) {|f| + open(@filename, 'rb') {|f| f.each {|line| line.sub!(/#.*/, '') addr, hostname, *aliases = line.split(/\s+/) @@ -920,7 +920,7 @@ def Config.parse_resolv_conf(filename) nameserver = [] search = nil ndots = 1 - open(filename) {|f| + open(filename, 'rb') {|f| f.each {|line| line.sub!(/[#;].*/, '') keyword, *args = line.split(/\s+/) diff --git a/test/resolv/test_addr.rb b/test/resolv/test_addr.rb index 84bc8c2d3b2def..d4728e1b716ba2 100644 --- a/test/resolv/test_addr.rb +++ b/test/resolv/test_addr.rb @@ -13,4 +13,16 @@ def test_invalid_ipv4_address end } end + + def test_invalid_byte_comment + bug9273 = '[ruby-core:59239] [Bug #9273]' + Tempfile.open('resolv_test_addr_') do |tmpfile| + tmpfile.print("\xff\x00\x40") + tmpfile.close + hosts = Resolv::Hosts.new(tmpfile.path) + assert_nothing_raised(ArgumentError, bug9273) do + hosts.each_address("") {break} + end + end + end end diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb index 0d9565ef68ac36..07396fb177de8e 100644 --- a/test/resolv/test_dns.rb +++ b/test/resolv/test_dns.rb @@ -1,6 +1,7 @@ require 'test/unit' require 'resolv' require 'socket' +require 'tempfile' class TestResolvDNS < Test::Unit::TestCase def setup @@ -150,4 +151,14 @@ def test_no_server } end + def test_invalid_byte_comment + bug9273 = '[ruby-core:59239] [Bug #9273]' + Tempfile.open('resolv_test_dns_') do |tmpfile| + tmpfile.print("\xff\x00\x40") + tmpfile.close + assert_nothing_raised(ArgumentError, bug9273) do + Resolv::DNS::Config.parse_resolv_conf(tmpfile.path) + end + end + end end diff --git a/version.h b/version.h index c91aedde32fcc3..c0347b835e2308 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 41 +#define RUBY_PATCHLEVEL 42 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 21b009633f032d6713519e64858778465de5a5bd Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 13:48:53 +0000 Subject: [PATCH 48/83] merge revision(s) 44790: [Backport #9472] * io.c (rb_io_syswrite): add RB_GC_GUARD [Bug #9472][ruby-core:60407] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 1 + version.h | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 26614f3183be92..a786d6f7e9d481 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Feb 2 05:48:42 2014 Eric Wong + + * io.c (rb_io_syswrite): add RB_GC_GUARD + [Bug #9472][ruby-core:60407] + Fri Feb 21 17:42:42 2014 Nobuyoshi Nakada * lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not diff --git a/io.c b/io.c index 5aa720b6a7b651..6e3fd85d2b1238 100644 --- a/io.c +++ b/io.c @@ -4572,6 +4572,7 @@ rb_io_syswrite(VALUE io, VALUE str) } n = rb_write_internal(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str)); + RB_GC_GUARD(str); if (n == -1) rb_sys_fail_path(fptr->pathv); diff --git a/version.h b/version.h index c0347b835e2308..def8d8b0bc0860 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 42 +#define RUBY_PATCHLEVEL 43 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 43fde884af75053c1dccd3fe141da7538826c785 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 14:06:17 +0000 Subject: [PATCH 49/83] merge revision(s) 44531: [Backport #9300] * ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings with quotes should not have changed. [ruby-core:59316] [Bug #9300] * ext/psych/lib/psych.rb: fixed missing require. * test/psych/test_string.rb: test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ ext/psych/lib/psych.rb | 1 + ext/psych/lib/psych/visitors/yaml_tree.rb | 2 +- test/psych/test_string.rb | 4 ++++ version.h | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a786d6f7e9d481..b66e879bfcd2fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Feb 21 23:00:34 2014 Aaron Patterson + + * ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings with + quotes should not have changed. [ruby-core:59316] [Bug #9300] + + * ext/psych/lib/psych.rb: fixed missing require. + + * test/psych/test_string.rb: test + Sun Feb 2 05:48:42 2014 Eric Wong * io.c (rb_io_syswrite): add RB_GC_GUARD diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb index 2a87f43efe0b1d..45e01c5fd19666 100644 --- a/ext/psych/lib/psych.rb +++ b/ext/psych/lib/psych.rb @@ -14,6 +14,7 @@ require 'psych/json/tree_builder' require 'psych/json/stream' require 'psych/handlers/document_stream' +require 'psych/class_loader' ### # = Overview diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index 1cb21376934e6c..f89fcbb8f12c3e 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -284,7 +284,7 @@ def visit_String o quote = false elsif o =~ /\n/ style = Nodes::Scalar::LITERAL - elsif o =~ /^\W/ + elsif o =~ /^\W[^"]*$/ style = Nodes::Scalar::DOUBLE_QUOTED else unless String === @ss.tokenize(o) diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index 84326da8d31fb4..01fc0e4bb0b722 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -15,6 +15,10 @@ def initialize end end + def test_no_doublequotes_with_special_characters + assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"') + end + def test_doublequotes_when_there_is_a_single yaml = Psych.dump "@123'abc" assert_match(/---\s*"/, yaml) diff --git a/version.h b/version.h index def8d8b0bc0860..a63532d2e804b0 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 43 +#define RUBY_PATCHLEVEL 44 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 41196a7a16961833a127662332662e72a9c69a32 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 14:08:26 +0000 Subject: [PATCH 50/83] merge revision(s) 44472: [Backport #9333] * win32/Makefile.sub: remove HAVE_FSEEKO because fseeko removed from win32/win32.c Fixed [Bug #9333]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ version.h | 2 +- win32/Makefile.sub | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b66e879bfcd2fd..a36360f51a5b1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 21 23:07:56 2014 Akio Tajima + + * win32/Makefile.sub: remove HAVE_FSEEKO because fseeko removed from win32/win32.c + Fixed [Bug #9333]. + Fri Feb 21 23:00:34 2014 Aaron Patterson * ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings with diff --git a/version.h b/version.h index a63532d2e804b0..9d7241d82c6326 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 44 +#define RUBY_PATCHLEVEL 45 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 diff --git a/win32/Makefile.sub b/win32/Makefile.sub index a04e8024beab68..d6289bc53d381f 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -677,7 +677,6 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub #define HAVE_GETCWD 1 #define HAVE_TRUNCATE 1 #define HAVE_FTRUNCATE 1 -#define HAVE_FSEEKO 1 #define HAVE_TIMES 1 #define HAVE_FCNTL 1 #define HAVE_LINK 1 From 2ae49e78e723dc54c94cd7501f0c2de5a792570d Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 14:14:26 +0000 Subject: [PATCH 51/83] merge revision(s) 44469: [Backport #9329] * lib/mkmf.rb (RbConfig): expand RUBY_SO_NAME for extensions backward compatibility. [ruby-core:59426] [Bug #9329] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/mkmf.rb | 2 ++ version.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a36360f51a5b1a..816f468b9fba92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 21 23:10:12 2014 Nobuyoshi Nakada + + * lib/mkmf.rb (RbConfig): expand RUBY_SO_NAME for extensions + backward compatibility. [ruby-core:59426] [Bug #9329] + Fri Feb 21 23:07:56 2014 Akio Tajima * win32/Makefile.sub: remove HAVE_FSEEKO because fseeko removed from win32/win32.c diff --git a/lib/mkmf.rb b/lib/mkmf.rb index c4e2e5a90041f2..2d44b123d2f293 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -2508,6 +2508,8 @@ def MAIN_DOES_NOTHING(*refs) $configure_args["--topdir"] ||= $curdir $ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"])) + RbConfig.expand(CONFIG["RUBY_SO_NAME"]) + # :startdoc: split = Shellwords.method(:shellwords).to_proc diff --git a/version.h b/version.h index 9d7241d82c6326..f02c5385976b74 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 45 +#define RUBY_PATCHLEVEL 46 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 37095c485fade52009efff279235a99accc6401b Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 14:53:48 +0000 Subject: [PATCH 52/83] merge revision(s) 44462,44477: [Backport #9314] * encoding.c (must_encindex, rb_enc_from_index, rb_obj_encoding): mask encoding index and ignore dummy flags. [ruby-core:59354] [Bug #9314] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ encoding.c | 6 +++--- test/ruby/test_transcode.rb | 11 +++++++++++ version.h | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 816f468b9fba92..306c20331831bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 21 23:51:38 2014 Nobuyoshi Nakada + + * encoding.c (must_encindex, rb_enc_from_index, rb_obj_encoding): mask + encoding index and ignore dummy flags. [ruby-core:59354] [Bug #9314] + Fri Feb 21 23:10:12 2014 Nobuyoshi Nakada * lib/mkmf.rb (RbConfig): expand RUBY_SO_NAME for extensions diff --git a/encoding.c b/encoding.c index 9bfda11f380ee6..f102524379fc22 100644 --- a/encoding.c +++ b/encoding.c @@ -156,7 +156,7 @@ must_encindex(int index) rb_raise(rb_eEncodingError, "encoding index out of bound: %d", index); } - if (ENC_TO_ENCINDEX(enc) != index) { + if (ENC_TO_ENCINDEX(enc) != (int)(index & ENC_INDEX_MASK)) { rb_raise(rb_eEncodingError, "wrong encoding index %d for %s (expected %d)", index, rb_enc_name(enc), ENC_TO_ENCINDEX(enc)); } @@ -592,7 +592,7 @@ rb_enc_from_index(int index) if (!enc_table.list) { rb_enc_init(); } - if (index < 0 || enc_table.count <= index) { + if (index < 0 || enc_table.count <= (index &= ENC_INDEX_MASK)) { return 0; } return enc_table.list[index].enc; @@ -933,7 +933,7 @@ rb_obj_encoding(VALUE obj) if (idx < 0) { rb_raise(rb_eTypeError, "unknown encoding"); } - return rb_enc_from_encoding_index(idx); + return rb_enc_from_encoding_index(idx & ENC_INDEX_MASK); } int diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index 25c9d24663ce8f..5f3f51a67675ba 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -2080,4 +2080,15 @@ def test_encode_with_invalid_chars assert_equal "\ufffd", str.encode(invalid: :replace), bug8995 end end + + def test_valid_dummy_encoding + bug9314 = '[ruby-core:59354] [Bug #9314]' + assert_separately(%W[- -- #{bug9314}], <<-'end;') + bug = ARGV.shift + result = assert_nothing_raised(TypeError, bug) {break "test".encode(Encoding::UTF_16)} + assert_equal("\xFE\xFF\x00t\x00e\x00s\x00t", result.b, bug) + result = assert_nothing_raised(TypeError, bug) {break "test".encode(Encoding::UTF_32)} + assert_equal("\x00\x00\xFE\xFF\x00\x00\x00t\x00\x00\x00e\x00\x00\x00s\x00\x00\x00t", result.b, bug) + end; + end end diff --git a/version.h b/version.h index f02c5385976b74..b80e09e97564d6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 46 +#define RUBY_PATCHLEVEL 47 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From c22f44bda01698c1608b9392bbc7118caf19837c Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 15:12:52 +0000 Subject: [PATCH 53/83] merge revision(s) 44616,44622,44623,44626,44632,44636: add timeout to test_do_reply http://fb64b.rubyci.org/~chkbuild/ruby-trunk/log/20140115T073301Z.log.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rinda/test_rinda.rb | 54 +++++++++++++++++++++++++++++++++++++--- version.h | 6 ++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index 448c4fe02fc4c6..f5472d28acfa68 100644 --- a/test/rinda/test_rinda.rb +++ b/test/rinda/test_rinda.rb @@ -4,7 +4,7 @@ require 'drb/eq' require 'rinda/ring' require 'rinda/tuplespace' - +require 'timeout' require 'singleton' module Rinda @@ -559,6 +559,10 @@ def teardown end def test_do_reply + with_timeout(10) {_test_do_reply} + end + + def _test_do_reply called = nil callback = proc { |ts| @@ -571,12 +575,16 @@ def test_do_reply @rs.do_reply - Thread.pass until called + wait_for(10) {called} assert_same @ts, called end def test_do_reply_local + with_timeout(10) {_test_do_reply_local} + end + + def _test_do_reply_local called = nil callback = proc { |ts| @@ -587,7 +595,7 @@ def test_do_reply_local @rs.do_reply - Thread.pass until called + wait_for(10) {called} assert_same @ts, called end @@ -674,6 +682,46 @@ def test_shutdown assert_nil(@rs.do_reply, 'otherwise should hang forever') end + private + + def with_timeout(n) + aoe = Thread.abort_on_exception + Thread.abort_on_exception = true + tl0 = Thread.list + tl = nil + th = Thread.new(Thread.current) do |mth| + sleep n + (tl = Thread.list - tl0).each {|t|t.raise(Timeout::Error)} + mth.raise(Timeout::Error) + end + tl0 << th + rescue Timeout::Error => e + if tl + bt = e.backtrace + tl.each do |t| + begin + t.value + rescue Timeout::Error => e + bt.unshift("") + bt[0, 0] = e.backtrace + end + end + end + raise Timeout::Error, "timeout", bt + ensure + th.kill if th + Thread.abort_on_exception = aoe + end + + def wait_for(n) + t = n + Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) + until yield + if t < Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) + flunk "timeout during waiting call" + end + sleep 0.1 + end + end end class TestRingFinger < Test::Unit::TestCase diff --git a/version.h b/version.h index b80e09e97564d6..aabfd2232bc2ce 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 47 +#define RUBY_RELEASE_DATE "2014-02-22" +#define RUBY_PATCHLEVEL 48 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 21 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" From de3abc8592e43096adcb3c2118bf2a002ffddcb4 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 15:42:08 +0000 Subject: [PATCH 54/83] merge revision(s) 44449: [Backport #9416] * parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to isolate command argument state from outer scope. [ruby-core:59342] [Bug #9308] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ parse.y | 4 ++++ test/ruby/test_syntax.rb | 5 +++++ version.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 306c20331831bc..a7883c7a3ee14c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 00:21:50 2014 Nobuyoshi Nakada + + * parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to + isolate command argument state from outer scope. + [ruby-core:59342] [Bug #9308] + Fri Feb 21 23:51:38 2014 Nobuyoshi Nakada * encoding.c (must_encindex, rb_enc_from_index, rb_obj_encoding): mask diff --git a/parse.y b/parse.y index d04cf456126d25..eb5ed547d335a4 100644 --- a/parse.y +++ b/parse.y @@ -130,6 +130,7 @@ struct local_vars { struct vtable *vars; struct vtable *used; struct local_vars *prev; + stack_type cmdargs; }; #define DVARS_INHERIT ((void*)1) @@ -9642,6 +9643,8 @@ local_push_gen(struct parser_params *parser, int inherit_dvars) local->used = !(inherit_dvars && (ifndef_ripper(compile_for_eval || e_option_supplied(parser))+0)) && RTEST(ruby_verbose) ? vtable_alloc(0) : 0; + local->cmdargs = cmdarg_stack; + cmdarg_stack = 0; lvtbl = local; } @@ -9655,6 +9658,7 @@ local_pop_gen(struct parser_params *parser) } vtable_free(lvtbl->args); vtable_free(lvtbl->vars); + cmdarg_stack = lvtbl->cmdargs; xfree(lvtbl); lvtbl = local; } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 04fcd20a56c28b..cac755a3903c48 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -256,6 +256,11 @@ def test_do_block_in_cmdarg_begin assert_valid_syntax("p begin 1.times do 1 end end", __FILE__, bug6419) end + def test_do_block_in_call_args + bug9308 = '[ruby-core:59342] [Bug #9308]' + assert_valid_syntax("bar def foo; self.each do end end", bug9308) + end + def test_reserved_method_no_args bug6403 = '[ruby-dev:45626]' assert_valid_syntax("def self; :foo; end", __FILE__, bug6403) diff --git a/version.h b/version.h index aabfd2232bc2ce..260d1a85b6bcaf 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 48 +#define RUBY_PATCHLEVEL 49 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 17ad6f49a12b4061a2e3605fc2e9d0deedfeb6ec Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 21 Feb 2014 23:32:34 +0000 Subject: [PATCH 55/83] merge revision(s) 44925: [Backport #9492] * configure.in: check if pthread_setname_np is available. * thread_pthread.c: pthread_setname_np is not available on old Darwins. [ruby-core:60524] [Bug #9492] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ configure.in | 2 +- thread_pthread.c | 2 +- version.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7883c7a3ee14c..f856ed660109aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Feb 22 01:35:02 2014 Nobuyoshi Nakada + + * configure.in: check if pthread_setname_np is available. + + * thread_pthread.c: pthread_setname_np is not available on old + Darwins. [ruby-core:60524] [Bug #9492] + Sat Feb 22 00:21:50 2014 Nobuyoshi Nakada * parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to diff --git a/configure.in b/configure.in index a920fd5675a71b..17ed3edea3d2e8 100644 --- a/configure.in +++ b/configure.in @@ -2448,7 +2448,7 @@ if test x"$enable_pthread" = xyes; then pthread_get_stackaddr_np pthread_get_stacksize_np \ thr_stksegment pthread_stackseg_np pthread_getthrds_np \ pthread_cond_init pthread_condattr_setclock pthread_condattr_init \ - pthread_sigmask) + pthread_sigmask pthread_setname_np) if test "${host_os}" = "nacl"; then ac_cv_func_pthread_attr_init=no else diff --git a/thread_pthread.c b/thread_pthread.c index 57daa3b45d06a9..3e58ac5745aeba 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1423,7 +1423,7 @@ timer_thread_sleep(rb_global_vm_lock_t* unused) #if defined(__linux__) && defined(PR_SET_NAME) # define SET_THREAD_NAME(name) prctl(PR_SET_NAME, name) -#elif defined(__APPLE__) +#elif defined(HAVE_PTHREAD_SETNAME_NP) /* pthread_setname_np() on Darwin does not have target thread argument */ # define SET_THREAD_NAME(name) pthread_setname_np(name) #else diff --git a/version.h b/version.h index 260d1a85b6bcaf..e352ebc6bfa737 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 49 +#define RUBY_PATCHLEVEL 50 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From df382466acdaed86dddd102c9c2d827622869db0 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 04:21:39 +0000 Subject: [PATCH 56/83] merge revision(s) 44595: [Backport #9342] * ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS on SizedQueue#clear. [ruby-core:59462] [Bug #9342] * test/thread/test_queue.rb: add test. the patch is from Justin Collins. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/thread/thread.c | 15 +++++++++++++++ test/thread/test_queue.rb | 22 ++++++++++++++++++++++ version.h | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f856ed660109aa..9323ed5ae5a684 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Feb 22 13:17:32 2014 Masaki Matsushita + + * ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS + on SizedQueue#clear. [ruby-core:59462] [Bug #9342] + + * test/thread/test_queue.rb: add test. the patch is from + Justin Collins. + Sat Feb 22 01:35:02 2014 Nobuyoshi Nakada * configure.in: check if pthread_setname_np is available. diff --git a/ext/thread/thread.c b/ext/thread/thread.c index a8f675c55ba309..c409b36da2c0ba 100644 --- a/ext/thread/thread.c +++ b/ext/thread/thread.c @@ -502,6 +502,20 @@ rb_szqueue_pop(int argc, VALUE *argv, VALUE self) return szqueue_do_pop(self, should_block); } +/* + * Document-method: Queue#clear + * + * Removes all objects from the queue. + */ + +static VALUE +rb_szqueue_clear(VALUE self) +{ + rb_ary_clear(GET_QUEUE_QUE(self)); + wakeup_all_threads(GET_SZQUEUE_WAITERS(self)); + return self; +} + /* * Document-method: SizedQueue#num_waiting * @@ -586,6 +600,7 @@ Init_thread(void) rb_define_method(rb_cSizedQueue, "max=", rb_szqueue_max_set, 1); rb_define_method(rb_cSizedQueue, "push", rb_szqueue_push, 1); rb_define_method(rb_cSizedQueue, "pop", rb_szqueue_pop, -1); + rb_define_method(rb_cSizedQueue, "clear", rb_szqueue_clear, 0); rb_define_method(rb_cSizedQueue, "num_waiting", rb_szqueue_num_waiting, 0); /* Alias for #push. */ diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 2126500bd81d70..c99475d8dc872d 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -129,6 +129,28 @@ def test_queue_clear_return_value assert_same q, retval end + def test_sized_queue_clear + # Fill queue, then test that SizedQueue#clear wakes up all waiting threads + sq = SizedQueue.new(2) + 2.times { sq << 1 } + + t1 = Thread.new do + sq << 1 + end + + t2 = Thread.new do + sq << 1 + end + + t3 = Thread.new do + Thread.pass + sq.clear + end + + [t3, t2, t1].each(&:join) + assert_equal sq.length, 2 + end + def test_sized_queue_push_return_value q = SizedQueue.new(1) retval = q.push(1) diff --git a/version.h b/version.h index e352ebc6bfa737..2bb33993f50434 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 50 +#define RUBY_PATCHLEVEL 51 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 276b6b82c3d5ce0204454c7dbd9d25cf1d05b322 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 04:35:18 +0000 Subject: [PATCH 57/83] merge revision(s) 44568: [Backport #9399] * iseq.c (iseq_load): keep type_map to get rid of memory leak. based on a patch by Eric Wong at [ruby-core:59699]. [Bug #9399] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ iseq.c | 8 ++++++++ ruby_atomic.h | 5 +++++ version.h | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9323ed5ae5a684..5ccf2fc5bdb7ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 13:26:57 2014 Nobuyoshi Nakada + + * iseq.c (iseq_load): keep type_map to get rid of memory leak. + based on a patch by Eric Wong at [ruby-core:59699]. [Bug #9399] + Sat Feb 22 13:17:32 2014 Masaki Matsushita * ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS diff --git a/iseq.c b/iseq.c index 679bdb7a2de1da..22081a1ee29516 100644 --- a/iseq.c +++ b/iseq.c @@ -483,6 +483,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) VALUE type, body, locals, args, exception; st_data_t iseq_type; + static struct st_table *type_map_cache = 0; struct st_table *type_map = 0; rb_iseq_t *iseq; rb_compile_option_t option; @@ -523,7 +524,9 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) iseq->self = iseqval; iseq->local_iseq = iseq; + type_map = type_map_cache; if (type_map == 0) { + struct st_table *cached_map; type_map = st_init_numtable(); st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP); st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD); @@ -534,6 +537,11 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL); st_insert(type_map, ID2SYM(rb_intern("main")), ISEQ_TYPE_MAIN); st_insert(type_map, ID2SYM(rb_intern("defined_guard")), ISEQ_TYPE_DEFINED_GUARD); + cached_map = ATOMIC_PTR_CAS(type_map_cache, (struct st_table *)0, type_map); + if (cached_map) { + st_free_table(type_map); + type_map = cached_map; + } } if (st_lookup(type_map, type, &iseq_type) == 0) { diff --git a/ruby_atomic.h b/ruby_atomic.h index 69efbdc4c4c651..789efdc4eaae2a 100644 --- a/ruby_atomic.h +++ b/ruby_atomic.h @@ -161,5 +161,10 @@ atomic_size_exchange(size_t *ptr, size_t val) # define ATOMIC_PTR_EXCHANGE(var, val) (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val)) # endif #endif +#ifndef ATOMIC_PTR_CAS +# if SIZEOF_VOIDP == SIZEOF_SIZE_T +# define ATOMIC_PTR_CAS(var, oldval, val) (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val)) +# endif +#endif #endif /* RUBY_ATOMIC_H */ diff --git a/version.h b/version.h index 2bb33993f50434..d1b63ae75b591f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 51 +#define RUBY_PATCHLEVEL 52 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From cf3896bf771859581ac2b1ffc90df06502985cfa Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:05:22 +0000 Subject: [PATCH 58/83] merge revision(s) 44931: [Backport #9452] * vm_insnhelper.c (vm_call_method): should check ci->me->flag of a refining method in case the method is private. [ruby-core:60111] [Bug #9452] * vm_method.c (make_method_entry_refined): set me->flag of a refined method entry to NOEX_PUBLIC in case the original method is private and it is refined as a public method. The original flag is stored in me->def->body.orig_me, so it's OK to make a refined method entry public. [ruby-core:60111] [Bug #9452] * test/ruby/test_refinement.rb: related tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 +++++++++++ test/ruby/test_refinement.rb | 45 ++++++++++++++++++++++++++++++++++++ version.h | 2 +- vm_insnhelper.c | 7 ++---- vm_method.c | 1 + 5 files changed, 63 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ccf2fc5bdb7ba..08d12fbc7bd0db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Sat Feb 22 13:49:30 2014 Shugo Maeda + + * vm_insnhelper.c (vm_call_method): should check ci->me->flag of + a refining method in case the method is private. + [ruby-core:60111] [Bug #9452] + + * vm_method.c (make_method_entry_refined): set me->flag of a refined + method entry to NOEX_PUBLIC in case the original method is private + and it is refined as a public method. The original flag is stored + in me->def->body.orig_me, so it's OK to make a refined method + entry public. [ruby-core:60111] [Bug #9452] + + * test/ruby/test_refinement.rb: related tests. + Sat Feb 22 13:26:57 2014 Nobuyoshi Nakada * iseq.c (iseq_load): keep type_map to get rid of memory leak. diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 07a325c1b847e5..d535c474241d5d 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1107,6 +1107,51 @@ def foo INPUT end + def test_adding_private_method + bug9452 = '[ruby-core:60111] [Bug #9452]' + + assert_in_out_err([], <<-INPUT, ["Success!", "NoMethodError"], [], bug9452) + module R + refine Object do + def m + puts "Success!" + end + + private(:m) + end + end + + using R + + m + 42.m rescue p($!.class) + INPUT + end + + def test_making_private_method_public + bug9452 = '[ruby-core:60111] [Bug #9452]' + + assert_in_out_err([], <<-INPUT, ["Success!", "Success!"], [], bug9452) + class Object + private + def m + end + end + + module R + refine Object do + def m + puts "Success!" + end + end + end + + using R + m + 42.m + INPUT + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index d1b63ae75b591f..0bfd038f5d161b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 52 +#define RUBY_PATCHLEVEL 53 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index edf4e46652dc37..1228b3f4df6976 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1829,7 +1829,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) ci->me = me; ci->defined_class = defined_class; if (me->def->type != VM_METHOD_TYPE_REFINED) { - goto normal_method_dispatch; + goto start_method_dispatch; } } @@ -1838,11 +1838,8 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) ci->me = ci->me->def->body.orig_me; if (UNDEFINED_METHOD_ENTRY_P(ci->me)) { ci->me = 0; - goto start_method_dispatch; - } - else { - goto normal_method_dispatch; } + goto start_method_dispatch; } else { klass = ci->me->klass; diff --git a/vm_method.c b/vm_method.c index fce8add6ef078d..ecded4aa2fcc68 100644 --- a/vm_method.c +++ b/vm_method.c @@ -212,6 +212,7 @@ make_method_entry_refined(rb_method_entry_t *me) *new_def->body.orig_me = *me; rb_vm_check_redefinition_opt_method(me, me->klass); if (me->def) me->def->alias_count++; + me->flag = NOEX_WITH_SAFE(NOEX_PUBLIC); me->def = new_def; } From 650f200077bf38aec086d3cba63b17e3f11042dc Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:14:42 +0000 Subject: [PATCH 59/83] merge revision(s) 44884: [Backport #9498] * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): Raise DecodeError if no data before the limit. Reported by Will Bryant. [ruby-core:60557] [Bug #9498] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/resolv.rb | 3 +++ version.h | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 08d12fbc7bd0db..96988353be026b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 14:07:04 2014 Tanaka Akira + + * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): Raise + DecodeError if no data before the limit. + Reported by Will Bryant. [ruby-core:60557] [Bug #9498] + Sat Feb 22 13:49:30 2014 Shugo Maeda * vm_insnhelper.c (vm_call_method): should check ci->me->flag of diff --git a/lib/resolv.rb b/lib/resolv.rb index 0c2b68ec27c687..ed12764a1b56e0 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1520,6 +1520,7 @@ def get_length16 end def get_bytes(len = @limit - @index) + raise DecodeError.new("limit exceeded") if @limit < @index + len d = @data[@index, len] @index += len return d @@ -1547,6 +1548,7 @@ def get_unpack(template) end def get_string + raise DecodeError.new("limit exceeded") if @limit <= @index len = @data[@index].ord raise DecodeError.new("limit exceeded") if @limit < @index + 1 + len d = @data[@index + 1, len] @@ -1570,6 +1572,7 @@ def get_labels(limit=nil) limit = @index if !limit || @index < limit d = [] while true + raise DecodeError.new("limit exceeded") if @limit <= @index case @data[@index].ord when 0 @index += 1 diff --git a/version.h b/version.h index 0bfd038f5d161b..2b6e8e1b919150 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 53 +#define RUBY_PATCHLEVEL 54 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From e8c1c968058dcec69fba617de380d5c455b3f838 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:20:38 +0000 Subject: [PATCH 60/83] merge revision(s) 44880: [Backport #9477] * lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on socket creation. Reported by Bjoern Rennhak. [ruby-core:60442] [Bug #9477] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/resolv.rb | 16 ++++++++++++---- version.h | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96988353be026b..be680377bc36a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 14:18:35 2014 Tanaka Akira + + * lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on + socket creation. + Reported by Bjoern Rennhak. [ruby-core:60442] [Bug #9477] + Sat Feb 22 14:07:04 2014 Tanaka Akira * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): Raise diff --git a/lib/resolv.rb b/lib/resolv.rb index ed12764a1b56e0..ee21c9c8434c16 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -522,8 +522,9 @@ def fetch_resource(name, typeclass) msg.rd = 1 msg.add_question(candidate, typeclass) unless sender = senders[[candidate, nameserver, port]] - sender = senders[[candidate, nameserver, port]] = - requester.sender(msg, candidate, nameserver, port) + sender = requester.sender(msg, candidate, nameserver, port) + next if !sender + senders[[candidate, nameserver, port]] = sender end reply, reply_name = requester.request(sender, tout) case reply.rcode @@ -741,7 +742,11 @@ def initialize(*nameserver_port) af = Socket::AF_INET end next if @socks_hash[bind_host] - sock = UDPSocket.new(af) + begin + sock = UDPSocket.new(af) + rescue Errno::EAFNOSUPPORT + next # The kernel doesn't support the address family. + end sock.do_not_reverse_lookup = true sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD DNS.bind_random_port(sock, bind_host) @@ -756,11 +761,12 @@ def recv_reply(readable_socks) end def sender(msg, data, host, port=Port) + sock = @socks_hash[host.index(':') ? "::" : "0.0.0.0"] + return nil if !sock service = [host, port] id = DNS.allocate_request_id(host, port) request = msg.encode request[0,2] = [id].pack('n') - sock = @socks_hash[host.index(':') ? "::" : "0.0.0.0"] return @senders[[service, id]] = Sender.new(request, data, sock, host, port) end @@ -781,6 +787,7 @@ def initialize(msg, data, sock, host, port) attr_reader :data def send + raise "@sock is nil." if @sock.nil? @sock.send(@msg, 0, @host, @port) end end @@ -824,6 +831,7 @@ def close class Sender < Requester::Sender # :nodoc: def send + raise "@sock is nil." if @sock.nil? @sock.send(@msg, 0) end attr_reader :data diff --git a/version.h b/version.h index 2b6e8e1b919150..c82cf8823e2d97 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 54 +#define RUBY_PATCHLEVEL 55 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 10be2aa5c0f9e89603bea412cf62eb8ae300076a Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:39:58 +0000 Subject: [PATCH 61/83] merge revision(s) 44585: [Backport #9268] * lib/net/smtp.rb: [DOC] Remove dead link to RAA by Giorgos Tsiftsis Fixes the following bugs: [Bug #9152] [Bug #9268] [Bug #9394] * lib/open-uri.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/net/smtp.rb | 5 +++-- lib/open-uri.rb | 2 +- version.h | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index be680377bc36a3..d34a096e4d58bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 14:31:23 2014 Zachary Scott + + * lib/net/smtp.rb: [DOC] Remove dead link to RAA by Giorgos Tsiftsis + Fixes the following bugs: [Bug #9152] [Bug #9268] [Bug #9394] + * lib/open-uri.rb: ditto + Sat Feb 22 14:18:35 2014 Tanaka Akira * lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index f49e38b283fa01..5fd4f8e5c5a5b2 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -76,8 +76,9 @@ class SMTPUnsupportedCommand < ProtocolError # # This library does NOT provide functions to compose internet mails. # You must create them by yourself. If you want better mail support, - # try RubyMail or TMail. You can get both libraries from RAA. - # (http://www.ruby-lang.org/en/raa.html) + # try RubyMail or TMail or search for alternatives in + # {RubyGems.org}[https://rubygems.org/] or {The Ruby + # Toolbox}[https://www.ruby-toolbox.com/]. # # FYI: the official documentation on internet mail is: [RFC2822] (http://www.ietf.org/rfc/rfc2822.txt). # diff --git a/lib/open-uri.rb b/lib/open-uri.rb index b1a253841d65a9..86aa0f1887b939 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -73,7 +73,7 @@ def open(name, *rest, &block) # :doc: # The environment variables such as http_proxy, https_proxy and ftp_proxy # are in effect by default. Here we disable proxy: # -# open("http://www.ruby-lang.org/en/raa.html", :proxy => nil) {|f| +# open("http://www.ruby-lang.org/en/", :proxy => nil) {|f| # # ... # } # diff --git a/version.h b/version.h index c82cf8823e2d97..28cfdff7933651 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 55 +#define RUBY_PATCHLEVEL 56 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From f9fb834b818a3abbac5d22f11370ca0190a05688 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:46:06 +0000 Subject: [PATCH 62/83] merge revision(s) 44586: [Backport #9152] * lib/xmlrpc/client.rb: [DOC] Remove note about SSL package on RAA Since RAA has been deprecated, and the SSL package has been replaced with net/https this statement is entirely false and should be deleted. [Bug #9152] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/xmlrpc/client.rb | 2 -- version.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d34a096e4d58bc..21c38b1e706a03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Feb 22 14:45:36 2014 Zachary Scott + + * lib/xmlrpc/client.rb: [DOC] Remove note about SSL package on RAA + Since RAA has been deprecated, and the SSL package has been replaced + with net/https this statement is entirely false and should be + deleted. [Bug #9152] + Sat Feb 22 14:31:23 2014 Zachary Scott * lib/net/smtp.rb: [DOC] Remove dead link to RAA by Giorgos Tsiftsis diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb index a0d2a13557c20e..5ee3961f3018d7 100644 --- a/lib/xmlrpc/client.rb +++ b/lib/xmlrpc/client.rb @@ -77,8 +77,6 @@ class Client # # If +use_ssl+ is set to +true+, communication over SSL is enabled. # - # Note, that you need the SSL package from RAA installed. - # # Parameter +timeout+ is the time to wait for a XML-RPC response, defaults to 30. def initialize(host=nil, path=nil, port=nil, proxy_host=nil, proxy_port=nil, user=nil, password=nil, use_ssl=nil, timeout=nil) diff --git a/version.h b/version.h index 28cfdff7933651..a21924efeb1ff8 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 56 +#define RUBY_PATCHLEVEL 57 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From cb38be4176ee5032d10048bb9cb1cfc4b3f6000b Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 05:56:02 +0000 Subject: [PATCH 63/83] merge revision(s) 44584,44587,44945: [Backport #9243] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Szテシcs [Bug #9243] * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Sz?cs [Bug #9243] * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Szuecs [Bug #9243] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/openssl/ossl_pkey_dh.c | 3 +-- version.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21c38b1e706a03..260f0a144f51f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Feb 22 14:52:55 2014 Zachary Scott + + * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Szuecs [Bug #9243] + Sat Feb 22 14:45:36 2014 Zachary Scott * lib/xmlrpc/client.rb: [DOC] Remove note about SSL package on RAA diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c index a6ae0063f5b338..011b6f00b4b7b3 100644 --- a/ext/openssl/ossl_pkey_dh.c +++ b/ext/openssl/ossl_pkey_dh.c @@ -621,7 +621,7 @@ Init_ossl_dh() * * === Example of a key exchange * dh1 = OpenSSL::PKey::DH.new(2048) - * params = dh1.public_key.to_der #you may send this publicly to the participating party + * der = dh1.public_key.to_der #you may send this publicly to the participating party * dh2 = OpenSSL::PKey::DH.new(der) * dh2.generate_key! #generate the per-session key pair * symm_key1 = dh1.compute_key(dh2.pub_key) @@ -664,4 +664,3 @@ Init_ossl_dh() { } #endif /* NO_DH */ - diff --git a/version.h b/version.h index a21924efeb1ff8..09566e32997e97 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 57 +#define RUBY_PATCHLEVEL 58 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 957bd7683ae9fa741edc00144af0a50f6aec02f7 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:01:44 +0000 Subject: [PATCH 64/83] merge revision(s) 44642: [Backport #9093] * lib/resolv.rb (Resolv::DNS::Resource::TXT#data): Return concatenated string. Patch by Ryan Brunner. [ruby-core:58220] [Bug #9093] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/resolv.rb | 4 ++-- version.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 260f0a144f51f4..aea157baa6b63c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 15:01:21 2014 Tanaka Akira + + * lib/resolv.rb (Resolv::DNS::Resource::TXT#data): Return concatenated + string. + Patch by Ryan Brunner. [ruby-core:58220] [Bug #9093] + Sat Feb 22 14:52:55 2014 Zachary Scott * ext/openssl/ossl_pkey_dh.c: Fixed typo by Sandor Szuecs [Bug #9243] diff --git a/lib/resolv.rb b/lib/resolv.rb index ee21c9c8434c16..6b2fa9d90333e2 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1974,10 +1974,10 @@ def initialize(first_string, *rest_strings) attr_reader :strings ## - # Returns the first string from +strings+. + # Returns the concatenated string from +strings+. def data - @strings[0] + @strings.join("") end def encode_rdata(msg) # :nodoc: diff --git a/version.h b/version.h index 09566e32997e97..57bd213e7ea8df 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 58 +#define RUBY_PATCHLEVEL 59 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From bda92e9c78a572fe2e785eac5ac998efc4e7f699 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:04:51 +0000 Subject: [PATCH 65/83] merge revision(s) 44463: [Backport #9210] * variable.c: adding extra example in docs. patched by Steve Klabnik. [Bug #9210] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ variable.c | 5 +++-- version.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index aea157baa6b63c..6ef6b3e9dfcfa0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 15:03:05 2014 Ayumu AIZAWA + + * variable.c: adding extra example in docs. + patched by Steve Klabnik. [Bug #9210] + Sat Feb 22 15:01:21 2014 Tanaka Akira * lib/resolv.rb (Resolv::DNS::Resource::TXT#data): Return concatenated diff --git a/variable.c b/variable.c index 350bb582db343b..424730dcb9dced 100644 --- a/variable.c +++ b/variable.c @@ -2517,8 +2517,9 @@ cvar_list(void *data) * class Two < One * @@var2 = 2 * end - * One.class_variables #=> [:@@var1] - * Two.class_variables #=> [:@@var2, :@@var1] + * One.class_variables #=> [:@@var1] + * Two.class_variables #=> [:@@var2, :@@var1] + * Two.class_variables(false) #=> [:@@var2] */ VALUE diff --git a/version.h b/version.h index 57bd213e7ea8df..2edc89841cb2f3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 59 +#define RUBY_PATCHLEVEL 60 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 8f7b41024e70a159404d0251fb5f4fef0848b555 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:06:55 +0000 Subject: [PATCH 66/83] merge revision(s) 44878,44879: [Backport #9483] * ext/ripper/lib/ripper/lexer.rb: [DOC] use lower case version of core classes when referring to return value, since we aren't directly talking about the class. Patch by Jonathan Jackson [Bug #9483] * lib/open-uri.rb: [DOC] use lower case version of core classes, same as commit r44878, based on patch by Jonathan Jackson [Bug #9483] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ ext/ripper/lib/ripper/lexer.rb | 4 ++-- lib/open-uri.rb | 5 +++-- version.h | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ef6b3e9dfcfa0..703a9d0069f05d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Sat Feb 22 15:06:32 2014 Zachary Scott + + * lib/open-uri.rb: [DOC] use lower case version of core classes, same + as commit r44878, based on patch by Jonathan Jackson [Bug #9483] + +Sat Feb 22 15:06:32 2014 Zachary Scott + + * ext/ripper/lib/ripper/lexer.rb: [DOC] use lower case version of core + classes when referring to return value, since we aren't directly + talking about the class. Patch by Jonathan Jackson [Bug #9483] + Sat Feb 22 15:03:05 2014 Ayumu AIZAWA * variable.c: adding extra example in docs. diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb index 5c99dfe8fa2961..c0a64d1ee592ac 100644 --- a/ext/ripper/lib/ripper/lexer.rb +++ b/ext/ripper/lib/ripper/lexer.rb @@ -12,7 +12,7 @@ class Ripper - # Tokenizes the Ruby program and returns an Array of String. + # Tokenizes the Ruby program and returns an array of strings. # # p Ripper.tokenize("def m(a) nil end") # # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"] @@ -21,7 +21,7 @@ def Ripper.tokenize(src, filename = '-', lineno = 1) Lexer.new(src, filename, lineno).tokenize end - # Tokenizes the Ruby program and returns an Array of an Array, + # Tokenizes the Ruby program and returns an array of an array, # which is formatted like [[lineno, column], type, token]. # # require 'ripper' diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 86aa0f1887b939..26eb1a364e12c1 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -534,8 +534,9 @@ def charset end end - # returns a list of encodings in Content-Encoding field - # as an Array of String. + # Returns a list of encodings in Content-Encoding field as an array of + # strings. + # # The encodings are downcased for canonicalization. def content_encoding vs = @metas['content-encoding'] diff --git a/version.h b/version.h index 2edc89841cb2f3..88cb8dc92bd4d7 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 60 +#define RUBY_PATCHLEVEL 61 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 52ed9b4805116e33395fce6524fe6904959cd035 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:11:15 +0000 Subject: [PATCH 67/83] merge revision(s) 44696: [Backport #9429] * lib/racc/rdoc/grammar.en.rdoc: [DOC] Correct grammar and typos Patch by Giorgos Tsiftsis [Bug #9429] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++ lib/racc/rdoc/grammar.en.rdoc | 81 ++++++++++++++++------------------- version.h | 2 +- 3 files changed, 43 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 703a9d0069f05d..cf8ac26fdadee2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 15:07:58 2014 Zachary Scott + + * lib/racc/rdoc/grammar.en.rdoc: [DOC] Correct grammar and typos + Patch by Giorgos Tsiftsis [Bug #9429] [ci skip] + Sat Feb 22 15:06:32 2014 Zachary Scott * lib/open-uri.rb: [DOC] use lower case version of core classes, same diff --git a/lib/racc/rdoc/grammar.en.rdoc b/lib/racc/rdoc/grammar.en.rdoc index b667a7cb5ece7d..a154246ee58592 100644 --- a/lib/racc/rdoc/grammar.en.rdoc +++ b/lib/racc/rdoc/grammar.en.rdoc @@ -4,14 +4,12 @@ == Class Block and User Code Block -There's two block on toplevel. -one is 'class' block, another is 'user code' block. 'user code' block MUST -places after 'class' block. +There are two blocks on toplevel. One is 'class' block, another is 'user code' +block. 'user code' block MUST be placed after 'class' block. -== Comment +== Comments -You can insert comment about all places. Two style comment can be used, -Ruby style (#.....) and C style (/*......*/) . +You can insert comments about all places. Two style comments can be used, Ruby style '#.....' and C style '/\*......*\/'. == Class Block @@ -19,19 +17,19 @@ The class block is formed like this: class CLASS_NAME [precedance table] - [token declearations] - [expected number of S/R conflict] + [token declarations] + [expected number of S/R conflicts] [options] [semantic value convertion] [start rule] rule GRAMMARS -CLASS_NAME is a name of parser class. -This is the name of generating parser class. +CLASS_NAME is a name of parser class. This is the name of generating parser +class. -If CLASS_NAME includes '::', Racc outputs module clause. -For example, writing "class M::C" causes creating the code bellow: +If CLASS_NAME includes '::', Racc outputs module clause. For example, writing +"class M::C" causes creating the code bellow: module M class C @@ -42,8 +40,8 @@ For example, writing "class M::C" causes creating the code bellow: == Grammar Block -The grammar block discripts grammar which is able -to be understood by parser. Syntax is: +The grammar block describes grammar which is able to be understood by parser. +Syntax is: (token): (token) (token) (token).... (action) @@ -59,28 +57,27 @@ to be understood by parser. Syntax is: Note that you cannot use '%' string, here document, '%r' regexp in action. -Actions can be omitted. -When it is omitted, '' (empty string) is used. +Actions can be omitted. When it is omitted, '' (empty string) is used. -A return value of action is a value of left side value ($$). -It is value of result, or returned value by "return" statement. +A return value of action is a value of left side value ($$). It is value of +result, or returned value by `return` statement. Here is an example of whole grammar block. rule - goal: definition ruls source { result = val } + goal: definition rules source { result = val } definition: /* none */ { result = [] } | definition startdesig { result[0] = val[1] } | definition - precrule # this line continue from upper line + precrule # this line continues from upper line { result[1] = val[1] } startdesig: START TOKEN -You can use following special local variables in action. +You can use the following special local variables in action: * result ($$) @@ -92,8 +89,7 @@ An array of value of right-hand side (rhs). * _values (...$-2,$-1,$0) -A stack of values. -DO NOT MODIFY this stack unless you know what you are doing. +A stack of values. DO NOT MODIFY this stack unless you know what you are doing. == Operator Precedence @@ -107,9 +103,9 @@ To designate this block: right '=' preclow -`right' is yacc's %right, `left' is yacc's %left. +`right` is yacc's %right, `left` is yacc's %left. -`=' + (symbol) means yacc's %prec: +`=` + (symbol) means yacc's %prec: prechigh nonassoc UMINUS @@ -136,22 +132,22 @@ Racc has bison's "expect" directive. : : -This directive declears "expected" number of shift/reduce conflict. -If "expected" number is equal to real number of conflicts, -racc does not print confliction warning message. +This directive declares "expected" number of shift/reduce conflicts. If +"expected" number is equal to real number of conflicts, Racc does not print +conflict warning message. == Declaring Tokens -By declaring tokens, you can avoid many meanless bugs. -If decleared token does not exist/existing token does not decleared, -Racc output warnings. Declearation syntax is: +By declaring tokens, you can avoid many meaningless bugs. If declared token +does not exist or existing token does not decleared, Racc output warnings. +Declaration syntax is: token TOKEN_NAME AND_IS_THIS ALSO_THIS_IS AGAIN_AND_AGAIN THIS_IS_LAST == Options -You can write options for racc command in your racc file. +You can write options for Racc command in your Racc file. options OPTION OPTION ... @@ -159,19 +155,19 @@ Options are: * omit_action_call -omit empty action call or not. +omits empty action call or not. * result_var -use/does not use local variable "result" +uses local variable "result" or not. -You can use 'no_' prefix to invert its meanings. +You can use 'no_' prefix to invert their meanings. == Converting Token Symbol Token symbols are, as default, - * naked token string in racc file (TOK, XFILE, this_is_token, ...) + * naked token string in Racc file (TOK, XFILE, this_is_token, ...) --> symbol (:TOK, :XFILE, :this_is_token, ...) * quoted string (':', '.', '(', ...) --> same string (':', '.', '(', ...) @@ -185,7 +181,7 @@ Here is an example: end We can use almost all ruby value can be used by token symbol, -except 'false' and 'nil'. These are causes unexpected parse error. +except 'false' and 'nil'. These cause unexpected parse error. If you want to use String as token symbol, special care is required. For example: @@ -202,12 +198,10 @@ For example: start real_target -This statement will not be used forever, I think. - == User Code Block -"User Code Block" is a Ruby source code which is copied to output. -There are three user code block, "header" "inner" and "footer". +"User Code Block" is a Ruby source code which is copied to output. There are +three user code blocks, "header" "inner" and "footer". Format of user code is like this: @@ -221,6 +215,5 @@ Format of user code is like this: : : -If four '-' exist on line head, -racc treat it as beginning of user code block. -A name of user code must be one word. +If four '-' exist on line head, Racc treat it as beginning of user code block. +The name of user code block must be one word. diff --git a/version.h b/version.h index 88cb8dc92bd4d7..e6f197f5b0cec3 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 61 +#define RUBY_PATCHLEVEL 62 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From b3445c00d36dbe17b68760e3f1d28487018fd9fd Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 06:16:18 +0000 Subject: [PATCH 68/83] merge revision(s) 44549: [Backport #9387] * range.c (Range#size): [DOC] improve description and add examples. Patch by @skade. [Fixes GH-501] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ range.c | 5 ++++- version.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf8ac26fdadee2..46dd38ba571333 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 15:13:38 2014 Benoit Daloze + + * range.c (Range#size): [DOC] improve description and add examples. + Patch by @skade. [Fixes GH-501] + Sat Feb 22 15:07:58 2014 Zachary Scott * lib/racc/rdoc/grammar.en.rdoc: [DOC] Correct grammar and typos diff --git a/range.c b/range.c index 4526dcba895172..d2d9a707c07fed 100644 --- a/range.c +++ b/range.c @@ -711,9 +711,12 @@ sym_each_i(RB_BLOCK_CALL_FUNC_ARGLIST(v, arg)) * call-seq: * rng.size -> num * - * Returns the number of elements in the range. + * Returns the number of elements in the range. Both the begin and the end of + * the Range must be Numeric, otherwise nil is returned. * * (10..20).size #=> 11 + * ('a'..'z').size #=> nil + * (-Float::INFINITY..Float::INFINITY).size #=> Infinity */ static VALUE diff --git a/version.h b/version.h index e6f197f5b0cec3..5af029549aa023 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 62 +#define RUBY_PATCHLEVEL 63 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 61d12617ac983dfae11276a4e16c48134f94beeb Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:17:22 +0000 Subject: [PATCH 69/83] merge revision(s) 44670,44671,44673,44675: [Backport #8783] thread_pthread.c: timer thread stack size * thread_pthread.c (rb_thread_create_timer_thread): define the stack size for timer thread at compile time. * thread_pthread.c (rb_thread_create_timer_thread): expand timer thread stack size to get rid of segfault on FreeBSD/powerpc64. based on the patch by Steve Wills at [ruby-core:59923]. [ruby-core:56590] [Bug #8783] * thread_pthread.c (rb_thread_create_timer_thread): fix for platforms where PTHREAD_STACK_MIN is a dynamic value and not a compile-time constant. [ruby-dev:47911] [Bug #9436] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ thread_pthread.c | 17 ++++++++--------- version.h | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46dd38ba571333..cfda696fb2d01c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sat Feb 22 15:56:53 2014 Nobuyoshi Nakada + + * thread_pthread.c (rb_thread_create_timer_thread): fix for platforms + where PTHREAD_STACK_MIN is a dynamic value and not a compile-time + constant. [ruby-dev:47911] [Bug #9436] + +Sat Feb 22 15:56:53 2014 Nobuyoshi Nakada + + * thread_pthread.c (rb_thread_create_timer_thread): expand timer + thread stack size to get rid of segfault on FreeBSD/powerpc64. + based on the patch by Steve Wills at [ruby-core:59923]. + [ruby-core:56590] [Bug #8783] + Sat Feb 22 15:13:38 2014 Benoit Daloze * range.c (Range#size): [DOC] improve description and add examples. diff --git a/thread_pthread.c b/thread_pthread.c index 3e58ac5745aeba..aa8962a315fc5f 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1479,17 +1479,16 @@ rb_thread_create_timer_thread(void) exit(EXIT_FAILURE); } # ifdef PTHREAD_STACK_MIN - if (PTHREAD_STACK_MIN < 4096 * 3) { + { + const size_t min_size = (4096 * 4); /* Allocate the machine stack for the timer thread - * at least 12KB (3 pages). FreeBSD 8.2 AMD64 causes - * machine stack overflow only with PTHREAD_STACK_MIN. + * at least 16KB (4 pages). FreeBSD 8.2 AMD64 causes + * machine stack overflow only with PTHREAD_STACK_MIN. */ - pthread_attr_setstacksize(&attr, - 4096 * 3 + (THREAD_DEBUG ? BUFSIZ : 0)); - } - else { - pthread_attr_setstacksize(&attr, - PTHREAD_STACK_MIN + (THREAD_DEBUG ? BUFSIZ : 0)); + size_t stack_size = PTHREAD_STACK_MIN; /* may be dynamic, get only once */ + if (stack_size < min_size) stack_size = min_size; + if (THREAD_DEBUG) stack_size += BUFSIZ; + pthread_attr_setstacksize(&attr, stack_size); } # endif #endif diff --git a/version.h b/version.h index 5af029549aa023..6a9765c01c56af 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 63 +#define RUBY_PATCHLEVEL 64 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From dc8c558ac281a451d2e207b13da5b1922c95bf64 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:19:41 +0000 Subject: [PATCH 70/83] merge revision(s) 45066: [Backport #9545] [Backport #9550] * ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error (bsock_recvmsg_internal): ditto * test/socket/test_unix.rb: test above for infinite loop git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/socket/ancdata.c | 18 ++++++++---------- test/socket/test_unix.rb | 23 +++++++++++++++++++++++ version.h | 2 +- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index cfda696fb2d01c..4d1a6ac9ba57c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 16:17:54 2014 Eric Wong + + * ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error + (bsock_recvmsg_internal): ditto + * test/socket/test_unix.rb: test above for infinite loop + Sat Feb 22 15:56:53 2014 Nobuyoshi Nakada * thread_pthread.c (rb_thread_create_timer_thread): fix for platforms diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index 9a68a0c2893b3e..bbbf985e2834e1 100644 --- a/ext/socket/ancdata.c +++ b/ext/socket/ancdata.c @@ -1280,12 +1280,11 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock) ss = rb_sendmsg(fptr->fd, &mh, flags); - if (!nonblock && rb_io_wait_writable(fptr->fd)) { - rb_io_check_closed(fptr); - goto retry; - } - if (ss == -1) { + if (!nonblock && rb_io_wait_writable(fptr->fd)) { + rb_io_check_closed(fptr); + goto retry; + } if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN)) rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "sendmsg(2) would block"); rb_sys_fail("sendmsg(2)"); @@ -1595,12 +1594,11 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock) ss = rb_recvmsg(fptr->fd, &mh, flags); - if (!nonblock && rb_io_wait_readable(fptr->fd)) { - rb_io_check_closed(fptr); - goto retry; - } - if (ss == -1) { + if (!nonblock && rb_io_wait_readable(fptr->fd)) { + rb_io_check_closed(fptr); + goto retry; + } if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN)) rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvmsg(2) would block"); #if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index 38d8333f2a0669..f10c5efaf84018 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -5,6 +5,7 @@ require "test/unit" require "tempfile" +require "timeout" require "tmpdir" require "thread" require "io/nonblock" @@ -369,6 +370,28 @@ def test_dgram_pair s2.close if s2 end + def test_dgram_pair_sendrecvmsg_errno_set + s1, s2 = to_close = UNIXSocket.pair(Socket::SOCK_DGRAM) + pipe = IO.pipe + to_close.concat(pipe) + set_errno = lambda do + begin + pipe[0].read_nonblock(1) + fail + rescue => e + assert(IO::EAGAINWaitReadable === e) + end + end + Timeout.timeout(10) do + set_errno.call + assert_equal(2, s1.sendmsg("HI")) + set_errno.call + assert_equal("HI", s2.recvmsg[0]) + end + ensure + to_close.each(&:close) if to_close + end + def test_epipe # [ruby-dev:34619] s1, s2 = UNIXSocket.pair s1.shutdown(Socket::SHUT_WR) diff --git a/version.h b/version.h index 6a9765c01c56af..b0527e9a72e022 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 64 +#define RUBY_PATCHLEVEL 65 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From c3729ca38f62d0d0712ef6aecf447c80c9bbeec8 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:22:12 +0000 Subject: [PATCH 71/83] merge revision(s) 44772: [Backport #9430] benchmark/driver: avoid large alloc in driver process * benchmark/driver: avoid large alloc in driver process [ruby-core:59869] [Bug #9430] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- benchmark/driver.rb | 2 +- version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/driver.rb b/benchmark/driver.rb index 695dc41afff0c9..cbc72cf604f26c 100644 --- a/benchmark/driver.rb +++ b/benchmark/driver.rb @@ -242,7 +242,7 @@ def measure executable, file cmd = "#{executable} #{@ruby_arg} #{file}" m = Benchmark.measure{ - `#{cmd}` + system(cmd, out: File::NULL) } if $? != 0 diff --git a/version.h b/version.h index b0527e9a72e022..54fd73d42b6335 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 65 +#define RUBY_PATCHLEVEL 66 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From bed9d6c7137f234abad684517ccfc99f1675b5d1 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:50:05 +0000 Subject: [PATCH 72/83] merge revision(s) 44731,44751: [Backport #8978] * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. [ruby-core:57599] [Bug #8978]. Thanks mame! * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. [ruby-core:57599] [Bug #8978]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ ext/fiddle/closure.c | 4 ++-- version.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d1a6ac9ba57c8..e813fd6bd4c2f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Sat Feb 22 16:34:12 2014 Yusuke Endoh + + * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. + [ruby-core:57599] [Bug #8978]. + +Sat Feb 22 16:34:12 2014 Aaron Patterson + + * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. + [ruby-core:57599] [Bug #8978]. Thanks mame! + Sat Feb 22 16:17:54 2014 Eric Wong * ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index 121a08ea19f7da..e0f7e4b12d3475 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -27,7 +27,7 @@ dealloc(void * ptr) #if USE_FFI_CLOSURE_ALLOC ffi_closure_free(cls->pcl); #else - munmap(cls->pcl, sizeof(cls->pcl)); + munmap(cls->pcl, sizeof(*cls->pcl)); #endif if (cls->argv) xfree(cls->argv); xfree(cls); @@ -234,7 +234,7 @@ initialize(int rbargc, VALUE argv[], VALUE self) #else result = ffi_prep_closure(pcl, cif, callback, (void *)self); cl->code = (void *)pcl; - i = mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC); + i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC); if (i) { rb_sys_fail("mprotect"); } diff --git a/version.h b/version.h index 54fd73d42b6335..bbc2601900fced 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 66 +#define RUBY_PATCHLEVEL 67 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 42ffa2e13c16567a086f3b298e4e3c165e45357f Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 07:53:33 +0000 Subject: [PATCH 73/83] merge revision(s) 44514: [Backport #9374] * ext/json/generator/depend: add build dependencies for json extension [Bug #9374] [ruby-core:59609] * ext/json/parser/depend: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/json/generator/depend | 1 + ext/json/parser/depend | 1 + version.h | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e813fd6bd4c2f4..f0c9ca031324c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 22 16:51:36 2014 Eric Wong + + * ext/json/generator/depend: add build dependencies for json extension + [Bug #9374] [ruby-core:59609] + * ext/json/parser/depend: ditto + Sat Feb 22 16:34:12 2014 Yusuke Endoh * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. diff --git a/ext/json/generator/depend b/ext/json/generator/depend index 1a042a2501eb2d..593a8fbb543db0 100644 --- a/ext/json/generator/depend +++ b/ext/json/generator/depend @@ -1 +1,2 @@ +$(OBJS): $(ruby_headers) generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h diff --git a/ext/json/parser/depend b/ext/json/parser/depend index 498ffa964cdc82..d188844670f0d4 100644 --- a/ext/json/parser/depend +++ b/ext/json/parser/depend @@ -1 +1,2 @@ +$(OBJS): $(ruby_headers) parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h diff --git a/version.h b/version.h index bbc2601900fced..bfcb361b41be70 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 67 +#define RUBY_PATCHLEVEL 68 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 5d59efcc81f593a0269c66615a159b5c03111514 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 08:38:43 +0000 Subject: [PATCH 74/83] merge revision(s) 44628: [Backport #9413] * eval.c (rb_mod_s_constants): return its own constants for other than Module itself. [ruby-core:59763] [Bug #9413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 4 ++-- test/ruby/test_module.rb | 13 +++++++++++++ version.h | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0c9ca031324c1..8abc8943b86102 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 17:33:39 2014 Nobuyoshi Nakada + + * eval.c (rb_mod_s_constants): return its own constants for other + than Module itself. [ruby-core:59763] [Bug #9413] + Sat Feb 22 16:51:36 2014 Eric Wong * ext/json/generator/depend: add build dependencies for json extension diff --git a/eval.c b/eval.c index 3a0206f24ab8c2..841b3671e3b794 100644 --- a/eval.c +++ b/eval.c @@ -380,8 +380,8 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod) VALUE cbase = 0; void *data = 0; - if (argc > 0) { - return rb_mod_constants(argc, argv, rb_cModule); + if (argc > 0 || mod != rb_cModule) { + return rb_mod_constants(argc, argv, mod); } while (cref) { diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 4f834f0c1e3fb1..ba6f273159063b 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -866,6 +866,19 @@ def test_mod_constants m.instance_eval { remove_const(:Foo) } end + class Bug9413 + class << self + Foo = :foo + end + end + + def test_singleton_constants + bug9413 = '[ruby-core:59763] [Bug #9413]' + c = Bug9413.singleton_class + assert_include(c.constants(true), :Foo, bug9413) + assert_include(c.constants(false), :Foo, bug9413) + end + def test_frozen_class m = Module.new m.freeze diff --git a/version.h b/version.h index bfcb361b41be70..6de4c639a78dd6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 68 +#define RUBY_PATCHLEVEL 69 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From e16f765ada21d3afa937d05ab88bc76d38ef2613 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 08:54:43 +0000 Subject: [PATCH 75/83] merge revision(s) 44637: [Backport #9385] * lib/open-uri.rb: Make proxy disabling working again. Fixed by Christophe Philemotte. [ruby-core:59650] [Bug #9385] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/open-uri.rb | 2 +- version.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8abc8943b86102..3faeda326bb8b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 17:46:32 2014 Tanaka Akira + + * lib/open-uri.rb: Make proxy disabling working again. + Fixed by Christophe Philemotte. [ruby-core:59650] [Bug #9385] + Sat Feb 22 17:33:39 2014 Nobuyoshi Nakada * eval.c (rb_mod_s_constants): return its own constants for other diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 26eb1a364e12c1..264c8501cf284e 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -288,7 +288,7 @@ def OpenURI.open_http(buf, target, proxy, options) # :nodoc: end end - http = klass.new(target_host, target_port) + http = proxy ? klass.new(target_host, target_port) : klass.new(target_host, target_port, nil) if target.class == URI::HTTPS require 'net/https' http.use_ssl = true diff --git a/version.h b/version.h index 6de4c639a78dd6..d3149d7c03f2c5 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 69 +#define RUBY_PATCHLEVEL 70 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From ada0c632cc86298f87e2c068d6cd047392e09747 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 09:24:49 +0000 Subject: [PATCH 76/83] merge revision(s) 45057,45059: [Backport #9533] * hash.c (rb_hash_flatten): fix behavior of flatten(-1). [ruby-dev:47988] [Bug #9533] * test/ruby/test_array.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ hash.c | 25 ++++++++++++++++++------- test/ruby/test_hash.rb | 4 ++-- version.h | 2 +- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3faeda326bb8b6..e0be9a55326c6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Feb 22 18:20:58 2014 Masaki Matsushita + + * hash.c (rb_hash_flatten): fix behavior of flatten(-1). + [ruby-dev:47988] [Bug #9533] + + * test/ruby/test_array.rb: test for above. + Sat Feb 22 17:46:32 2014 Tanaka Akira * lib/open-uri.rb: Make proxy disabling working again. diff --git a/hash.c b/hash.c index 1c285c2b232df2..db510c818ec4af 100644 --- a/hash.c +++ b/hash.c @@ -67,7 +67,7 @@ rb_hash_freeze(VALUE hash) VALUE rb_cHash; static VALUE envtbl; -static ID id_hash, id_yield, id_default; +static ID id_hash, id_yield, id_default, id_flatten_bang; VALUE rb_hash_set_ifnone(VALUE hash, VALUE ifnone) @@ -2399,15 +2399,25 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash) { VALUE ary; - ary = rb_ary_new_capa(RHASH_SIZE(hash) * 2); - rb_hash_foreach(hash, flatten_i, ary); if (argc) { - int level = NUM2INT(*argv) - 1; - if (level > 0) { - *argv = INT2FIX(level); - rb_funcall2(ary, rb_intern("flatten!"), argc, argv); + int level = NUM2INT(*argv); + if (level == 0) return rb_hash_to_a(hash); + + ary = rb_ary_new_capa(RHASH_SIZE(hash) * 2); + rb_hash_foreach(hash, flatten_i, ary); + if (level - 1 > 0) { + *argv = INT2FIX(level - 1); + rb_funcall2(ary, id_flatten_bang, argc, argv); } + else if (level < 0) { + rb_funcall2(ary, id_flatten_bang, 0, 0); + } + } + else { + ary = rb_ary_new_capa(RHASH_SIZE(hash) * 2); + rb_hash_foreach(hash, flatten_i, ary); } + return ary; } @@ -3757,6 +3767,7 @@ Init_Hash(void) id_hash = rb_intern("hash"); id_yield = rb_intern("yield"); id_default = rb_intern("default"); + id_flatten_bang = rb_intern("flatten!"); rb_cHash = rb_define_class("Hash", rb_cObject); diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index c872b11a3c6c97..800241a70389af 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -973,11 +973,11 @@ def test_flatten a = @cls[1=> "one", 2 => [2,"two"], 3 => [3, ["three"]]] assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten) - assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(-1)) - assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(0)) + assert_equal([[1, "one"], [2, [2, "two"]], [3, [3, ["three"]]]], a.flatten(0)) assert_equal([1, "one", 2, [2, "two"], 3, [3, ["three"]]], a.flatten(1)) assert_equal([1, "one", 2, 2, "two", 3, 3, ["three"]], a.flatten(2)) assert_equal([1, "one", 2, 2, "two", 3, 3, "three"], a.flatten(3)) + assert_equal([1, "one", 2, 2, "two", 3, 3, "three"], a.flatten(-1)) assert_raise(TypeError){ a.flatten(Object) } end diff --git a/version.h b/version.h index d3149d7c03f2c5..52c4bf043e235d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 70 +#define RUBY_PATCHLEVEL 71 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 8a059b476185345651ef2bfc13d858b9b484c746 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 09:53:35 +0000 Subject: [PATCH 77/83] merge revision(s) 45076: [Backport #9535] * class.c (rb_mod_init_copy): do nothing if copying self. [ruby-dev:47989] [Bug #9535] * hash.c (rb_hash_initialize_copy): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ class.c | 2 +- ext/bigdecimal/bigdecimal.c | 4 +++- ext/json/generator/generator.c | 1 + ext/zlib/zlib.c | 1 + hash.c | 2 ++ test/ruby/test_hash.rb | 6 ++++++ test/ruby/test_module.rb | 11 +++++++++++ version.h | 2 +- 9 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0be9a55326c6b..b61a02d11ee543 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Feb 22 18:48:57 2014 Nobuyoshi Nakada + + * class.c (rb_mod_init_copy): do nothing if copying self. + [ruby-dev:47989] [Bug #9535] + + * hash.c (rb_hash_initialize_copy): ditto. + Sat Feb 22 18:20:58 2014 Masaki Matsushita * hash.c (rb_hash_flatten): fix behavior of flatten(-1). diff --git a/class.c b/class.c index e161e25063ff94..bf9b2bb43e5d63 100644 --- a/class.c +++ b/class.c @@ -321,7 +321,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig) if (RB_TYPE_P(clone, T_CLASS)) { class_init_copy_check(clone, orig); } - rb_obj_init_copy(clone, orig); + if (!OBJ_INIT_COPY(clone, orig)) return clone; if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) { RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig)); rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone); diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 8c470fc2b77d82..4120a2346dc948 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2481,7 +2481,9 @@ BigDecimal_initialize_copy(VALUE self, VALUE other) Real *pv = rb_check_typeddata(self, &BigDecimal_data_type); Real *x = rb_check_typeddata(other, &BigDecimal_data_type); - DATA_PTR(self) = VpCopy(pv, x); + if (self != other) { + DATA_PTR(self) = VpCopy(pv, x); + } return self; } diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c index ed7bb8288758f2..550e9beef0bd28 100644 --- a/ext/json/generator/generator.c +++ b/ext/json/generator/generator.c @@ -965,6 +965,7 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig) { JSON_Generator_State *objState, *origState; + if (obj == orig) return obj; Data_Get_Struct(obj, JSON_Generator_State, objState); Data_Get_Struct(orig, JSON_Generator_State, origState); if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State"); diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 391bec17226f8a..ffdd9a0b7d51d2 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -1556,6 +1556,7 @@ rb_deflate_init_copy(VALUE self, VALUE orig) Data_Get_Struct(self, struct zstream, z1); z2 = get_zstream(orig); + if (z1 == z2) return self; err = deflateCopy(&z1->stream, &z2->stream); if (err != Z_OK) { raise_zlib_error(err, 0); diff --git a/hash.c b/hash.c index db510c818ec4af..66cd94bcddc96e 100644 --- a/hash.c +++ b/hash.c @@ -1428,6 +1428,8 @@ rb_hash_initialize_copy(VALUE hash, VALUE hash2) Check_Type(hash2, T_HASH); + if (hash == hash2) return hash; + ntbl = RHASH(hash)->ntbl; if (RHASH(hash2)->ntbl) { if (ntbl) st_free_table(ntbl); diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 800241a70389af..0bbdf13a07698f 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -108,6 +108,12 @@ def test_clear_initialize_copy assert_empty(h) end + def test_self_initialize_copy + h = @cls[1=>2] + h.instance_eval {initialize_copy(h)} + assert_equal(2, h[1]) + end + def test_dup_will_rehash set1 = @cls[] set2 = @cls[set1 => true] diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index ba6f273159063b..f89071c10f270b 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -364,6 +364,17 @@ def test_constants assert_equal([:MIXIN, :USER], User.constants.sort) end + def test_self_initialize_copy + bug9535 = '[ruby-dev:47989] [Bug #9535]' + m = Module.new do + def foo + :ok + end + initialize_copy(self) + end + assert_equal(:ok, Object.new.extend(m).foo, bug9535) + end + def test_dup bug6454 = '[ruby-core:45132]' diff --git a/version.h b/version.h index 52c4bf043e235d..2138e5e758896d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 71 +#define RUBY_PATCHLEVEL 72 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From f577abf00cf2d1bc15488bc815f7cffe5e6b0367 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 10:03:49 +0000 Subject: [PATCH 78/83] merge revision(s) 45084: [Backport #9547] * ext/socket/init.c (wait_connectable): break if the socket is writable to avoid infinite loops on FreeBSD and other platforms which conforms to SUSv3. This problem cannot be reproduced with loopback interfaces, so it's hard to write test code. rsock_connect() and wait_connectable() are overly complicated, so they should be refactored, but I commit this fix as a workaround for the release of Ruby 1.9.3 scheduled on Feb 24. [ruby-core:60940] [Bug #9547] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ ext/socket/init.c | 8 ++++++-- version.h | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b61a02d11ee543..2fdbeb26d076c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Sat Feb 22 18:55:08 2014 Shugo Maeda + + * ext/socket/init.c (wait_connectable): break if the socket is + writable to avoid infinite loops on FreeBSD and other platforms + which conforms to SUSv3. This problem cannot be reproduced with + loopback interfaces, so it's hard to write test code. + rsock_connect() and wait_connectable() are overly complicated, so + they should be refactored, but I commit this fix as a workaround + for the release of Ruby 1.9.3 scheduled on Feb 24. + [ruby-core:60940] [Bug #9547] + Sat Feb 22 18:48:57 2014 Nobuyoshi Nakada * class.c (rb_mod_init_copy): do nothing if copying self. diff --git a/ext/socket/init.c b/ext/socket/init.c index 6d98a66d6e8573..d3b875c78dffce 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -323,8 +323,12 @@ wait_connectable(int fd) */ if (ret < 0) break; - if (sockerr == 0) - continue; /* workaround for winsock */ + if (sockerr == 0) { + if (revents & RB_WAITFD_OUT) + break; + else + continue; /* workaround for winsock */ + } /* BSD and Linux use sockerr. */ errno = sockerr; diff --git a/version.h b/version.h index 2138e5e758896d..2a60d15ec871b9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 72 +#define RUBY_PATCHLEVEL 73 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 0025fef5e2a91ba5a7964baee5794d7b8edb9912 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 13:13:24 +0000 Subject: [PATCH 79/83] merge revision(s) 44412,44413,44414,44420,44421: [Backport #9298] test_method.rb, test_proc.rb: suppress warnings * test/ruby/test_method.rb: suppress warnings in verbose mode. * test/ruby/test_proc.rb: ditto. * proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if having rest keywords argument. [ruby-core:53298] [Bug #8072] * iseq.c (rb_iseq_parameters): push argument type symbol only for unnamed rest keywords argument. * compile.c (iseq_set_arguments): set arg_keyword_check from nd_cflag, which is set by parser. internal ID is used for unnamed keyword rest argument, which should be separated from no keyword check. * iseq.c (rb_iseq_parameters): if no keyword check, keyword rest is present. * parse.y (new_args_tail_gen): set keywords check to nd_cflag, which equals to that keyword rest is not present. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 23 ++++++++++++++++ compile.c | 2 +- iseq.c | 2 +- parse.y | 7 ++++- proc.c | 2 +- test/ruby/test_keyword.rb | 9 +++++++ test/ruby/test_method.rb | 57 ++++++++++++++++++++++++++++++++++++--- test/ruby/test_proc.rb | 34 ++++++++++++++++++++++- version.h | 2 +- 9 files changed, 129 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2fdbeb26d076c4..b67f54aef6eba2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Sat Feb 22 21:56:26 2014 Nobuyoshi Nakada + + * compile.c (iseq_set_arguments): set arg_keyword_check from + nd_cflag, which is set by parser. internal ID is used for + unnamed keyword rest argument, which should be separated from no + keyword check. + + * iseq.c (rb_iseq_parameters): if no keyword check, keyword rest is + present. + + * parse.y (new_args_tail_gen): set keywords check to nd_cflag, which + equals to that keyword rest is not present. + +Sat Feb 22 21:56:26 2014 Nobuyoshi Nakada + + * iseq.c (rb_iseq_parameters): push argument type symbol only for + unnamed rest keywords argument. + +Sat Feb 22 21:56:26 2014 Nobuyoshi Nakada + + * proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if + having rest keywords argument. [ruby-core:53298] [Bug #8072] + Sat Feb 22 18:55:08 2014 Shugo Maeda * ext/socket/init.c (wait_connectable): break if the socket is diff --git a/compile.c b/compile.c index 3d6a4627e9f475..e96a9829d4fdb3 100644 --- a/compile.c +++ b/compile.c @@ -1203,7 +1203,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args) node = node->nd_next; i += 1; } - iseq->arg_keyword_check = (args->kw_rest_arg->nd_vid & ID_SCOPE_MASK) == ID_JUNK; + iseq->arg_keyword_check = args->kw_rest_arg->nd_cflag != 0; iseq->arg_keywords = i; iseq->arg_keyword_required = r; iseq->arg_keyword_table = ALLOC_N(ID, i); diff --git a/iseq.c b/iseq.c index 22081a1ee29516..32d996796429f9 100644 --- a/iseq.c +++ b/iseq.c @@ -2023,7 +2023,7 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc) } rb_ary_push(args, a); } - if (rb_id2str(iseq->local_table[iseq->arg_keyword])) { + if (!iseq->arg_keyword_check) { CONST_ID(keyrest, "keyrest"); rb_ary_push(args, PARAM(iseq->arg_keyword, keyrest)); } diff --git a/parse.y b/parse.y index eb5ed547d335a4..25946dccda974f 100644 --- a/parse.y +++ b/parse.y @@ -9486,6 +9486,7 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b) struct rb_args_info *args; NODE *kw_rest_arg = 0; NODE *node; + int check = 0; args = ALLOC(struct rb_args_info); MEMZERO(args, struct rb_args_info, 1); @@ -9493,10 +9494,14 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b) args->block_arg = b; args->kw_args = k; - if (k && !kr) kr = internal_id(); + if (k && !kr) { + check = 1; + kr = internal_id(); + } if (kr) { arg_var(kr); kw_rest_arg = NEW_DVAR(kr); + kw_rest_arg->nd_cflag = check; } args->kw_rest_arg = kw_rest_arg; diff --git a/proc.c b/proc.c index e52beaf9d813d4..78851ac54749f1 100644 --- a/proc.c +++ b/proc.c @@ -825,7 +825,7 @@ proc_arity(VALUE self) static inline int rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max) { - *max = iseq->arg_rest == -1 ? + *max = (iseq->arg_rest == -1 && iseq->arg_keyword == -1) ? iseq->argc + iseq->arg_post_len + iseq->arg_opts - (iseq->arg_opts > 0) : UNLIMITED_ARGUMENTS; return iseq->argc + iseq->arg_post_len; diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 7e708454ae580b..03b93dbf0d0b58 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -117,6 +117,15 @@ def test_f9 assert_equal([1, 2, [3, 4], 5, :key, {str: "bar"}, nil], f9(1, 2, 3, 4, 5, str: "bar")) end + def f10(a: 1, **) + a + end + + def test_f10 + assert_equal(42, f10(a: 42)) + assert_equal(1, f10(b: 42)) + end + def test_method_parameters assert_equal([[:key, :str], [:key, :num]], method(:f1).parameters); assert_equal([[:req, :x], [:key, :str], [:key, :num]], method(:f2).parameters); diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 1652c91d4f1c75..2e3c2ae8b07317 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -22,7 +22,14 @@ def mo4(a, *b, &c) end def mo5(a, *b, c) end def mo6(a, *b, c, &d) end def mo7(a, b = nil, *c, d, &e) end - def ma1((a), &b) end + def ma1((a), &b) nil && a end + def mk1(**) end + def mk2(**o) nil && o end + def mk3(a, **o) nil && o end + def mk4(a = nil, **o) nil && o end + def mk5(a, b = nil, **o) nil && o end + def mk6(a, b = nil, c, **o) nil && o end + def mk7(a, b = nil, *c, d, **o) nil && o end class Base def foo() :base end @@ -68,6 +75,13 @@ def test_arity assert_equal(-2, method(:mo4).arity) assert_equal(-3, method(:mo5).arity) assert_equal(-3, method(:mo6).arity) + assert_equal(-1, method(:mk1).arity) + assert_equal(-1, method(:mk2).arity) + assert_equal(-2, method(:mk3).arity) + assert_equal(-1, method(:mk4).arity) + assert_equal(-2, method(:mk5).arity) + assert_equal(-3, method(:mk6).arity) + assert_equal(-3, method(:mk7).arity) end def test_arity_special @@ -293,7 +307,7 @@ def a end end - assert_nothing_raised do + assert_nothing_raised(bug8686) do m.define_singleton_method(:a, m.method(:a)) end end @@ -456,7 +470,14 @@ def test_default_accessibility define_method(:pmo5) {|a, *b, c|} define_method(:pmo6) {|a, *b, c, &d|} define_method(:pmo7) {|a, b = nil, *c, d, &e|} - define_method(:pma1) {|(a), &b|} + define_method(:pma1) {|(a), &b| nil && a} + define_method(:pmk1) {|**|} + define_method(:pmk2) {|**o|} + define_method(:pmk3) {|a, **o|} + define_method(:pmk4) {|a = nil, **o|} + define_method(:pmk5) {|a, b = nil, **o|} + define_method(:pmk6) {|a, b = nil, c, **o|} + define_method(:pmk7) {|a, b = nil, *c, d, **o|} def test_bound_parameters assert_equal([], method(:m0).parameters) @@ -470,6 +491,13 @@ def test_bound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:mo6).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:mo7).parameters) assert_equal([[:req], [:block, :b]], method(:ma1).parameters) + assert_equal([[:keyrest]], method(:mk1).parameters) + assert_equal([[:keyrest, :o]], method(:mk2).parameters) + assert_equal([[:req, :a], [:keyrest, :o]], method(:mk3).parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], method(:mk4).parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:mk5).parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:mk6).parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:mk7).parameters) end def test_unbound_parameters @@ -484,6 +512,13 @@ def test_unbound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:mo6).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:mo7).parameters) assert_equal([[:req], [:block, :b]], self.class.instance_method(:ma1).parameters) + assert_equal([[:keyrest]], self.class.instance_method(:mk1).parameters) + assert_equal([[:keyrest, :o]], self.class.instance_method(:mk2).parameters) + assert_equal([[:req, :a], [:keyrest, :o]], self.class.instance_method(:mk3).parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], self.class.instance_method(:mk4).parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:mk5).parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:mk6).parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:mk7).parameters) end def test_bmethod_bound_parameters @@ -498,6 +533,13 @@ def test_bmethod_bound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).parameters) assert_equal([[:req], [:block, :b]], method(:pma1).parameters) + assert_equal([[:keyrest]], method(:pmk1).parameters) + assert_equal([[:keyrest, :o]], method(:pmk2).parameters) + assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).parameters) end def test_bmethod_unbound_parameters @@ -512,6 +554,14 @@ def test_bmethod_unbound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:pmo6).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:pmo7).parameters) assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters) + assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters) + assert_equal([[:keyrest]], self.class.instance_method(:pmk1).parameters) + assert_equal([[:keyrest, :o]], self.class.instance_method(:pmk2).parameters) + assert_equal([[:req, :a], [:keyrest, :o]], self.class.instance_method(:pmk3).parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], self.class.instance_method(:pmk4).parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:pmk5).parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:pmk6).parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:pmk7).parameters) end def test_public_method_with_zsuper_method @@ -659,6 +709,7 @@ def foo prepend m } assert_raise(NameError, bug7988) {Module.new{prepend m}.instance_method(:bar)} + true || c || bug7836 end def test_gced_bmethod diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index b40485f5821752..206e21fb1a8bfd 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -77,6 +77,13 @@ def test_arity assert_equal(2, proc{|(x, y), z|[x,y]}.arity) assert_equal(1, proc{|(x, y), z=0|[x,y]}.arity) assert_equal(-4, proc{|x, *y, z, a|}.arity) + assert_equal(-1, proc{|**|}.arity) + assert_equal(-1, proc{|**o|}.arity) + assert_equal(-2, proc{|x, **o|}.arity) + assert_equal(-1, proc{|x=0, **o|}.arity) + assert_equal(-2, proc{|x, y=0, **o|}.arity) + assert_equal(-3, proc{|x, y=0, z, **o|}.arity) + assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity) assert_equal(0, lambda{}.arity) assert_equal(0, lambda{||}.arity) @@ -95,6 +102,13 @@ def test_arity assert_equal(2, lambda{|(x, y), z|[x,y]}.arity) assert_equal(-2, lambda{|(x, y), z=0|[x,y]}.arity) assert_equal(-4, lambda{|x, *y, z, a|}.arity) + assert_equal(-1, lambda{|**|}.arity) + assert_equal(-1, lambda{|**o|}.arity) + assert_equal(-2, lambda{|x, **o|}.arity) + assert_equal(-1, lambda{|x=0, **o|}.arity) + assert_equal(-2, lambda{|x, y=0, **o|}.arity) + assert_equal(-3, lambda{|x, y=0, z, **o|}.arity) + assert_equal(-3, lambda{|x, y=0, *z, w, **o|}.arity) assert_arity(0) {} assert_arity(0) {||} @@ -104,6 +118,10 @@ def test_arity assert_arity(-3) {|x, *y, z|} assert_arity(-1) {|*x|} assert_arity(-1) {|*|} + assert_arity(-1) {|**o|} + assert_arity(-1) {|**|} + assert_arity(-2) {|x, *y, **|} + assert_arity(-3) {|x, *y, z, **|} end def m(x) @@ -1086,6 +1104,13 @@ def pmo5(a, *b, c) end def pmo6(a, *b, c, &d) end def pmo7(a, b = :b, *c, d, &e) end def pma1((a), &b) a; end + def pmk1(**) end + def pmk2(**o) nil && o end + def pmk3(a, **o) nil && o end + def pmk4(a = nil, **o) nil && o end + def pmk5(a, b = nil, **o) nil && o end + def pmk6(a, b = nil, c, **o) nil && o end + def pmk7(a, b = nil, *c, d, **o) nil && o end def test_bound_parameters @@ -1100,6 +1125,13 @@ def test_bound_parameters assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).to_proc.parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).to_proc.parameters) assert_equal([[:req], [:block, :b]], method(:pma1).to_proc.parameters) + assert_equal([[:keyrest]], method(:pmk1).to_proc.parameters) + assert_equal([[:keyrest, :o]], method(:pmk2).to_proc.parameters) + assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).to_proc.parameters) + assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).to_proc.parameters) + assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).to_proc.parameters) assert_equal([], "".method(:upcase).to_proc.parameters) assert_equal([[:rest]], "".method(:gsub).to_proc.parameters) @@ -1209,7 +1241,7 @@ def test_overridden_proc end def get_binding if: 1, case: 2, when: 3, begin: 4, end: 5 - a = 0 + a ||= 0 binding end diff --git a/version.h b/version.h index 2a60d15ec871b9..46079c17a3930c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 73 +#define RUBY_PATCHLEVEL 74 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From aac2d826a21e83b341d3c2b783a1cef25f85e286 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 22 Feb 2014 13:27:49 +0000 Subject: [PATCH 80/83] merge revision(s) 45130: [Backport #9554] * ext/io/console/console.c (console_dev): need read access for conout$ because some functions need it. [Bug#9554] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/io/console/console.c | 2 +- version.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b67f54aef6eba2..9a7196639cb723 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 22 22:26:43 2014 NAKAMURA Usaku + + * ext/io/console/console.c (console_dev): need read access for conout$ + because some functions need it. [Bug#9554] + Sat Feb 22 21:56:26 2014 Nobuyoshi Nakada * compile.c (iseq_set_arguments): set arg_keyword_check from diff --git a/ext/io/console/console.c b/ext/io/console/console.c index f3379ffd8d1542..de5ca825583bd0 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -710,7 +710,7 @@ console_dev(VALUE klass) int fd; #ifdef CONSOLE_DEVICE_FOR_WRITING - fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_WRONLY, 0); + fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0); if (fd < 0) return Qnil; rb_update_max_fd(fd); args[1] = INT2FIX(O_WRONLY); diff --git a/version.h b/version.h index 46079c17a3930c..f7be648b3928a9 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 74 +#define RUBY_PATCHLEVEL 75 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 From 67a696c55949d2cf50483b4c728e97a7e4106165 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 24 Feb 2014 04:24:15 +0000 Subject: [PATCH 81/83] merge revision(s) 44809,44811,44813,44815,44816,44817,44818,44918,45003: [Backport #9482] * ext/psych/yaml/emitter.c: merge libyaml 0.1.5 * ext/psych/yaml/loader.c: ditto * ext/psych/yaml/parser.c: ditto * ext/psych/yaml/reader.c: ditto * ext/psych/yaml/scanner.c: ditto * ext/psych/yaml/writer.c: ditto * ext/psych/yaml/yaml_private.h: ditto * ext/psych/lib/psych.rb: New release of psych. * ext/psych/psych.gemspec: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 ++++++++ ext/psych/lib/psych.rb | 2 +- ext/psych/psych.gemspec | 9 +++-- ext/psych/yaml/api.c | 55 +++++++++++++++++++--------- ext/psych/yaml/config.h | 8 ++--- ext/psych/yaml/emitter.c | 10 +++--- ext/psych/yaml/loader.c | 33 +++++++++++++++-- ext/psych/yaml/parser.c | 12 +++---- ext/psych/yaml/reader.c | 4 +++ ext/psych/yaml/scanner.c | 68 ++++++++++++++++++++--------------- ext/psych/yaml/yaml_private.h | 20 ++++++++++- version.h | 6 ++-- 12 files changed, 167 insertions(+), 75 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a7196639cb723..def33cbe32aab1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Mon Feb 24 13:05:48 2014 Aaron Patterson + + * ext/psych/lib/psych.rb: New release of psych. + * ext/psych/psych.gemspec: ditto + +Mon Feb 24 13:05:48 2014 Aaron Patterson + + * ext/psych/yaml/emitter.c: merge libyaml 0.1.5 + * ext/psych/yaml/loader.c: ditto + * ext/psych/yaml/parser.c: ditto + * ext/psych/yaml/reader.c: ditto + * ext/psych/yaml/scanner.c: ditto + * ext/psych/yaml/writer.c: ditto + * ext/psych/yaml/yaml_private.h: ditto + Sat Feb 22 22:26:43 2014 NAKAMURA Usaku * ext/io/console/console.c (console_dev): need read access for conout$ diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb index 45e01c5fd19666..4b422f56449b38 100644 --- a/ext/psych/lib/psych.rb +++ b/ext/psych/lib/psych.rb @@ -217,7 +217,7 @@ module Psych # The version is Psych you're using - VERSION = '2.0.2' + VERSION = '2.0.3' # The version of libyaml Psych is using LIBYAML_VERSION = Psych.libyaml_version.join '.' diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec index ca751a033dcaed..100b6ff73720ad 100644 --- a/ext/psych/psych.gemspec +++ b/ext/psych/psych.gemspec @@ -2,23 +2,22 @@ Gem::Specification.new do |s| s.name = "psych" - s.version = "2.0.2" + s.version = "2.0.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib"] s.authors = ["Aaron Patterson"] - s.date = "2013-11-26" + s.date = "2014-02-04" s.description = "Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]\nfor its YAML parsing and emitting capabilities. In addition to wrapping\nlibyaml, Psych also knows how to serialize and de-serialize most Ruby objects\nto and from the YAML format." s.email = ["aaron@tenderlovemaking.com"] s.extensions = ["ext/psych/extconf.rb"] - s.extra_rdoc_files = ["CHANGELOG.rdoc", "Manifest.txt", "README.rdoc"] s.files = [".autotest", ".travis.yml", "CHANGELOG.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h", "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h", "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h", "ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c", "ext/psych/yaml/emitter.c", "ext/psych/yaml/loader.c", "ext/psych/yaml/parser.c", "ext/psych/yaml/reader.c", "ext/psych/yaml/scanner.c", "ext/psych/yaml/writer.c", "ext/psych/yaml/yaml.h", "ext/psych/yaml/yaml_private.h", "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/deprecated.rb", "lib/psych/exception.rb", "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb", "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb", "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb", "lib/psych/visitors.rb", "lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb", "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "test/psych/handlers/test_recorder.rb", "test/psych/helper.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_engine_manager.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/test_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "test/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb", ".gemtest"] s.homepage = "http://github.com/tenderlove/psych" s.licenses = ["MIT"] s.rdoc_options = ["--main", "README.rdoc"] - s.require_paths = ["lib"] s.required_ruby_version = Gem::Requirement.new(">= 1.9.2") s.rubyforge_project = "psych" - s.rubygems_version = "2.0.2" + s.rubygems_version = "2.2.1" s.summary = "Psych is a YAML parser and emitter" s.test_files = ["test/psych/handlers/test_recorder.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_engine_manager.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/test_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "test/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb"] end diff --git a/ext/psych/yaml/api.c b/ext/psych/yaml/api.c index 0c4732e1520d22..e0b9d979cc0596 100644 --- a/ext/psych/yaml/api.c +++ b/ext/psych/yaml/api.c @@ -395,7 +395,7 @@ yaml_emitter_delete(yaml_emitter_t *emitter) } QUEUE_DEL(emitter, emitter->events); STACK_DEL(emitter, emitter->indents); - while (!STACK_EMPTY(empty, emitter->tag_directives)) { + while (!STACK_EMPTY(emitter, emitter->tag_directives)) { yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives); yaml_free(tag_directive.handle); yaml_free(tag_directive.prefix); @@ -822,6 +822,7 @@ yaml_scalar_event_initialize(yaml_event_t *event, yaml_char_t *anchor_copy = NULL; yaml_char_t *tag_copy = NULL; yaml_char_t *value_copy = NULL; + size_t value_length; assert(event); /* Non-NULL event object is expected. */ assert(value); /* Non-NULL anchor is expected. */ @@ -839,16 +840,19 @@ yaml_scalar_event_initialize(yaml_event_t *event, } if (length < 0) { - length = strlen((char *)value); + value_length = strlen((char *)value); + } + else { + value_length = (size_t)length; } - if (!yaml_check_utf8(value, length)) goto error; - value_copy = yaml_malloc(length+1); + if (!yaml_check_utf8(value, value_length)) goto error; + value_copy = yaml_malloc(value_length+1); if (!value_copy) goto error; - memcpy(value_copy, value, length); - value_copy[length] = '\0'; + memcpy(value_copy, value, value_length); + value_copy[value_length] = '\0'; - SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, length, + SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, value_length, plain_implicit, quoted_implicit, style, mark, mark); return 1; @@ -1202,6 +1206,8 @@ yaml_document_add_scalar(yaml_document_t *document, yaml_char_t *tag_copy = NULL; yaml_char_t *value_copy = NULL; yaml_node_t node; + size_t value_length; + ptrdiff_t ret; assert(document); /* Non-NULL document object is expected. */ assert(value); /* Non-NULL value is expected. */ @@ -1215,19 +1221,26 @@ yaml_document_add_scalar(yaml_document_t *document, if (!tag_copy) goto error; if (length < 0) { - length = strlen((char *)value); + value_length = strlen((char *)value); + } + else { + value_length = (size_t)length; } - if (!yaml_check_utf8(value, length)) goto error; - value_copy = yaml_malloc(length+1); + if (!yaml_check_utf8(value, value_length)) goto error; + value_copy = yaml_malloc(value_length+1); if (!value_copy) goto error; - memcpy(value_copy, value, length); - value_copy[length] = '\0'; + memcpy(value_copy, value, value_length); + value_copy[value_length] = '\0'; - SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark); + SCALAR_NODE_INIT(node, tag_copy, value_copy, value_length, style, mark, mark); if (!PUSH(&context, document->nodes, node)) goto error; - return document->nodes.top - document->nodes.start; + ret = document->nodes.top - document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (ret > INT_MAX) goto error; +#endif + return (int)ret; error: yaml_free(tag_copy); @@ -1255,6 +1268,7 @@ yaml_document_add_sequence(yaml_document_t *document, yaml_node_item_t *top; } items = { NULL, NULL, NULL }; yaml_node_t node; + ptrdiff_t ret; assert(document); /* Non-NULL document object is expected. */ @@ -1272,7 +1286,11 @@ yaml_document_add_sequence(yaml_document_t *document, style, mark, mark); if (!PUSH(&context, document->nodes, node)) goto error; - return document->nodes.top - document->nodes.start; + ret = document->nodes.top - document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (ret > INT_MAX) goto error; +#endif + return (int)ret; error: STACK_DEL(&context, items); @@ -1300,6 +1318,7 @@ yaml_document_add_mapping(yaml_document_t *document, yaml_node_pair_t *top; } pairs = { NULL, NULL, NULL }; yaml_node_t node; + ptrdiff_t ret; assert(document); /* Non-NULL document object is expected. */ @@ -1317,7 +1336,11 @@ yaml_document_add_mapping(yaml_document_t *document, style, mark, mark); if (!PUSH(&context, document->nodes, node)) goto error; - return document->nodes.top - document->nodes.start; + ret = document->nodes.top - document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (ret > INT_MAX) goto error; +#endif + return (int)ret; error: STACK_DEL(&context, pairs); diff --git a/ext/psych/yaml/config.h b/ext/psych/yaml/config.h index 6d6c25b3b104ea..fb62651340416d 100644 --- a/ext/psych/yaml/config.h +++ b/ext/psych/yaml/config.h @@ -1,11 +1,11 @@ #define PACKAGE_NAME "yaml" #define PACKAGE_TARNAME "yaml" -#define PACKAGE_VERSION "0.1.4" -#define PACKAGE_STRING "yaml 0.1.4" +#define PACKAGE_VERSION "0.1.5" +#define PACKAGE_STRING "yaml 0.1.5" #define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component libyaml" #define PACKAGE_URL "" #define YAML_VERSION_MAJOR 0 #define YAML_VERSION_MINOR 1 -#define YAML_VERSION_PATCH 4 -#define YAML_VERSION_STRING "0.1.4" +#define YAML_VERSION_PATCH 5 +#define YAML_VERSION_STRING "0.1.5" diff --git a/ext/psych/yaml/emitter.c b/ext/psych/yaml/emitter.c index c41a94a79f8837..bf84fafc511a5a 100644 --- a/ext/psych/yaml/emitter.c +++ b/ext/psych/yaml/emitter.c @@ -53,7 +53,7 @@ #define WRITE_BREAK(emitter,string) \ (FLUSH(emitter) \ && (CHECK(string,'\n') ? \ - (PUT_BREAK(emitter), \ + ((void)PUT_BREAK(emitter), \ string.pointer ++, \ 1) : \ (COPY(emitter->buffer,string), \ @@ -1493,7 +1493,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, int break_space = 0; int space_break = 0; - int preceded_by_whitespace = 0; + int preceeded_by_whitespace = 0; int followed_by_whitespace = 0; int previous_space = 0; int previous_break = 0; @@ -1524,7 +1524,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, flow_indicators = 1; } - preceded_by_whitespace = 1; + preceeded_by_whitespace = 1; followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); while (string.pointer != string.end) @@ -1570,7 +1570,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, } } - if (CHECK(string, '#') && preceded_by_whitespace) { + if (CHECK(string, '#') && preceeded_by_whitespace) { flow_indicators = 1; block_indicators = 1; } @@ -1619,7 +1619,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, previous_break = 0; } - preceded_by_whitespace = IS_BLANKZ(string); + preceeded_by_whitespace = IS_BLANKZ(string); MOVE(string); if (string.pointer != string.end) { followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); diff --git a/ext/psych/yaml/loader.c b/ext/psych/yaml/loader.c index 9d3d912663c328..cb3ea930891b90 100644 --- a/ext/psych/yaml/loader.c +++ b/ext/psych/yaml/loader.c @@ -283,9 +283,12 @@ static int yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event) { yaml_node_t node; + ptrdiff_t node_index; int index; yaml_char_t *tag = first_event->data.scalar.tag; + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; + if (!tag || strcmp((char *)tag, "!") == 0) { yaml_free(tag); tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG); @@ -298,7 +301,11 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event) if (!PUSH(parser, parser->document->nodes, node)) goto error; - index = parser->document->nodes.top - parser->document->nodes.start; + node_index = parser->document->nodes.top - parser->document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (node_index > INT_MAX) goto error; +#endif + index = (int)node_index; if (!yaml_parser_register_anchor(parser, index, first_event->data.scalar.anchor)) return 0; @@ -327,8 +334,11 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event) yaml_node_item_t *top; } items = { NULL, NULL, NULL }; int index, item_index; + ptrdiff_t node_index; yaml_char_t *tag = first_event->data.sequence_start.tag; + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; + if (!tag || strcmp((char *)tag, "!") == 0) { yaml_free(tag); tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG); @@ -343,7 +353,11 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event) if (!PUSH(parser, parser->document->nodes, node)) goto error; - index = parser->document->nodes.top - parser->document->nodes.start; + node_index = parser->document->nodes.top - parser->document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (node_index > INT_MAX) goto error; +#endif + index = (int)node_index; if (!yaml_parser_register_anchor(parser, index, first_event->data.sequence_start.anchor)) return 0; @@ -351,6 +365,9 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event) if (!yaml_parser_parse(parser, &event)) return 0; while (event.type != YAML_SEQUENCE_END_EVENT) { + if (!STACK_LIMIT(parser, + parser->document->nodes.start[index-1].data.sequence.items, + INT_MAX-1)) return 0; item_index = yaml_parser_load_node(parser, &event); if (!item_index) return 0; if (!PUSH(parser, @@ -384,9 +401,12 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event) yaml_node_pair_t *top; } pairs = { NULL, NULL, NULL }; int index; + ptrdiff_t node_index; yaml_node_pair_t pair; yaml_char_t *tag = first_event->data.mapping_start.tag; + if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error; + if (!tag || strcmp((char *)tag, "!") == 0) { yaml_free(tag); tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG); @@ -401,7 +421,11 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event) if (!PUSH(parser, parser->document->nodes, node)) goto error; - index = parser->document->nodes.top - parser->document->nodes.start; + node_index = parser->document->nodes.top - parser->document->nodes.start; +#if PTRDIFF_MAX > INT_MAX + if (node_index > INT_MAX) goto error; +#endif + index = (int)node_index; if (!yaml_parser_register_anchor(parser, index, first_event->data.mapping_start.anchor)) return 0; @@ -409,6 +433,9 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event) if (!yaml_parser_parse(parser, &event)) return 0; while (event.type != YAML_MAPPING_END_EVENT) { + if (!STACK_LIMIT(parser, + parser->document->nodes.start[index-1].data.mapping.pairs, + INT_MAX-1)) return 0; pair.key = yaml_parser_load_node(parser, &event); if (!pair.key) return 0; if (!yaml_parser_parse(parser, &event)) return 0; diff --git a/ext/psych/yaml/parser.c b/ext/psych/yaml/parser.c index dc5430b09fc27c..32671b252c23f1 100644 --- a/ext/psych/yaml/parser.c +++ b/ext/psych/yaml/parser.c @@ -759,9 +759,8 @@ yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser, else if (token->type == YAML_BLOCK_END_TOKEN) { - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ parser->state = POP(parser, parser->states); - dummy_mark = POP(parser, parser->marks); + (void)POP(parser, parser->marks); SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark); SKIP_TOKEN(parser); return 1; @@ -869,9 +868,8 @@ yaml_parser_parse_block_mapping_key(yaml_parser_t *parser, else if (token->type == YAML_BLOCK_END_TOKEN) { - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ parser->state = POP(parser, parser->states); - dummy_mark = POP(parser, parser->marks); + (void)POP(parser, parser->marks); MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); SKIP_TOKEN(parser); return 1; @@ -952,7 +950,6 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser, yaml_event_t *event, int first) { yaml_token_t *token; - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ if (first) { token = PEEK_TOKEN(parser); @@ -997,7 +994,7 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser, } parser->state = POP(parser, parser->states); - dummy_mark = POP(parser, parser->marks); + (void)POP(parser, parser->marks); SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark); SKIP_TOKEN(parser); return 1; @@ -1104,7 +1101,6 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, yaml_event_t *event, int first) { yaml_token_t *token; - yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */ if (first) { token = PEEK_TOKEN(parser); @@ -1158,7 +1154,7 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, } parser->state = POP(parser, parser->states); - dummy_mark = POP(parser, parser->marks); + (void)POP(parser, parser->marks); MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark); SKIP_TOKEN(parser); return 1; diff --git a/ext/psych/yaml/reader.c b/ext/psych/yaml/reader.c index 4e48add7b8813c..f1a06deb9d3a5b 100644 --- a/ext/psych/yaml/reader.c +++ b/ext/psych/yaml/reader.c @@ -460,6 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length) } + if (parser->offset >= PTRDIFF_MAX) + return yaml_parser_set_reader_error(parser, "input is too long", + PTRDIFF_MAX, -1); + return 1; } diff --git a/ext/psych/yaml/scanner.c b/ext/psych/yaml/scanner.c index 31fed0ed94dcda..34308d5d4540d7 100644 --- a/ext/psych/yaml/scanner.c +++ b/ext/psych/yaml/scanner.c @@ -615,11 +615,11 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser); */ static int -yaml_parser_roll_indent(yaml_parser_t *parser, int column, - int number, yaml_token_type_t type, yaml_mark_t mark); +yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column, + ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark); static int -yaml_parser_unroll_indent(yaml_parser_t *parser, int column); +yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column); /* * Token fetchers. @@ -1103,7 +1103,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser) */ int required = (!parser->flow_level - && parser->indent == (int)parser->mark.column); + && parser->indent == (ptrdiff_t)parser->mark.column); /* * A simple key is required only when it is the first token in the current @@ -1176,6 +1176,11 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser) /* Increase the flow level. */ + if (parser->flow_level == INT_MAX) { + parser->error = YAML_MEMORY_ERROR; + return 0; + } + parser->flow_level++; return 1; @@ -1188,11 +1193,9 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser) static int yaml_parser_decrease_flow_level(yaml_parser_t *parser) { - yaml_simple_key_t dummy_key; /* Used to eliminate a compiler warning. */ - if (parser->flow_level) { parser->flow_level --; - dummy_key = POP(parser, parser->simple_keys); + (void)POP(parser, parser->simple_keys); } return 1; @@ -1206,8 +1209,8 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser) */ static int -yaml_parser_roll_indent(yaml_parser_t *parser, int column, - int number, yaml_token_type_t type, yaml_mark_t mark) +yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column, + ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark) { yaml_token_t token; @@ -1226,7 +1229,14 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column, if (!PUSH(parser, parser->indents, parser->indent)) return 0; - parser->indent = column; +#if PTRDIFF_MAX > INT_MAX + if (column > INT_MAX) { + parser->error = YAML_MEMORY_ERROR; + return 0; + } +#endif + + parser->indent = (int)column; /* Create a token and insert it into the queue. */ @@ -1248,13 +1258,13 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column, /* * Pop indentation levels from the indents stack until the current level - * becomes less or equal to the column. For each indentation level, append + * becomes less or equal to the column. For each intendation level, append * the BLOCK-END token. */ static int -yaml_parser_unroll_indent(yaml_parser_t *parser, int column) +yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column) { yaml_token_t token; @@ -1263,7 +1273,7 @@ yaml_parser_unroll_indent(yaml_parser_t *parser, int column) if (parser->flow_level) return 1; - /* Loop through the indentation levels in the stack. */ + /* Loop through the intendation levels in the stack. */ while (parser->indent > column) { @@ -2574,7 +2584,7 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive, /* Resize the string to include the head. */ - while (string.end - string.start <= (int)length) { + while ((size_t)(string.end - string.start) <= length) { if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) { parser->error = YAML_MEMORY_ERROR; goto error; @@ -2769,15 +2779,15 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, if (IS_DIGIT(parser->buffer)) { - /* Check that the indentation is greater than 0. */ + /* Check that the intendation is greater than 0. */ if (CHECK(parser->buffer, '0')) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an indentation indicator equal to 0"); + start_mark, "found an intendation indicator equal to 0"); goto error; } - /* Get the indentation level and eat the indicator. */ + /* Get the intendation level and eat the indicator. */ increment = AS_DIGIT(parser->buffer); @@ -2791,7 +2801,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, { if (CHECK(parser->buffer, '0')) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an indentation indicator equal to 0"); + start_mark, "found an intendation indicator equal to 0"); goto error; } @@ -2841,7 +2851,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, end_mark = parser->mark; - /* Set the indentation level if it was specified. */ + /* Set the intendation level if it was specified. */ if (increment) { indent = parser->indent >= 0 ? parser->indent+increment : increment; @@ -2907,7 +2917,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, if (!READ_LINE(parser, leading_break)) goto error; - /* Eat the following indentation spaces and line breaks. */ + /* Eat the following intendation spaces and line breaks. */ if (!yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark)) goto error; @@ -2942,8 +2952,8 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token, } /* - * Scan indentation spaces and line breaks for a block scalar. Determine the - * indentation level if needed. + * Scan intendation spaces and line breaks for a block scalar. Determine the + * intendation level if needed. */ static int @@ -2955,11 +2965,11 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, *end_mark = parser->mark; - /* Eat the indentation spaces and line breaks. */ + /* Eat the intendation spaces and line breaks. */ while (1) { - /* Eat the indentation spaces. */ + /* Eat the intendation spaces. */ if (!CACHE(parser, 1)) return 0; @@ -2972,12 +2982,12 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, if ((int)parser->mark.column > max_indent) max_indent = (int)parser->mark.column; - /* Check for a tab character messing the indentation. */ + /* Check for a tab character messing the intendation. */ if ((!*indent || (int)parser->mark.column < *indent) && IS_TAB(parser->buffer)) { return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found a tab character where an indentation space is expected"); + start_mark, "found a tab character where an intendation space is expected"); } /* Have we found a non-empty line? */ @@ -3498,12 +3508,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) { if (IS_BLANK(parser->buffer)) { - /* Check for tab character that abuse indentation. */ + /* Check for tab character that abuse intendation. */ if (leading_blanks && (int)parser->mark.column < indent && IS_TAB(parser->buffer)) { yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", - start_mark, "found a tab character that violates indentation"); + start_mark, "found a tab character that violate intendation"); goto error; } @@ -3536,7 +3546,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token) if (!CACHE(parser, 1)) goto error; } - /* Check indentation level. */ + /* Check intendation level. */ if (!parser->flow_level && (int)parser->mark.column < indent) break; diff --git a/ext/psych/yaml/yaml_private.h b/ext/psych/yaml/yaml_private.h index af10c839735237..cd3d3a56c4b4e6 100644 --- a/ext/psych/yaml/yaml_private.h +++ b/ext/psych/yaml/yaml_private.h @@ -10,6 +10,17 @@ #include #include +#include + +#ifndef _MSC_VER +#include +#else +#ifdef _WIN64 +#define PTRDIFF_MAX _I64_MAX +#else +#define PTRDIFF_MAX INT_MAX +#endif +#endif /* * Memory management. @@ -422,7 +433,14 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end); (stack).start = (stack).top = (stack).end = 0) #define STACK_EMPTY(context,stack) \ - ((stack).start == (stack).top) + ((void)(context), \ + ((stack).start == (stack).top)) + +#define STACK_LIMIT(context,stack,size) \ + ((stack).top - (stack).start < (size) ? \ + 1 : \ + ((context)->error = YAML_MEMORY_ERROR, \ + 0)) #define PUSH(context,stack,value) \ (((stack).top != (stack).end \ diff --git a/version.h b/version.h index f7be648b3928a9..f309464de276e4 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.1" -#define RUBY_RELEASE_DATE "2014-02-22" -#define RUBY_PATCHLEVEL 75 +#define RUBY_RELEASE_DATE "2014-02-24" +#define RUBY_PATCHLEVEL 76 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_DAY 24 #include "ruby/version.h" From 1980b4d4e4cc1dfd7f04d88c03e9f0a60dd4e94e Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 24 Feb 2014 05:41:09 +0000 Subject: [PATCH 82/83] add tag v2_1_1 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v2_1_1@45161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e From 5b54c3b7b05622ac56d71b9605a9cebc06a682e8 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 1 Mar 2014 09:02:36 +0000 Subject: [PATCH 83/83] merge revision(s) 44370: [Backport #9576] hash.c: extra states * hash.c (rb_hash_reject): use words "extra states". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e Conflicts: hash.c version.h Conflicts: hash.c --- hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hash.c b/hash.c index 4355edd57e8933..50f199fbc75be6 100644 --- a/hash.c +++ b/hash.c @@ -1178,7 +1178,7 @@ rb_hash_reject(VALUE hash) #endif } } -#if HASH_REJECT_COPY_MISC_ATTRIBUTES +#if HASH_REJECT_COPY_EXTRA_STATES result = rb_hash_dup_empty(hash); #else result = rb_hash_new(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy