[1].pack("b2") returns an 1-length string
-----------------------------------------
Key: JRUBY-6053
URL: https://jira.codehaus.org/browse/JRUBY-6053
Project: JRuby
Issue Type: Bug
Reporter: Yusuke Endoh
Assignee: Thomas E Enebo
$ bin/jruby --1.9 -e 'p ["1"].pack("b2")'
"\x01"
$ ruby -e 'p ["1"].pack("b2")'
"\x01\x00"
diff --git a/src/org/jruby/util/Pack.java b/src/org/jruby/util/Pack.java
@@ -1895,7 +1895,7 @@ public class Pack {
int padLength = 0;
if (occurrences > lCurElemString.length())
{
- padLength = (occurrences -
lCurElemString.length()) / 2 + occurrences % 2;
+ padLength = (occurrences -
lCurElemString.length()) / 2 + lCurElemString.length() % 2;
occurrences = lCurElemString.length();
}
@@ -1929,7 +1929,7 @@ public class Pack {
int padLength = 0;
if (occurrences > lCurElemString.length())
{
- padLength = (occurrences -
lCurElemString.length()) / 2 + occurrences % 2;
+ padLength = (occurrences -
lCurElemString.length()) / 2 + lCurElemString.length() % 2;
occurrences = lCurElemString.length();
}
--
Yusuke Endoh <[email protected]>
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email