[#70464] ljust, rjust... — "Chris Pine" <nemo@...>

Just thought I would run these ideas by everyone:

11 messages 2003/05/01

[#70502] temporary redirection of stdout — Andrew Walrond <andrew@...>

I'm new to ruby, so forgive any obvious stupididity, but can anyone

20 messages 2003/05/02

[#70535] SWIG on Solaris problem — Jim Freeze <jim@...>

Hi folks.

14 messages 2003/05/02

[#70594] Why is PHP so popular? What can we learn from the PHP camp? — ptkwt@...1.aracnet.com (Phil Tomson)

....and what can we learn from PHP's rapid rise to success?

99 messages 2003/05/05
[#70641] Re: Why is PHP so popular? What can we learn from the PHP camp? — Andreas Schwarz <usenet@...> 2003/05/05

Aredridel wrote:

[#70652] A wishlist for a "Ruby Standard Library" — Aredridel <aredridel@...> 2003/05/05

A wishlsit for a "Ruby Standard Library":

[#70655] Re: A wishlist for a "Ruby Standard Library" — Brian Candler <B.Candler@...> 2003/05/05

On Tue, May 06, 2003 at 07:39:54AM +0900, Aredridel wrote:

[#70673] Re: A wishlist for a "Ruby Standard Library" — Mark Wilson <mwilson13@...> 2003/05/06

[snipped many wonderful things.]

[#70759] Testing for a class existence — "Gennady" <gfb@...>

Does anybody know an easy way to test for a class/module existence in =

15 messages 2003/05/06

[#70770] capture output — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

I have seen much talking about this topic, but no working code!

68 messages 2003/05/06
[#70929] Re: IO.pipe + thread = hangs (was: Re: capture output) — "Robert Klemme" <bob.news@...> 2003/05/08

[#71741] Named Pipes — Mark Firestone <nedry@...> 2003/05/19

What is the recommended procedure for using named pipes in Ruby. Does one

[#71745] Re: Named Pipes — Brian Candler <B.Candler@...> 2003/05/19

On Mon, May 19, 2003 at 06:33:17PM +0900, Mark Firestone wrote:

[#70842] Symbiosis offer: trade Ruby for German :-) — Mauricio Fern疣dez <batsman.geo@...>

17 messages 2003/05/07

[#70865] access a variables name? — "meinrad.recheis" <my.name.here@...>

is it possible to access the variable-name of an object?

14 messages 2003/05/07

[#70891] Syck 0.25 + YAML.rb -- Objects in plain-text — why the lucky stiff <ruby-talk@...>

..my faithful friends..

20 messages 2003/05/07

[#70919] petition for raa-install to be included in 1.8 — ptkwt@...1.aracnet.com (Phil Tomson)

Similar to the YamlInRuby petition which has now closed.

14 messages 2003/05/08
[#70920] Re: petition for raa-install to be included in 1.8 — Sam Roberts <sroberts@...> 2003/05/08

I just looked again, and remember why I don't know anything about

[#70921] Re: petition for raa-install to be included in 1.8 — why the lucky stiff <ruby-talk@...> 2003/05/08

You can find a tutorial on using raa-install (as well as its API) at:

[#70985] Can a global be a constant? — Jim Freeze <jim@...>

Hi

36 messages 2003/05/08
[#71001] Re: Can a global be a constant? — "Hal E. Fulton" <hal9000@...> 2003/05/08

----- Original Message -----

[#71003] Re: Can a global be a constant? — Jim Freeze <jim@...> 2003/05/08

On Friday, 9 May 2003 at 8:23:52 +0900, Hal E. Fulton wrote:

[#71007] Re: Can a global be a constant? — dblack@... 2003/05/08

Hi --

[#71036] Re: Regexp: why does (re)* return only last repetition? — "Robert Klemme" <bob.news@...>

21 messages 2003/05/09
[#71209] Re: Regexp: why does (re)* return only last repetition? — "Robert Klemme" <bob.news@...> 2003/05/12

[#71225] Re: Regexp: why does (re)* return only last repetition? — Austin Ziegler <austin@...> 2003/05/12

On Mon, 12 May 2003 17:39:19 +0900, Robert Klemme wrote:

[#71229] Re: Regexp: why does (re)* return only last repetition? — Brian Candler <B.Candler@...> 2003/05/12

On Mon, May 12, 2003 at 10:18:00PM +0900, Austin Ziegler wrote:

[#71266] Re: Regexp: why does (re)* return only last repetition? — Austin Ziegler <austin@...> 2003/05/12

On Mon, 12 May 2003 23:51:44 +0900, Brian Candler wrote:

[#71042] TCP Sockets — Dominik Werder <dwerder@...>

Hi there,

28 messages 2003/05/09
[#71089] Re: TCP Sockets — Tom Felker <tcfelker@...> 2003/05/09

On Fri, 2003-05-09 at 05:40, Dominik Werder wrote:

[#71543] Re: TCP Sockets — Dominik Werder <dwerder@...> 2003/05/16

>> How can I tell how many bytes can be read from an IO object without

[#71547] Re: TCP Sockets — Brian Candler <B.Candler@...> 2003/05/16

On Fri, May 16, 2003 at 05:14:17PM +0900, Dominik Werder wrote:

[#71550] Re: TCP Sockets — Dominik Werder <dwerder@...> 2003/05/16

my problem is not the http protocol itself (not at this time :) but the IO-

[#71551] Re: TCP Sockets — Brian Candler <B.Candler@...> 2003/05/16

On Fri, May 16, 2003 at 07:20:30PM +0900, Dominik Werder wrote:

[#71553] Re: TCP Sockets — Dominik Werder <dwerder@...> 2003/05/16

> Maybe, but threads are really the "ruby way" to solve this problem.

[#71557] Re: TCP Sockets — Brian Candler <B.Candler@...> 2003/05/16

On Fri, May 16, 2003 at 07:53:39PM +0900, Dominik Werder wrote:

[#71562] Re: TCP Sockets — Dominik Werder <dwerder@...> 2003/05/16

> That would mean mixing the binary streams in a non-deterministic way,

[#71107] RCR for child execution — Brian Candler <B.Candler@...>

Looking on RubyGarden it seems that the RCR process there is "resting", so

99 messages 2003/05/10
[#71122] Re: RCR for child execution — "Simon Strandgaard" <0bz63fz3m1qt3001@...> 2003/05/10

On Sun, 11 May 2003 01:50:49 +0900, Brian Candler wrote:

[#71126] Re: RCR for child execution — Brian Candler <B.Candler@...> 2003/05/10

On Sun, May 11, 2003 at 01:27:31AM +0900, Simon Strandgaard wrote:

[#71364] Re: RCR for child execution — "Simon Strandgaard" <0bz63fz3m1qt3001@...> 2003/05/13

On Tue, 13 May 2003 21:11:08 +0000, ahoward wrote:

[#71385] Re: RCR for child execution — matz@... (Yukihiro Matsumoto) 2003/05/14

Hi,

[#71152] Is Rubygarden's wiki restricted to English? — Mauricio Fern疣dez <batsman.geo@...>

20 messages 2003/05/11
[#71160] Re: Is Rubygarden's wiki restricted to English? — "Hal E. Fulton" <hal9000@...> 2003/05/11

----- Original Message -----

[#71165] Re: Is Rubygarden's wiki restricted to English? — Mauricio Fern疣dez <batsman.geo@...> 2003/05/11

On Mon, May 12, 2003 at 12:40:26AM +0900, Hal E. Fulton wrote:

[#71189] efficiency advice needed — "meinrad.recheis" <my.name.here@...>

hi,

12 messages 2003/05/11

[#71297] State Pattern Implementation — "Robert Klemme" <bob.news@...>

22 messages 2003/05/13

[#71361] Objects VS Datastructures — Simon Vandemoortele <deliriousREMOVEUPPERCASETEXTTOREPLY@...>

19 messages 2003/05/13

[#71447] Embedding/GC/heap corruption problem — "Jan Bernhardt" <j.bernhardt@...>

Hi,

22 messages 2003/05/14

[#71488] Test::Unit sequencing — Brian Candler <B.Candler@...>

A question for more experienced Test::Unit users.

23 messages 2003/05/15
[#71492] Re: Test::Unit sequencing — Anders Bengtsson <ndrsbngtssn@...> 2003/05/15

--- Brian Candler <B.Candler@pobox.com> wrote:

[#71508] Re: Test::Unit sequencing — ahoward <ahoward@...> 2003/05/15

On Thu, 15 May 2003, [iso-8859-1] Anders Bengtsson wrote:

[#71510] RCR: $INCLUDED global var — martindemello@... (Martin DeMello)

$INCLUDED = (__FILE__ != $0)

25 messages 2003/05/15
[#71515] Re: RCR: $INCLUDED global var — matz@... (Yukihiro Matsumoto) 2003/05/15

Hi,

[#71525] Re: RCR: $INCLUDED global var — ahoward <ahoward@...> 2003/05/15

On Fri, 16 May 2003, Yukihiro Matsumoto wrote:

[#71520] public/protected/private syntax — Guillaume Marcais <guslist@...>

I tend to find the public/protected/private keywords in Ruby a little odd.

27 messages 2003/05/15
[#71540] Re: public/protected/private syntax — "Robert Klemme" <bob.news@...> 2003/05/16

[#71573] Re: public/protected/private syntax — Guillaume Marcais <guillaume.marcais@...> 2003/05/16

On Friday 16 May 2003 03:38 am, you wrote:

[#71595] Re: public/protected/private syntax — Austin Ziegler <austin@...> 2003/05/16

On Fri, 16 May 2003 23:33:21 +0900, Guillaume Marcais wrote:

[#71560] gzip cgi compression — Dominik Werder <dwerder@...>

Is zlib compatible with HTTP-gzip-output-compression?

14 messages 2003/05/16

[#71636] select strange behavier — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

'select' is suppose to watch some file-descriptors and when an event

22 messages 2003/05/17

[#71673] An Object Going Out Of Scope — "vinita Papur" <gkapur@...>

A quick question. How can one discern when an object goes out of scope?

46 messages 2003/05/18
[#71678] Re: An Object Going Out Of Scope — "MikkelFJ" <mikkelfj-anti-spam@...> 2003/05/18

[#71680] Re: An Object Going Out Of Scope — Mauricio Fern疣dez <batsman.geo@...> 2003/05/18

On Sun, May 18, 2003 at 06:08:43PM +0900, MikkelFJ wrote:

[#71681] ruby garbage collection — "Gaffer" <gaffer@...> 2003/05/18

i need this for a realtime game application which has embedded ruby -- after

[#71683] Re: ruby garbage collection — Mauricio Fern疣dez <batsman.geo@...> 2003/05/18

On Sun, May 18, 2003 at 08:35:11PM +0900, Gaffer wrote:

[#71685] Re: ruby garbage collection — "Gaffer" <gaffer@...> 2003/05/18

strange, i found the rb_gc call on my own and called that to good effect

[#71688] Re: ruby garbage collection — "Simon Strandgaard" <0bz63fz3m1qt3001@...> 2003/05/18

On Sun, 18 May 2003 22:10:18 +0900, Gaffer wrote:

[#71689] Re: ruby garbage collection — "Gaffer" <gaffer@...> 2003/05/18

i think its actually the GC cleaning up matrix and vector classes (my own

[#71691] Re: ruby garbage collection — "Simon Strandgaard" <0bz63fz3m1qt3001@...> 2003/05/18

On Sun, 18 May 2003 22:39:17 +0900, Gaffer wrote:

[#71692] Re: ruby garbage collection — "Gaffer" <gaffer@...> 2003/05/18

i'm pretty sure i've tracked down the cause, this is my first time embedding

[#71695] Re: ruby garbage collection — "Simon Strandgaard" <0bz63fz3m1qt3001@...> 2003/05/18

On Sun, 18 May 2003 23:48:28 +0900, Gaffer wrote:

[#71948] How I'd like method-wrapping to work... — "Hal E. Fulton" <hal9000@...>

OK, I read Matz's blog entries as well as I could.

16 messages 2003/05/21

[#72030] why is "does" missing from this sub!-stitution? — Dave Oshel <dcoshel@...>

[~/Desktop] dave$ cat foobar.rb ; foobar.rb

19 messages 2003/05/22
[#72037] Re: why is "does" missing from this sub!-stitution? — Dave Oshel <dcoshel@...> 2003/05/22

In article <20030522202818.GA24497@student.ei.uni-stuttgart.de>,

[#72056] Naive CGI question — "Hal E. Fulton" <hal9000@...>

I'm betting this is either impossible

15 messages 2003/05/23

[#72134] Problem compiling extension on Solaris — "Tim Hunter" <cyclists@...>

I have an user who is trying to build RMagick on Solaris with Ruby 1.6.8.

22 messages 2003/05/25
[#72262] Re: Problem compiling extension on Solaris — Daniel Berger <djberge@...> 2003/05/27

[#72150] Binary Tree vs. Hash — Xiangrong Fang <xrfang@...>

Hi ruby fans,

47 messages 2003/05/26

[#72184] Project Directory Structure — Jim Freeze <jim@...>

Hi:

47 messages 2003/05/26
[#72218] Re: Project Directory Structure — "MikkelFJ" <mikkelfj-anti-spam@...> 2003/05/26

[#72222] Re: Project Directory Structure — Jim Freeze <jim@...> 2003/05/26

Thanks everyone for your input so far.

[#72244] Re: Project Directory Structure — Robert Feldt <feldt@...> 2003/05/27

On Tue, 27 May 2003, Jim Freeze wrote:

[#72260] Re: Project Directory Structure — Jim Freeze <jim@...> 2003/05/27

On Tuesday, 27 May 2003 at 18:26:53 +0900, Robert Feldt wrote:

[#72265] Re: Project Directory Structure — Jim Freeze <jim@...> 2003/05/27

Thanks for all the input. A description of the Project

[#72269] Re: Project Directory Structure — Robert Feldt <feldt@...> 2003/05/27

On Wed, 28 May 2003, Jim Freeze wrote:

[#72274] RCR: unpack/pack Bignum — Robert Feldt <feldt@...>

I'm sure this has been discussed before and maybe there are good reasons

27 messages 2003/05/27
[#72375] Re: RCR: unpack/pack Bignum — Robert Feldt <feldt@...> 2003/05/28

No one seems to be interested in this issue so I'll have to reply to

[#72381] Re: RCR: unpack/pack Bignum — nobu.nokada@... 2003/05/28

Hi,

[#72394] Re: RCR: unpack/pack Bignum — Robert Feldt <feldt@...> 2003/05/29

On Thu, 29 May 2003 nobu.nokada@softhome.net wrote:

[#72403] Re: RCR: unpack/pack Bignum — nobu.nokada@... 2003/05/29

Hi,

[#72600] What is BER compression? (was RCR: unpack/pack Bignum) — Sam Roberts <sroberts@...> 2003/05/31

Is it documented anywhere, what this 'w' template is useful for?

[#72371] Windows Installer for Ruby 1.8.0 (CVS) — Andrew Hunt <andy@...>

Hi all,

16 messages 2003/05/28

[#72388] Array.extend versus instance.extend — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

I want to install 'shift_until_kind_of' in the global Array class

18 messages 2003/05/29

[#72420] Metakit for Ruby - Would you want it? — bobx@... (Bob)

I have a gentleman in England who I have been talking with who is

23 messages 2003/05/29

[#72439] Iteration - last detection — "Orion Hunter" <orion2480@...>

Is there any built in functionality for iteration that will allow me to

41 messages 2003/05/29
[#72510] Re: Iteration - last detection — Carlos <angus@...> 2003/05/30

> Is there any built in functionality for iteration that will allow me to

[#72577] IF statement in ruby 1.8.0 (2003-05-26) [i386-mswin32] — "Shashank Date" <sdate@...>

Just when I thought that I had perfectly understood the IF statement in

14 messages 2003/05/31

Re: RCR: unpack/pack Bignum

From: Guillaume Marcais <guslist@...>
Date: 2003-05-28 22:31:16 UTC
List: ruby-talk #72376
On Wednesday 28 May 2003 06:20 pm, you wrote:
> No one seems to be interested in this issue so I'll have to reply to
> myself... ;)

Actually, I am. I am doing packing of 64bits word for SNMP and my solution is 
clumsy at best.


> No one has pointed out that a clean solution for this is currently
> available so I went ahead and implemented it. Below is unit test I used
> and one patch for bignum.c and one for pack.c. The patches are taken
> against latest nightly snapshot:
>
> $ ruby -v
> ruby 1.8.0 (2003-05-27) [i386-mingw32]
>
> It should work for both big and little endian architectures but I've only
> tried on little endian. Would be great if someone can try on big-endian
> machine.

I'll try on my Mac (should be big-endian, isn't it?). It may take may a few 
days before I get around it though.

Guillaume.


> This patch adds a 'W' template character to pack and unpack for
> packing/unpacking an unsigned integer (Fixnum *OR* Bignum). The packing
> is from MSB to LSB so that
>
>  [0xff00].pack("W") == "\377\000"
>
> regardless of the endianness of the machine. Leading zeroes are trimmed
> from the string (except for negative numbers see below). If you pack a
> negative number you loose information about the sign, ie
>
>  [-1].pack("W").unpack("W").first == 1
>
> which is the same as for template 'I' but in contrast to template 'Q'.
>
> I choose W as in "raW binary representation of number" but its hard to
> find a good template char since most are taken.
>
> I didn't implement 'w' for dumping negative numbers since I don't see
> the need. However, the implementation hints at one possible way for how
> to do 'w' (by only allowing negative numbers to have leading zeroes).
>
> If someone finds this worthy/useful its in the public domain so use in
> anyway you want. I tried to stay close to the style in Ruby source but I'm
> sure the code can be even cleaner/nicer/faster.
>
> Regards,
>
> Robert Feldt
>
> Ps. This post is probably too long; I'm sorry... Maybe ruby-core list is
> better for these things? Or just to matz? I'm not fully up-to-date with
> community procedures.
>
> ----------utest_bignum_pack_unpack.rb------------------------------------
> require 'test/unit'
>
> class TestBignumPackAndUnpack < Test::Unit::TestCase
>   def test_01_pack_W_one_byte
>     (0..255).each do |i|
>       assert_equal(i.chr, [i].pack("W"))
>     end
>   end
>
>   def num_with_bytes(bytes)
>     low_limit = 2**(8 * (bytes-1))
>     low_limit + rand(-low_limit + 2**(8*bytes))
>   end
>
>   def assert_pack_W_sampled(numBytes, numSamples = 100)
>     numSamples.times do
>       num = num_with_bytes(numBytes)
>       packed = [num].pack("W")
>       assert_equal(numBytes, packed.length, "num = #{num}")
>       lsb_first = packed.reverse
>       numBytes.times do |i|
> 	assert_equal(lsb_first[i], num & 0xff)
> 	num >>= 8
>       end
>     end
>   end
>
>   def test_02_pack_W_sampled_positive_multi_bytes
>     (2..10).each do |num_bytes|
>       assert_pack_W_sampled(num_bytes, 25)
>     end
>   end
>
>   def test_03_pack_W_large
>     p1024 = [2**1024].pack("W")
>     assert_equal(1.chr + (0.chr*(1024/8)), p1024)
>     p1024_ones = [2**1024-1].pack("W")
>     assert_equal(0xff.chr * (1024/8), p1024_ones)
>     p2048 = [2**2048].pack("W")
>     assert_equal(1.chr + (0.chr*(2048/8)), p2048)
>     p2048_ones = [2**2048-1].pack("W")
>     assert_equal(0xff.chr * (2048/8), p2048_ones)
>   end
>
>   # This might not be what one wants but I think main use is in
>   # converting positive nums so lets leave it as is...
>   # To do 'w' we could make sure that negative numbers always
>   # start with leading 0. This way we could later unpack them without
>   # losing the sign.
>   def test_04_pack_W_negative_numbers
>     assert_equal("\000\000\000\001", [-1].pack("W"))
>     assert_equal("\000\000\000\002", [-2].pack("W"))
>     assert_equal("\000\000\000\377", [-255].pack("W"))
>     assert_equal("\000\000\377\377", [-2**16+1].pack("W"))
>     assert_equal("\000\377\377\377", [-2**24+1].pack("W"))
>     assert_equal("\377\377\377\377", [-2**32+1].pack("W"))
>     assert_equal("\000\000\000\001\000\000\000\000", [-2**32].pack("W"))
>   end
>
>   def test_05_unpack_W_one_byte
>     (0..255).each do |i|
>       assert_equal(i, i.chr.unpack("W").first)
>     end
>   end
>
>   def str_with_bytes(bytes)
>     s = ""
>     bytes.times {s << rand(256).chr}
>     s
>   end
>
>   def test_06_unpack_W_sampled_positive_multi_bytes
>     (2..10).each do |num_bytes|
>       25.times do
> 	s = str_with_bytes(num_bytes)
> 	num = s.unpack("W").first
> 	lsb_first = s.reverse
> 	num_bytes.times do |i|
> 	  assert_equal(lsb_first[i], num & 0xff,
> 		       "s = #{s.unpack('H*')}, num = #{num}")
> 	  num >>= 8
> 	end
>       end
>     end
>   end
>
>   def test_07_unpack_W_large
>     u1024 = (1.chr + (0.chr*(1024/8))).unpack("W").first
>     assert_equal(2**1024, u1024)
>     u1024_ones = (0xff.chr * (1024/8)).unpack("W").first
>     assert_equal(2**1024-1, u1024_ones)
>     u2048 = (1.chr + (0.chr*(2048/8))).unpack("W").first
>     assert_equal(2**2048, u2048)
>     u2048_ones = (0xff.chr * (2048/8)).unpack("W").first
>     assert_equal(2**2048-1, u2048_ones)
>   end
>
>   def test_08_unpack_W_packed_negative_numbers
>     assert_equal(1, [-1].pack("W").unpack("W").first)
>     assert_equal(2, [-2].pack("W").unpack("W").first)
>     assert_equal(255, [-255].pack("W").unpack("W").first)
>     assert_equal(2**16-1, [-2**16+1].pack("W").unpack("W").first)
>     assert_equal(2**24-1, [-2**24+1].pack("W").unpack("W").first)
>     assert_equal(2**32-1, [-2**32+1].pack("W").unpack("W").first)
>     assert_equal(2**32, [-2**32].pack("W").unpack("W").first)
>   end
>
>   def test_09_cycle_pack_then_unpack
>     1000.times do
>       num = rand(2**200)
>       assert_equal(num, [num].pack("W").unpack("W").first)
>     end
>   end
> end
>
> ---------upatch_bignum_c---------------------------------------------
> --- bignum.c	2003-05-28 23:50:04.000000000 +0200
> +++ bignum.c.old	2003-05-28 11:09:30.000000000 +0200
> @@ -306,110 +306,6 @@
>
>  #endif
>
> -/* We should probably use endian in pack.c instead but I had problems
> - * when linking so...
> - */
> -static int
> -big_endian()
> -{
> -    static int init = 0;
> -    static int big_endian_value;
> -    char *p;
> -
> -    if (init) return big_endian_value;
> -    init = 1;
> -    p = (char*)&init;
> -    return big_endian_value = (p[0]==1)?0:1;
> -}
> -
> -/* Pack a nonnegative bignum as raw binary data/bitstring starting from
> - * MSB to LSB.
> - * Returned data will be multiple of SIZEOF_BDIGITS so there can be up to
> - * SIZEOF_BDIGITS-1 leading zeroes.
> - * Assumes that val is really a bignum ie. fixnums
> - * needs to be converted prior to calling this.
> - */
> -void
> -rb_nonneg_bignum_pack(buf, val)
> -    char *buf;
> -    VALUE val;
> -{
> -    long len, i, j, chars;
> -    char *next_digit;
> -
> -    len = RBIGNUM(val)->len;
> -    next_digit = RBIGNUM(val)->digits + (len * SIZEOF_BDIGITS);
> -    if (big_endian()) {
> -        for(i=0; i<len; i++) {
> -            next_digit -= SIZEOF_BDIGITS;
> -            for(j=0; j<SIZEOF_BDIGITS; j++) {
> -	        *buf++ = *(next_digit+j);
> -	    }
> -	}
> -    } else {
> -        for(i=0; i<len; i++) {
> -            next_digit -= SIZEOF_BDIGITS;
> -            for(j=SIZEOF_BDIGITS-1; j>=0; j--) {
> -	        *buf++ = *(next_digit+j);
> -	    }
> -	}
> -    }
> -}
> -
> -VALUE
> -rb_bignum_unpack(buf, sign, len)
> -    const char *buf;
> -    int sign;
> -    long len;
> -{
> -    VALUE big;
> -    long num_digits, i, j;
> -    char *next_digit;
> -    char *extra_digit;
> -    long num_full_digits = len / SIZEOF_BDIGITS;
> -    int extra_bytes = len % SIZEOF_BDIGITS;
> -
> -    num_digits = num_full_digits + (extra_bytes>0 ? 1 : 0);
> -    big = bignew(num_digits, 1);
> -    extra_digit = next_digit =
> -      (char*)RBIGNUM(big)->digits + num_full_digits * SIZEOF_BDIGITS;
> -
> -    if (big_endian()) {
> -        if (extra_bytes > 0) {
> -	    for(i = 0; i < SIZEOF_BDIGITS - extra_bytes; i++) {
> -	        *extra_digit++ = 0;
> -	    }
> -	    for(i = 0; i < extra_bytes; i++) {
> -	        *extra_digit++ = *buf++;
> -	    }
> -        }
> -        for(i = 0; i < num_full_digits; i++) {
> -	    next_digit -= SIZEOF_BDIGITS;
> -	    for(j = 0; j < SIZEOF_BDIGITS; j++) {
> -	        *next_digit++ = *buf++;
> -	    }
> -        }
> -    } else {
> -        if (extra_bytes > 0) {
> -	    for(i = extra_bytes - 1; i >= 0 ; i--) {
> -	        *(extra_digit+i) = *buf++;
> -	    }
> -	    extra_digit += extra_bytes;
> -	    for(i = 0; i < SIZEOF_BDIGITS - extra_bytes; i++) {
> -	        *extra_digit++ = 0;
> -	    }
> -        }
> -        for(i = 0; i < num_full_digits; i++) {
> -	    next_digit -= SIZEOF_BDIGITS;
> -	    for(j = SIZEOF_BDIGITS - 1; j >= 0; j--) {
> -	        *(next_digit+j) = *buf++;
> -	    }
> -        }
> -    }
> -
> -    return bignorm(big);
> -}
> -
>  VALUE
>  rb_cstr_to_inum(str, base, badcheck)
>      const char *str;
>
>
> --------upatch_pack_c------------------------------------------------------
>- --- pack.c	2003-05-28 23:55:32.000000000 +0200
> +++ pack.c.old	2003-05-28 11:19:21.000000000 +0200
> @@ -376,21 +376,6 @@
>  static int uv_to_utf8 _((char*,unsigned long));
>  static unsigned long utf8_to_uv _((char*,long*));
>
> -VALUE
> -ensure_bignum(val)
> -    VALUE val;
> -{
> -    if (NIL_P(val)) {
> -        val = INT2FIX(0);
> -    } else {
> -        val = rb_to_int(val);
> -    }
> -    if (FIXNUM_P(val)) {
> -        val = rb_int2big(FIX2LONG(val));
> -    }
> -    return val;
> -}
> -
>  static VALUE
>  pack_pack(ary, fmt)
>      VALUE ary, fmt;
> @@ -683,33 +668,6 @@
>  	    }
>  	    break;
>
> -	  case 'W':
> -            while (len-- > 0) {
> -	        VALUE from;
> -                long len;
> -		long num_bytes_to_skip = 0;
> -
> -		from = ensure_bignum(NEXTFROM);
> -                len = RBIGNUM(from)->len * SIZEOF_BDIGITS;
> -                {
> -		    char tmp[len];
> -
> -                    rb_nonneg_bignum_pack(tmp, from);
> -		    // Skip leading zeroes if positive bignum. Extend
> -		    // this "strategy" for 'w' so that only negative
> -		    // bignums (and 0) can have leading zero?
> -		    if (RBIGNUM(from)->sign) {
> -		        while (num_bytes_to_skip < (len-1) &&
> -			       tmp[num_bytes_to_skip] == 0x00) {
> -		          num_bytes_to_skip++;
> -		        }
> -		    }
> -		    rb_str_buf_cat(res, ((char*)&tmp) + num_bytes_to_skip,
> -				   len - num_bytes_to_skip);
> -		}
> -	    }
> -	    break;
> -
>  	  case 'n':
>  	    while (len-- > 0) {
>  		unsigned short s;
> @@ -1456,11 +1414,6 @@
>  	    }
>  	    break;
>
> -	case 'W':
> -	  rb_ary_push(ary, rb_bignum_unpack(s, 1, send - s));
> -	  s = send;
> -	  break;
> -
>  	  case 'n':
>  	    PACK_LENGTH_ADJUST(unsigned short,2);
>  	    while (len-- > 0) {
>
> --------------------------------------------------------------------

In This Thread