Skip to content

Commit c40d698

Browse files
committed
Merge branch 'master' into truffle-head
Conflicts: truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java truffle/src/main/java/org/jruby/truffle/nodes/dispatch/UnresolvedDispatchNode.java
2 parents 4cdf4f9 + c281d17 commit c40d698

File tree

197 files changed

+2287
-648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+2287
-648
lines changed

core/src/main/java/org/jruby/ext/digest/BubbleBabble.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.jruby.ext.digest;
22

3+
import org.jruby.util.ByteList;
4+
35
/**
46
* Ported from OpenSSH (https://github.com/openssh/openssh-portable/blob/957fbceb0f3166e41b76fdb54075ab3b9cc84cba/sshkey.c#L942-L987)
57
*
@@ -32,42 +34,41 @@
3234

3335
public class BubbleBabble {
3436

35-
public static String bubblebabble(byte[] digestRaw) {
37+
public static ByteList bubblebabble(byte[] message, int begin, int length) {
3638
char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u', 'y'};
3739
char[] consonants = new char[]{'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm',
3840
'n', 'p', 'r', 's', 't', 'v', 'z', 'x'};
3941

4042
int seed = 1;
4143

42-
StringBuffer retval = new StringBuffer();
43-
int rawLen = digestRaw.length;
44+
ByteList retval = new ByteList();
4445

45-
int rounds = (rawLen / 2) + 1;
46+
int rounds = (length / 2) + 1;
4647
retval.append('x');
4748
for (int i = 0; i < rounds; i++) {
4849
int idx0, idx1, idx2, idx3, idx4;
4950

50-
if ((i + 1 < rounds) || (rawLen % 2 != 0)) {
51-
idx0 = (((((int) (digestRaw[2 * i])) >> 6) & 3) + seed) % 6;
52-
idx1 = (((int) (digestRaw[2 * i])) >> 2) & 15;
53-
idx2 = ((((int) (digestRaw[2 * i])) & 3) + (seed / 6)) % 6;
51+
if ((i + 1 < rounds) || (length % 2 != 0)) {
52+
idx0 = (((((int) (message[begin + 2 * i])) >> 6) & 3) + seed) % 6;
53+
idx1 = (((int) (message[begin + 2 * i])) >> 2) & 15;
54+
idx2 = ((((int) (message[begin + 2 * i])) & 3) + (seed / 6)) % 6;
5455
retval.append(vowels[idx0]);
5556
retval.append(consonants[idx1]);
5657
retval.append(vowels[idx2]);
5758
if ((i + 1) < rounds) {
58-
idx3 = (((int) (digestRaw[(2 * i) + 1])) >> 4) & 15;
59-
idx4 = (((int) (digestRaw[(2 * i) + 1]))) & 15;
59+
idx3 = (((int) (message[begin + (2 * i) + 1])) >> 4) & 15;
60+
idx4 = (((int) (message[begin + (2 * i) + 1]))) & 15;
6061
retval.append(consonants[idx3]);
6162
retval.append('-');
6263
retval.append(consonants[idx4]);
6364
seed = ((seed * 5) +
64-
((((int) (digestRaw[2 * i])) * 7) +
65-
((int) (digestRaw[(2 * i) + 1])))) % 36;
65+
((((int) (message[begin + 2 * i])) * 7) +
66+
((int) (message[begin + (2 * i) + 1])))) % 36;
6667
}
6768
}
6869
}
6970
retval.append('x');
7071

71-
return retval.toString();
72+
return retval;
7273
}
7374
}

core/src/main/java/org/jruby/ext/digest/RubyDigest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ public static IRubyObject s_hexencode(IRubyObject recv, IRubyObject arg) {
157157

158158
@JRubyMethod(name = "bubblebabble", required = 1, meta = true)
159159
public static IRubyObject bubblebabble(IRubyObject recv, IRubyObject arg) {
160-
return RubyString.newString(recv.getRuntime(), BubbleBabble.bubblebabble(arg.convertToString().getBytes()));
160+
final ByteList bytes = arg.convertToString().getByteList();
161+
return RubyString.newString(recv.getRuntime(), BubbleBabble.bubblebabble(bytes.unsafeBytes(), bytes.begin(), bytes.length()));
161162
}
162163

163164
private static class Metadata {
@@ -336,7 +337,7 @@ public static IRubyObject hexdigest_bang(ThreadContext context, IRubyObject self
336337
@JRubyMethod(name = "bubblebabble", required = 1, optional = 1, meta = true)
337338
public static IRubyObject bubblebabble(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
338339
byte[] digest = recv.callMethod(context, "digest", args, Block.NULL_BLOCK).convertToString().getBytes();
339-
return RubyString.newString(recv.getRuntime(), BubbleBabble.bubblebabble(digest));
340+
return RubyString.newString(recv.getRuntime(), BubbleBabble.bubblebabble(digest, 0, digest.length));
340341
}
341342

342343
@JRubyMethod()
@@ -480,7 +481,8 @@ public IRubyObject reset() {
480481

481482
@JRubyMethod()
482483
public IRubyObject bubblebabble(ThreadContext context) {
483-
return RubyString.newString(context.runtime, BubbleBabble.bubblebabble(algo.digest()));
484+
final byte[] digest = algo.digest();
485+
return RubyString.newString(context.runtime, BubbleBabble.bubblebabble(digest, 0, digest.length));
484486
}
485487

486488
private void setAlgorithm(Metadata metadata) throws NoSuchAlgorithmException {

core/src/main/java/org/jruby/util/TypeConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ public static void checkType(ThreadContext context, IRubyObject x, RubyModule t)
293293
throw context.runtime.newRuntimeError("bug: undef leaked to the Ruby space");
294294
}
295295

296-
xt = x.getMetaClass().getNativeClassIndex();
296+
xt = x.getMetaClass().getClassIndex();
297297

298298
// MISSING: special error for T_DATA of a certain type
299299
if (xt != t.getClassIndex()) {
300-
String tname = t.getBaseName();
300+
String tname = x.getMetaClass().toString();
301301
if (tname != null) {
302302
throw context.runtime.newTypeError("wrong argument type " + tname + " (expected " + t.getName() + ")");
303303
}

lib/ruby/truffle/mri/thread.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,12 @@ def num_waiting
373373

374374
# Documentation comments:
375375
# - How do you make RDoc inherit documentation from superclass?
376+
377+
# Truffle: define marshal_dump as MRI tests expect it
378+
[ConditionVariable, Queue].each do |klass|
379+
klass.class_exec do
380+
def marshal_dump
381+
raise TypeError, "can't dump #{self.class}"
382+
end
383+
end
384+
end

lib/ruby/truffle/rubysl/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Commits for each library are:
1111
* rubysl-pathname `cdf215804c4349353a60226b5c1d71f695d45570`
1212
* rubysl-tempfile `97c4464b4d235f773aab537fbc80608a730a58fc`
1313
* rubysl-socket `3a8c965b36643208da81360ddb4ca7ba867cd3c4`
14+
* rubysl-securerandom `00e31daaf492f7987aa50750dfc3ebc8e8c42a7e`
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2013, Brian Shirai
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
3. Neither the name of the library nor the names of its contributors may be
13+
used to endorse or promote products derived from this software without
14+
specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT,
20+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "rubysl/securerandom/securerandom"
2+
require "rubysl/securerandom/version"

0 commit comments

Comments
 (0)