Bug #3948: Unexpected RangeErorr of pack and unpack with specified byte-order modifier
http://redmine.ruby-lang.org/issues/show/3948

Author: Heesob Park
Status: Open, Priority: Normal
Category: core, Target version: 1.9.x
ruby -v: ruby 1.9.3dev (2010-10-14 trunk 29498) [i386-mswin32_90]

After applying Revision 29496, I can use < > modifier for pack and unpack.
But it fails to work when the modifier occurs more than once.

C:\>ruby -e 'p "1234".unpack("SS")'
[12849, 13363]

C:\>ruby -e 'p "1234".unpack("SS>")'
[12849, 13108]

C:\>ruby -e 'p "1234".unpack("S>S")'
[12594, 13108]

C:\>ruby -e 'p "1234".unpack("S>S>")'
-e:1:in `unpack': Can't use both '<' and '>' (RangeError)
        from -e:1:in `<main>'

C:\>ruby -e 'p "1234".unpack("S<S<")'
-e:1:in `unpack': Can't use both '<' and '>' (RangeError)
        from -e:1:in `<main>'
	
C:\>ruby -e 'p "1234".unpack("S<S>")'
-e:1:in `unpack': Can't use both '<' and '>' (RangeError)
        from -e:1:in `<main>'
	
	
C:\>ruby -e 'p [1234,5678].pack("SS")'
"\xD2\x04.\x16"

C:\>ruby -e 'p [1234,5678].pack("SS>")'
"\xD2\x04\x16."

C:\>ruby -e 'p [1234,5678].pack("S>S")'
"\x04\xD2\x16."

C:\>ruby -e 'p [1234,5678].pack("S<S")'
"\xD2\x04.\x16"

C:\>ruby -e 'p [1234,5678].pack("S>S>")'
-e:1:in `pack': Can't use both '<' and '>' (RangeError)
        from -e:1:in `<main>'

C:\>ruby -e 'p [1234,5678].pack("S<S<")'
-e:1:in `pack': Can't use both '<' and '>' (RangeError)
        from -e:1:in `<main>'
	
C:\>ruby -e 'p [1234,5678].pack("S<S>")'
-e:1:in `pack': Can't use both '<' and '>' (RangeError)
        from -e:1:in `<main>'


----------------------------------------
http://redmine.ruby-lang.org