ruby-changes:29997
From: akr <ko1@a...>
Date: Fri, 19 Jul 2013 01:08:06 +0900 (JST)
Subject: [ruby-changes:29997] akr:r42049 (trunk): * ext/-test-/bignum/intpack.c: Renamed from ext/-test-/bignum/pack.c.
akr 2013-07-19 01:07:03 +0900 (Fri, 19 Jul 2013) New Revision: 42049 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42049 Log: * ext/-test-/bignum/intpack.c: Renamed from ext/-test-/bignum/pack.c. (Init_intpack): Renamed from Init_pack. Reported by Naohisa Goto. [ruby-dev:47526] [Bug #8655] Added files: trunk/ext/-test-/bignum/intpack.c Removed files: trunk/ext/-test-/bignum/pack.c Modified files: trunk/ChangeLog trunk/ext/-test-/bignum/depend Index: ChangeLog =================================================================== --- ChangeLog (revision 42048) +++ ChangeLog (revision 42049) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jul 19 01:04:14 2013 Tanaka Akira <akr@f...> + + * ext/-test-/bignum/intpack.c: Renamed from ext/-test-/bignum/pack.c. + (Init_intpack): Renamed from Init_pack. + Reported by Naohisa Goto. [ruby-dev:47526] [Bug #8655] + Fri Jul 19 00:54:27 2013 Benoit Daloze <eregontp@g...> * test/ruby/test_array.rb (test_count): add a test case for #count Index: ext/-test-/bignum/pack.c =================================================================== --- ext/-test-/bignum/pack.c (revision 42048) +++ ext/-test-/bignum/pack.c (revision 42049) @@ -1,65 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/bignum/pack.c#L0 -#include "ruby.h" -#include "internal.h" - -static VALUE -rb_integer_pack_raw_m(VALUE val, VALUE buf, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags) -{ - int sign; - size_t numwords = 0; - size_t wordsize = NUM2SIZET(wordsize_arg); - - StringValue(buf); - rb_str_modify(buf); - sign = rb_integer_pack(val, - RSTRING_PTR(buf), NUM2SIZET(numwords_arg), - NUM2SIZET(wordsize_arg), NUM2SIZET(nails), NUM2INT(flags)); - - return rb_ary_new_from_args(2, INT2NUM(sign), rb_str_new(RSTRING_PTR(buf), wordsize * numwords)); -} - -static VALUE -rb_integer_pack_m(VALUE val, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags) -{ - int sign; - size_t numwords = NUM2SIZET(numwords_arg); - size_t wordsize = NUM2SIZET(wordsize_arg); - VALUE buf; - - if (numwords != 0 && wordsize != 0 && LONG_MAX / wordsize < numwords) - rb_raise(rb_eArgError, "too big numwords * wordsize"); - buf = rb_str_new(NULL, numwords * wordsize); - sign = rb_integer_pack(val, - RSTRING_PTR(buf), numwords, - wordsize, NUM2SIZET(nails), NUM2INT(flags)); - - return rb_assoc_new(INT2NUM(sign), buf); -} - -static VALUE -rb_integer_unpack_m(VALUE klass, VALUE buf, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags) -{ - StringValue(buf); - - return rb_integer_unpack(RSTRING_PTR(buf), - NUM2SIZET(numwords), NUM2SIZET(wordsize), - NUM2SIZET(nails), NUM2INT(flags)); -} - -void -Init_pack(VALUE klass) -{ - rb_define_method(rb_cInteger, "test_pack_raw", rb_integer_pack_raw_m, 5); - rb_define_method(rb_cInteger, "test_pack", rb_integer_pack_m, 4); - rb_define_singleton_method(rb_cInteger, "test_unpack", rb_integer_unpack_m, 5); - rb_define_const(rb_cInteger, "INTEGER_PACK_MSWORD_FIRST", INT2NUM(INTEGER_PACK_MSWORD_FIRST)); - rb_define_const(rb_cInteger, "INTEGER_PACK_LSWORD_FIRST", INT2NUM(INTEGER_PACK_LSWORD_FIRST)); - rb_define_const(rb_cInteger, "INTEGER_PACK_MSBYTE_FIRST", INT2NUM(INTEGER_PACK_MSBYTE_FIRST)); - rb_define_const(rb_cInteger, "INTEGER_PACK_LSBYTE_FIRST", INT2NUM(INTEGER_PACK_LSBYTE_FIRST)); - rb_define_const(rb_cInteger, "INTEGER_PACK_NATIVE_BYTE_ORDER", INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER)); - rb_define_const(rb_cInteger, "INTEGER_PACK_2COMP", INT2NUM(INTEGER_PACK_2COMP)); - rb_define_const(rb_cInteger, "INTEGER_PACK_LITTLE_ENDIAN", INT2NUM(INTEGER_PACK_LITTLE_ENDIAN)); - rb_define_const(rb_cInteger, "INTEGER_PACK_BIG_ENDIAN", INT2NUM(INTEGER_PACK_BIG_ENDIAN)); - rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_BIGNUM", INT2NUM(INTEGER_PACK_FORCE_BIGNUM)); - rb_define_const(rb_cInteger, "INTEGER_PACK_NEGATIVE", INT2NUM(INTEGER_PACK_NEGATIVE)); - rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION", INT2NUM(INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION)); -} Index: ext/-test-/bignum/depend =================================================================== --- ext/-test-/bignum/depend (revision 42048) +++ ext/-test-/bignum/depend (revision 42049) @@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/bignum/depend#L1 $(OBJS): $(HDRS) $(ruby_headers) -pack.o: pack.c $(top_srcdir)/internal.h +intpack.o: intpack.c $(top_srcdir)/internal.h mul.o: mul.c $(top_srcdir)/internal.h Index: ext/-test-/bignum/intpack.c =================================================================== --- ext/-test-/bignum/intpack.c (revision 0) +++ ext/-test-/bignum/intpack.c (revision 42049) @@ -0,0 +1,65 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/bignum/intpack.c#L1 +#include "ruby.h" +#include "internal.h" + +static VALUE +rb_integer_pack_raw_m(VALUE val, VALUE buf, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags) +{ + int sign; + size_t numwords = 0; + size_t wordsize = NUM2SIZET(wordsize_arg); + + StringValue(buf); + rb_str_modify(buf); + sign = rb_integer_pack(val, + RSTRING_PTR(buf), NUM2SIZET(numwords_arg), + NUM2SIZET(wordsize_arg), NUM2SIZET(nails), NUM2INT(flags)); + + return rb_ary_new_from_args(2, INT2NUM(sign), rb_str_new(RSTRING_PTR(buf), wordsize * numwords)); +} + +static VALUE +rb_integer_pack_m(VALUE val, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags) +{ + int sign; + size_t numwords = NUM2SIZET(numwords_arg); + size_t wordsize = NUM2SIZET(wordsize_arg); + VALUE buf; + + if (numwords != 0 && wordsize != 0 && LONG_MAX / wordsize < numwords) + rb_raise(rb_eArgError, "too big numwords * wordsize"); + buf = rb_str_new(NULL, numwords * wordsize); + sign = rb_integer_pack(val, + RSTRING_PTR(buf), numwords, + wordsize, NUM2SIZET(nails), NUM2INT(flags)); + + return rb_assoc_new(INT2NUM(sign), buf); +} + +static VALUE +rb_integer_unpack_m(VALUE klass, VALUE buf, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags) +{ + StringValue(buf); + + return rb_integer_unpack(RSTRING_PTR(buf), + NUM2SIZET(numwords), NUM2SIZET(wordsize), + NUM2SIZET(nails), NUM2INT(flags)); +} + +void +Init_intpack(VALUE klass) +{ + rb_define_method(rb_cInteger, "test_pack_raw", rb_integer_pack_raw_m, 5); + rb_define_method(rb_cInteger, "test_pack", rb_integer_pack_m, 4); + rb_define_singleton_method(rb_cInteger, "test_unpack", rb_integer_unpack_m, 5); + rb_define_const(rb_cInteger, "INTEGER_PACK_MSWORD_FIRST", INT2NUM(INTEGER_PACK_MSWORD_FIRST)); + rb_define_const(rb_cInteger, "INTEGER_PACK_LSWORD_FIRST", INT2NUM(INTEGER_PACK_LSWORD_FIRST)); + rb_define_const(rb_cInteger, "INTEGER_PACK_MSBYTE_FIRST", INT2NUM(INTEGER_PACK_MSBYTE_FIRST)); + rb_define_const(rb_cInteger, "INTEGER_PACK_LSBYTE_FIRST", INT2NUM(INTEGER_PACK_LSBYTE_FIRST)); + rb_define_const(rb_cInteger, "INTEGER_PACK_NATIVE_BYTE_ORDER", INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER)); + rb_define_const(rb_cInteger, "INTEGER_PACK_2COMP", INT2NUM(INTEGER_PACK_2COMP)); + rb_define_const(rb_cInteger, "INTEGER_PACK_LITTLE_ENDIAN", INT2NUM(INTEGER_PACK_LITTLE_ENDIAN)); + rb_define_const(rb_cInteger, "INTEGER_PACK_BIG_ENDIAN", INT2NUM(INTEGER_PACK_BIG_ENDIAN)); + rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_BIGNUM", INT2NUM(INTEGER_PACK_FORCE_BIGNUM)); + rb_define_const(rb_cInteger, "INTEGER_PACK_NEGATIVE", INT2NUM(INTEGER_PACK_NEGATIVE)); + rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION", INT2NUM(INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION)); +} Property changes on: ext/-test-/bignum/intpack.c ___________________________________________________________________ Added: svn:eol-style + LF -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/