Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7370ed8bef14
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3a3b7e5a9e98
Choose a head ref
  • 10 commits
  • 12 files changed
  • 1 contributor

Commits on Apr 27, 2018

  1. Copy the full SHA
    1402250 View commit details
  2. Copy the full SHA
    97291a8 View commit details
  3. Copy the full SHA
    3599ab0 View commit details
  4. Copy the full SHA
    fed0248 View commit details
  5. Set these to proper values.

    headius committed Apr 27, 2018
    Copy the full SHA
    abac894 View commit details
  6. Copy the full SHA
    70fd3fe View commit details
  7. Fix unhandled errno to go through IOEx to Errno logic correctly.

    Also handle ResourceException by letting it construct its own
    exception to be raised.
    headius committed Apr 27, 2018
    Copy the full SHA
    b4a450c View commit details
  8. Copy the full SHA
    5f83a19 View commit details
  9. Copy the full SHA
    6ae7589 View commit details
  10. Copy the full SHA
    3a3b7e5 View commit details
101 changes: 79 additions & 22 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -4332,41 +4332,98 @@ public IRubyObject start_with_p(ThreadContext context, IRubyObject arg) {
}

@JRubyMethod(name = "delete_prefix")
public IRubyObject delete_prefix(ThreadContext context, IRubyObject arg) {
RubyString prefix = arg.convertToString();
if (!this.start_with_p(context, prefix).isTrue()) return this.dup();
if (prefix.value.getRealSize() == this.value.getRealSize()) return newEmptyString(context.runtime, value.getEncoding());
RubyString result = (RubyString) substr19(context.runtime, prefix.strLength(), this.strLength() - prefix.strLength());
return result.isEmpty() ? this : result;
public IRubyObject delete_prefix(ThreadContext context, IRubyObject prefix) {
int prefixlen;

prefixlen = deletedPrefixLength(prefix);
if (prefixlen <= 0) return strDup(context.runtime);

return makeSharedString(context.runtime, prefixlen, size() - prefixlen);
}

@JRubyMethod(name = "delete_suffix")
public IRubyObject delete_suffix(ThreadContext context, IRubyObject arg) {
RubyString suffix = arg.convertToString();
if (!this.end_with_p(context, suffix).isTrue()) return this.dup();
if (suffix.value.getRealSize() == this.value.getRealSize()) return newEmptyString(context.runtime, value.getEncoding());
RubyString result = (RubyString) substr19(context.runtime, 0, this.strLength() - suffix.strLength());
return result.isEmpty() ? this : result;
public IRubyObject delete_suffix(ThreadContext context, IRubyObject suffix) {
int suffixlen;

suffixlen = deletedSuffixLength(suffix);
if (suffixlen <= 0) return strDup(context.runtime);

return makeSharedString(context.runtime, 0, size() - suffixlen);
}

@JRubyMethod(name = "delete_prefix!")
public IRubyObject delete_prefix_bang(ThreadContext context, IRubyObject arg) {
modifyCheck();
RubyString result = (RubyString) delete_prefix(context, arg);
if (equals(result)) return context.nil;
replaceInternal19(0, this.strLength(), result);
public IRubyObject delete_prefix_bang(ThreadContext context, IRubyObject prefix) {
modifyAndKeepCodeRange();
int prefixlen = deletedPrefixLength(prefix);
value.setBegin(value.getBegin() + prefixlen);
return this;
}

@JRubyMethod(name = "delete_suffix!")
public IRubyObject delete_suffix_bang(ThreadContext context, IRubyObject arg) {
modifyCheck();
RubyString result = (RubyString) delete_suffix(context, arg);
if (equals(result)) return context.nil;
replaceInternal19(0, this.strLength(), result);
public IRubyObject delete_suffix_bang(ThreadContext context, IRubyObject suffix) {
int olen, suffixlen, len;
checkFrozen();

suffixlen = deletedSuffixLength(suffix);
if (suffixlen <= 0) return context.nil;

olen = size();
modifyAndKeepCodeRange();
len = olen - suffixlen;
value.realSize(len);
if (!isCodeRangeAsciiOnly()) {
clearCodeRange();
}
return this;
}

private int deletedPrefixLength(IRubyObject _prefix) {
int strptr, prefixptr;
int olen, prefixlen;

RubyString prefix = _prefix.convertToString();
if (prefix.isBrokenString()) return 0;
checkEncoding(prefix);

/* return 0 if not start with prefix */
prefixlen = prefix.size();
if (prefixlen <= 0) return 0;
olen = size();
if (olen < prefixlen) return 0;
byte[] strBytes = value.unsafeBytes();
strptr = value.begin();
byte[] prefixBytes = prefix.value.unsafeBytes();
prefixptr = prefix.value.begin();
if (ByteList.memcmp(strBytes, strptr, prefixBytes, prefixptr, prefixlen) != 0) return 0;

return prefixlen;
}

private int deletedSuffixLength(IRubyObject _suffix) {
int strptr, suffixptr, s;
int olen, suffixlen;
Encoding enc;

RubyString suffix = _suffix.convertToString();
if (suffix.isBrokenString()) return 0;
enc = checkEncoding(suffix);

/* return 0 if not start with suffix */
suffixlen = suffix.size();
if (suffixlen <= 0) return 0;
olen = size();
if (olen < suffixlen) return 0;
byte[] strBytes = value.unsafeBytes();
strptr = value.begin();
byte[] suffixBytes = suffix.value.unsafeBytes();
suffixptr = suffix.value.begin();
s = strptr + olen - suffixlen;
if (ByteList.memcmp(strBytes, s, suffixBytes, suffixptr, suffixlen) != 0) return 0;
if (enc.leftAdjustCharHead(strBytes, strptr, s, strptr + olen) != s) return 0;

return suffixlen;
}

@JRubyMethod(name = "start_with?", rest = true)
public IRubyObject start_with_p(ThreadContext context, IRubyObject[]args) {
for (int i = 0; i < args.length; i++) {
16 changes: 11 additions & 5 deletions core/src/main/java/org/jruby/runtime/load/LoadService.java
Original file line number Diff line number Diff line change
@@ -415,13 +415,13 @@ private enum RequireState {

private final RequireLocks requireLocks = new RequireLocks();

private static final class RequireLocks {
enum LockResult { LOCKED, CIRCULAR }

private final class RequireLocks {
private final ConcurrentHashMap<String, ReentrantLock> pool;
// global lock for require must be fair
//private final ReentrantLock globalLock;

public enum LockResult { LOCKED, CIRCULAR }

private RequireLocks() {
this.pool = new ConcurrentHashMap<>(8, 0.75f, 2);
//this.globalLock = new ReentrantLock(true);
@@ -448,7 +448,13 @@ private LockResult lock(String requireName) {

if (lock.isHeldByCurrentThread()) return LockResult.CIRCULAR;

lock.lock();
try {
runtime.getCurrentContext().getThread().enterSleep();
lock.lock();
} finally {
runtime.getCurrentContext().getThread().exitSleep();
}


return LockResult.LOCKED;
}
@@ -508,7 +514,7 @@ private RequireState smartLoadInternal(String file, boolean circularRequireWarni
throw runtime.newLoadError("no such file to load -- " + file, file);
}

if (requireLocks.lock(state.loadName) == RequireLocks.LockResult.CIRCULAR) {
if (requireLocks.lock(state.loadName) == LockResult.CIRCULAR) {
if (circularRequireWarning && runtime.isVerbose()) {
warnCircularRequire(state.loadName);
}
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/util/RegularFileResource.java
Original file line number Diff line number Diff line change
@@ -189,8 +189,9 @@ public Channel openChannel(ModeFlags flags, int perm) throws ResourceException {
throw new ResourceException.FileIsDirectory(absolutePath());
case ENOTDIR:
throw new ResourceException.FileIsNotDirectory(absolutePath());
case EMFILE:
default:
throw new ResourceException.IOError(new IOException("unhandled errno: " + errno));
throw new ResourceException.IOError(new IOException(errno.description()));

}
}
5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/util/Sprintf.java
Original file line number Diff line number Diff line change
@@ -182,7 +182,7 @@ private IRubyObject getHashValue(ByteList name, char startDelim, char endDelim)
object = rubyHash.getIfNone();
if (object == RubyBasicObject.UNDEF) {
RubyString nameStr = RubyString.newString(runtime, name);
raiseKeyError("key" + startDelim + nameStr + endDelim + " not found", rubyHash, nameStr);
raiseKeyError("key" + startDelim + nameStr + endDelim + " not found", rubyHash, nameSym);
} else if (rubyHash.hasDefaultProc()) {
object = object.callMethod(runtime.getCurrentContext(), "call", nameSym);
}
@@ -269,7 +269,7 @@ IRubyObject next(ByteList name) {
object = rubyHash.getIfNone();
if (object == RubyBasicObject.UNDEF) {
RubyString nameStr = RubyString.newString(runtime, name);
raiseKeyError("key<" + name + "> not found", rubyHash, nameStr);
raiseKeyError("key<" + name + "> not found", rubyHash, nameSym);
} else if (rubyHash.hasDefaultProc()) {
object = object.callMethod(runtime.getCurrentContext(), "call", nameSym);
}
@@ -545,6 +545,7 @@ private static boolean rubySprintfToBuffer(ByteList buf, CharSequence charFormat
if (width < 0) {
flags |= FLAG_MINUS;
width = -width;
if (width < 0) throw runtime.newArgumentError("width too big");
}

break;
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/util/io/PosixShim.java
Original file line number Diff line number Diff line change
@@ -435,6 +435,8 @@ public Channel open(String cwd, String path, ModeFlags flags, int perm) {
errno = Errno.EACCES;
} catch (ResourceException.TooManySymlinks e) {
errno = Errno.ELOOP;
} catch (ResourceException resourceException) {
throw resourceException.newRaiseException(runtime);
} catch (IOException e) {
errno = Helpers.errnoFromException(e);
}
2 changes: 1 addition & 1 deletion lib/pom.rb
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ def initialize( name, version, default_spec = true )
ImportedGem.new( 'minitest', '${minitest.version}' ),
ImportedGem.new( 'test-unit', '${test-unit.version}' ),
ImportedGem.new( 'power_assert', '${power_assert.version}' ),
ImportedGem.new( 'psych', '3.0.2' ),
ImportedGem.new( 'psych', '3.0.3.pre1' ),
ImportedGem.new( 'json', '${json.version}' ),
ImportedGem.new( 'jar-dependencies', '${jar-dependencies.version}' ),
ImportedGem.new( 'net-telnet', '0.1.1'),
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>rubygems</groupId>
<artifactId>psych</artifactId>
<version>3.0.2</version>
<version>3.0.3.pre1</version>
<type>gem</type>
<scope>provided</scope>
<exclusions>
6 changes: 4 additions & 2 deletions lib/ruby/stdlib/rbconfig/sizeof.rb
Original file line number Diff line number Diff line change
@@ -9,10 +9,12 @@ module RbConfig
SIZEOF = sizeof

limits = {}
limits['FIXNUM_MAX'] = 0x8000000000000000
limits['FIXNUM_MIN'] = 0x7fffffffffffffff
limits['FIXNUM_MAX'] = 0x7fffffffffffffff
limits['FIXNUM_MIN'] = -0x8000000000000000
limits['LONG_MAX'] = limits['FIXNUM_MAX']
limits['LONG_MIN'] = limits['FIXNUM_MIN']
limits['INT_MAX'] = 0x7fffffff
limits['INT_MIN'] = -0x80000000
limits.freeze
LIMITS = limits
end
1 change: 1 addition & 0 deletions test/mri/excludes/TestDir.rb
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
exclude :test_glob, '\0 delimiter is not handled'
exclude :test_glob_cases, "fails to return files with their correct casing (#2150)"
exclude :test_glob_gc_for_fd, "tweaks rlimit and never restores it, depends on GC effects"
exclude :test_glob_too_may_open_files, "our glob does not appear to open files, and so the expected EMFILE does not happen"
exclude :test_home, "uses user.home as a fallback home path"
exclude :test_unknown_keywords, "https://github.com/jruby/jruby/issues/1368"
1 change: 1 addition & 0 deletions test/mri/excludes/TestSecureRandom.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
exclude :test_hex_encoding, "needs investigation"
exclude :test_with_openssl, "gen_random_openssl does not exist in our openssl library (jruby/jruby-openssl#159"
3 changes: 2 additions & 1 deletion test/mri/excludes/TestSocket_TCPSocket.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
exclude :test_recvfrom, "no addrinfo returned"
exclude :test_initialize_failure, "needs investigation"
exclude :test_inspect, "missing socket information"
exclude :test_recvfrom, "no addrinfo returned"
1 change: 1 addition & 0 deletions test/mri/excludes/TestSocket_UDPSocket.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude :test_bind, "needs investigation"
exclude :test_bind_addrinuse, "needs investigation"
exclude :test_inspect, "missing socket information"
exclude :test_send_too_long, "needs investigation"