Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix failing rubyspecs for String#unpack #675

Merged
merged 4 commits into from

2 participants

@tychobrailleur
Collaborator

This fixes the 22 failing specs for String#unpack, and addresses http://jira.codehaus.org/browse/JRUBY-5656.

@tychobrailleur
Collaborator

Hmm, odd one: the build fails, but all I can see is an error whilst building jruby-launcher which doesn’t sound related?

@headius
Owner

Yeah, I think the build's failure has nothing to do with your changes. I'll review what you have here and make sure it's working ok before pushing.

@headius
Owner

Looks ok here!

@headius headius merged commit f6a9649 into jruby:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
5 spec/tags/1.9/ruby/core/string/unpack/comment_tags.txt
@@ -1,5 +0,0 @@
-fails(JRUBY-5656):String#unpack ignores directives text from '#' to the first newline
-fails(JRUBY-5656):String#unpack ignores directives text from '#' to the end if no newline is present
-fails(JRUBY-5656):String#unpack ignores comments at the start of the directives string
-fails(JRUBY-5656):String#unpack ignores the entire directive string if it is a comment
-fails(JRUBY-5656):String#unpack ignores multiple comments
View
1  spec/tags/1.9/ruby/core/string/unpack/q_tags.txt
@@ -1 +0,0 @@
-fails(JRUBY-5656):String#unpack with format 'Q' adds nil for each element requested beyond the end of the String
View
8 spec/tags/1.9/ruby/core/string/unpack/s_tags.txt
@@ -1,8 +0,0 @@
-fails:String#unpack with format 'S' with modifier '<' and '_' decodes the number of shorts requested by the count modifier
-fails:String#unpack with format 'S' with modifier '<' and '_' decodes the remaining shorts when passed the '*' modifier
-fails:String#unpack with format 'S' with modifier '<' and '_' does not decode a short when fewer bytes than a short remain and the '*' modifier is passed
-fails:String#unpack with format 'S' with modifier '<' and '_' adds nil for each element requested beyond the end of the String
-fails:String#unpack with format 'S' with modifier '<' and '!' decodes the number of shorts requested by the count modifier
-fails:String#unpack with format 'S' with modifier '<' and '!' decodes the remaining shorts when passed the '*' modifier
-fails:String#unpack with format 'S' with modifier '<' and '!' does not decode a short when fewer bytes than a short remain and the '*' modifier is passed
-fails:String#unpack with format 'S' with modifier '<' and '!' adds nil for each element requested beyond the end of the String
View
1  spec/tags/1.9/ruby/core/string/unpack_tags.txt
@@ -1 +0,0 @@
-fails(JRUBY-5656):String#unpack with 'Q' and 'q' directives pads nil when the string is short
View
17 src/org/jruby/util/Pack.java
@@ -950,12 +950,20 @@ public static RubyArray unpack(Ruby runtime, ByteList encodedString, ByteList fo
int type = 0;
int next = safeGet(format);
- while (next != 0) {
+ mainLoop: while (next != 0) {
type = next;
next = safeGet(format);
if (UNPACK_IGNORE_NULL_CODES.indexOf(type) != -1 && next == 0) {
next = safeGetIgnoreNull(format);
}
+
+ if (type == '#') {
+ while (type != '\n') {
+ if (next == 0) break mainLoop;
+ type = next;
+ next = safeGet(format);
+ }
+ }
// Next indicates to decode using native encoding format
if (next == '_' || next == '!') {
@@ -978,6 +986,8 @@ public static RubyArray unpack(Ruby runtime, ByteList encodedString, ByteList fo
}
type = ENDIANESS_CODES.charAt(index);
next = safeGet(format);
+
+ if (next == '_' || next == '!') next = safeGet(format);
}
// How many occurrences of 'type' we want
@@ -1574,11 +1584,8 @@ public static void decode(Ruby runtime, ByteBuffer encode, int occurrences,
result.append(converter.decode(runtime, encode));
}
- // MRI behavior: for 'Q', do not add trailing nils
- if (converter != converters['Q']) {
- for (; lPadLength-- > 0;)
+ for (; lPadLength-- > 0;)
result.append(runtime.getNil());
- }
}
public static int encode(Ruby runtime, int occurrences, ByteList result,
Something went wrong with that request. Please try again.