Skip to content

Commit

Permalink
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
***** END LICENSE BLOCK *****/
package org.jruby;

import jnr.posix.POSIX;
import org.jcodings.Encoding;
import org.jcodings.EncodingDB;
import org.jcodings.ascii.AsciiTables;
@@ -2657,8 +2658,13 @@ public RubyString crypt(ThreadContext context, IRubyObject other) {
throw context.runtime.newArgumentError("salt too short(need >=2 bytes)");
}

RubyString result = RubyString.newString(context.runtime,
context.runtime.getPosix().crypt(asJavaString(), salt).toString());
POSIX posix = context.runtime.getPosix();
CharSequence cryptedString = posix.crypt(asJavaString(), salt);
// We differ from MRI in that we do not process salt to make it work and we will
// return any errors via errno.
if (cryptedString == null) throw context.runtime.newErrnoFromInt(posix.errno());

RubyString result = RubyString.newString(context.runtime, cryptedString.toString());
result.associateEncoding(ascii8bit);
result.infectBy(this);
result.infectBy(otherStr);
1 change: 1 addition & 0 deletions test/externals/ruby1.9/excludes/TestM17NComb.rb
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
exclude :test_str_chop, "needs investigation"
exclude :test_str_chr, "needs investigation"
exclude :test_str_count, "needs investigation"
exclude :test_str_crypt, "full of bogus tests"
exclude :test_str_empty?, "needs investigation"
exclude :test_str_end_with?, "needs investigation"
exclude :test_str_include?, "needs investigation"

0 comments on commit fce7ea8

Please sign in to comment.