[macruby-changes] [4957] MacRuby/trunk/pack.c

source_changes at macosforge.org source_changes at macosforge.org
Tue Nov 30 01:25:56 PST 2010


Revision: 4957
          http://trac.macosforge.org/projects/ruby/changeset/4957
Author:   watson1978 at gmail.com
Date:     2010-11-30 01:25:51 -0800 (Tue, 30 Nov 2010)
Log Message:
-----------
Array#pack('H') will fill low-nibble of the last byte with 0 when count is odd.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

assert_equal("A@",         ["414"].pack("H3"))
assert_equal("A@",         ["414"].pack("H4"))
assert_equal("A@\x00",     ["414"].pack("H5"))
assert_equal("A@\x00",     ["414"].pack("H6"))
assert_equal("A@\x00\x00", ["414"].pack("H7"))

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/pack.c

Modified: MacRuby/trunk/pack.c
===================================================================
--- MacRuby/trunk/pack.c	2010-11-30 04:34:52 UTC (rev 4956)
+++ MacRuby/trunk/pack.c	2010-11-30 09:25:51 UTC (rev 4957)
@@ -661,7 +661,7 @@
 		    long i, j = 0;
 
 		    if (len > plen) {
-			j = (len - plen + 1)/2;
+			j = (len + 1) / 2 - (plen + 1) / 2;
 			len = plen;
 		    }
 		    for (i=0; i++ < len; ptr++) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101130/512959be/attachment-0001.html>


More information about the macruby-changes mailing list