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: 22d6044b33b6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f8bbfdd7ea7f
Choose a head ref
  • 5 commits
  • 27 files changed
  • 1 contributor

Commits on Jan 2, 2016

  1. Copy the full SHA
    2f9be61 View commit details
  2. Copy the full SHA
    15dccca View commit details
  3. Copy the full SHA
    120195e View commit details
  4. Copy the full SHA
    18bb059 View commit details
  5. Copy the full SHA
    f8bbfdd View commit details
Showing with 34 additions and 131 deletions.
  1. +0 −2 spec/truffle/tags/core/string/unpack/a_tags.txt
  2. +0 −1 spec/truffle/tags/core/string/unpack/at_tags.txt
  3. +0 −2 spec/truffle/tags/core/string/unpack/b_tags.txt
  4. +0 −2 spec/truffle/tags/core/string/unpack/c_tags.txt
  5. +0 −2 spec/truffle/tags/core/string/unpack/d_tags.txt
  6. +0 −2 spec/truffle/tags/core/string/unpack/e_tags.txt
  7. +0 −2 spec/truffle/tags/core/string/unpack/f_tags.txt
  8. +0 −2 spec/truffle/tags/core/string/unpack/g_tags.txt
  9. +0 −2 spec/truffle/tags/core/string/unpack/h_tags.txt
  10. +0 −2 spec/truffle/tags/core/string/unpack/i_tags.txt
  11. +0 −74 spec/truffle/tags/core/string/unpack/l_tags.txt
  12. +0 −4 spec/truffle/tags/core/string/unpack/m_tags.txt
  13. +0 −2 spec/truffle/tags/core/string/unpack/n_tags.txt
  14. +0 −2 spec/truffle/tags/core/string/unpack/p_tags.txt
  15. +0 −2 spec/truffle/tags/core/string/unpack/q_tags.txt
  16. +0 −2 spec/truffle/tags/core/string/unpack/s_tags.txt
  17. +0 −2 spec/truffle/tags/core/string/unpack/u_tags.txt
  18. +0 −2 spec/truffle/tags/core/string/unpack/v_tags.txt
  19. +0 −1 spec/truffle/tags/core/string/unpack/w_tags.txt
  20. +0 −2 spec/truffle/tags/core/string/unpack/x_tags.txt
  21. +0 −3 spec/truffle/tags/core/string/unpack/z_tags.txt
  22. +1 −1 truffle/src/main/antlr4/org/jruby/truffle/format/parser/Pack.g4
  23. +1 −1 truffle/src/main/java/org/jruby/truffle/format/nodes/read/ReadBase64StringNode.java
  24. +20 −2 truffle/src/main/java/org/jruby/truffle/format/nodes/read/ReadBinaryStringNode.java
  25. +2 −2 truffle/src/main/java/org/jruby/truffle/format/parser/PackTreeBuilder.java
  26. +9 −9 truffle/src/main/java/org/jruby/truffle/format/parser/UnpackTreeBuilder.java
  27. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/a_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/unpack/at_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/b_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/c_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/d_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/e_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/f_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/g_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/h_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/i_tags.txt

This file was deleted.

74 changes: 0 additions & 74 deletions spec/truffle/tags/core/string/unpack/l_tags.txt

This file was deleted.

4 changes: 0 additions & 4 deletions spec/truffle/tags/core/string/unpack/m_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/n_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/p_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/q_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/s_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/u_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/v_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/unpack/w_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/x_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/unpack/z_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ directive : 'c' count? # int8
| 'H' count? # hexStringHighFirst
| 'h' count? # hexStringLowFirst
| 'u' count? # uuString
| 'M' INT? # mimeString
| 'M' count? # mimeString
| 'm' count? # base64String
| ('p' | 'P') # pointer
| '@' count? # at
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ public Object read(VirtualFrame frame, byte[] source) {

final ByteBuffer encode = ByteBuffer.wrap(source, getSourcePosition(frame), getSourceLength(frame) - getSourcePosition(frame));

int occurrences = requestedLength;
int occurrences = encode.remaining();

int length = encode.remaining()*3/4;
byte[] lElem = new byte[length];
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
@@ -34,14 +34,16 @@ public abstract class ReadBinaryStringNode extends PackNode {
final int count;
final boolean trimTrailingSpaces;
final boolean trimTrailingNulls;
final boolean trimToFirstNull;

public ReadBinaryStringNode(RubyContext context, boolean readToEnd, boolean readToNull, int count, boolean trimTrailingSpaces, boolean trimTrailingNulls) {
public ReadBinaryStringNode(RubyContext context, boolean readToEnd, boolean readToNull, int count, boolean trimTrailingSpaces, boolean trimTrailingNulls, boolean trimToFirstNull) {
super(context);
this.readToEnd = readToEnd;
this.readToNull = readToNull;
this.count = count;
this.trimTrailingSpaces = trimTrailingSpaces;
this.trimTrailingNulls = trimTrailingNulls;
this.trimToFirstNull = trimToFirstNull;
}

@Specialization(guards = "isNull(source)")
@@ -67,12 +69,20 @@ public Object read(VirtualFrame frame, byte[] source) {
while (start + length < getSourceLength(frame) && (!readToNull || (start + length < getSourceLength(frame) && source[start + length] != 0))) {
length++;
}

if (start + length < getSourceLength(frame) && source[start + length] == 0) {
length++;
}
} else if (readToNull) {
length = 0;

while (start + length < getSourceLength(frame) && length < count && (!readToNull || (start + length < getSourceLength(frame) && source[start + length] != 0))) {
length++;
}

if (start + length < getSourceLength(frame) && source[start + length] == 0) {
length++;
}
} else {
length = count;

@@ -89,6 +99,14 @@ public Object read(VirtualFrame frame, byte[] source) {

result = new ByteList(source, start, usedLength, true);

if (trimToFirstNull) {
final int firstNull = result.indexOf(0);

if (firstNull != -1 && trimTrailingNulls) {
result.realSize(firstNull);
}
}

setSourcePosition(frame, start + length);

return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(), result, StringSupport.CR_UNKNOWN, null);
Original file line number Diff line number Diff line change
@@ -294,10 +294,10 @@ public void exitMimeString(PackParser.MimeStringContext ctx) {

int length;

if (ctx.INT() == null) {
if (ctx.count() == null || ctx.count().INT() == null) {
length = 72;
} else {
length = Integer.parseInt(ctx.INT().getText());
length = Integer.parseInt(ctx.count().INT().getText());

if (length <= 1) {
length = 72;
Original file line number Diff line number Diff line change
@@ -219,36 +219,36 @@ public void exitF32Big(PackParser.F32BigContext ctx) {
@Override
public void exitBinaryStringSpacePadded(PackParser.BinaryStringSpacePaddedContext ctx) {
if (ctx.count() == null) {
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, 1, true, true, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, 1, true, true, false, new SourceNode())));
} else if (ctx.count().INT() == null) {
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, true, false, -1, true, true, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, true, false, -1, true, true, false, new SourceNode())));
} else {
final int count = Integer.parseInt(ctx.count().INT().getSymbol().getText());
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, count, true, true, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, count, true, true, false, new SourceNode())));
}
}

@Override
public void exitBinaryStringNullPadded(PackParser.BinaryStringNullPaddedContext ctx) {
if (ctx.count() == null) {
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, 1, false, false, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, 1, false, false, false, new SourceNode())));
} else if (ctx.count().INT() == null) {
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, true, false, -1, false, false, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, true, false, -1, false, false, false, new SourceNode())));
} else {
final int count = Integer.parseInt(ctx.count().INT().getSymbol().getText());
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, count, false, false, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, count, false, false, false, new SourceNode())));
}
}

@Override
public void exitBinaryStringNullStar(PackParser.BinaryStringNullStarContext ctx) {
if (ctx.count() == null) {
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, true, 1, false, false, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, true, 1, false, true, true, new SourceNode())));
} else if (ctx.count().INT() == null) {
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, true, true, -1, false, false, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, true, true, -1, false, true, true, new SourceNode())));
} else {
final int count = Integer.parseInt(ctx.count().INT().getSymbol().getText());
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, true, count, false, false, new SourceNode())));
appendNode(WriteValueNodeGen.create(context, ReadBinaryStringNodeGen.create(context, false, false, count, false, true, true, new SourceNode())));
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. This
* Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*