From 234c47e9fba274e1d07bdc39846cb9dbe3db569e Mon Sep 17 00:00:00 2001 From: matz Date: Sun, 9 Apr 2006 16:10:40 +0000 Subject: * prec.c (prec_prec_f): documentation patch from . [ruby-core:07689] * bignum.c (rb_big_pow): second operand may be too big even if it's a Fixnum. [ruby-talk:187984] * README.EXT: update symbol description. [ruby-talk:188104] * COPYING: explicitly note GPLv2. [ruby-talk:187922] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- COPYING | 2 +- ChangeLog | 18 ++++++++++++++++++ README.EXT | 23 ++++++++++++++++++----- README.EXT.ja | 11 ++++++++++- bignum.c | 5 +++++ prec.c | 4 ++-- 6 files changed, 54 insertions(+), 9 deletions(-) diff --git a/COPYING b/COPYING index 870a5f22d6..9043404a83 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ Ruby is copyrighted free software by Yukihiro Matsumoto . You can redistribute it and/or modify it under either the terms of the GPL -(see the file GPL), or the conditions below: +version 2 (see the file GPL), or the conditions below: 1. You may make and give away verbatim copies of the source form of the software without restriction, provided that you duplicate all of the diff --git a/ChangeLog b/ChangeLog index b5d90797cb..488b4134c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Mon Apr 10 01:03:10 2006 Yukihiro Matsumoto + + * prec.c (prec_prec_f): documentation patch from + . [ruby-core:07689] + +Sat Apr 8 02:34:34 2006 Yukihiro Matsumoto + + * bignum.c (rb_big_pow): second operand may be too big even if + it's a Fixnum. [ruby-talk:187984] + +Sat Apr 8 02:12:38 2006 Yukihiro Matsumoto + + * README.EXT: update symbol description. [ruby-talk:188104] + +Thu Apr 6 23:28:47 2006 Yukihiro Matsumoto + + * COPYING: explicitly note GPLv2. [ruby-talk:187922] + Thu Apr 6 11:18:37 2006 Hidetoshi NAGAI * ext/tk/lib/tk/panedwindow.rb: lack of arguments. [ruby-core:7681] diff --git a/README.EXT b/README.EXT index 4cfe80bd82..e5d39911ca 100644 --- a/README.EXT +++ b/README.EXT @@ -330,17 +330,30 @@ of the innermost method (which is defined by Ruby) can be accessed. 2.2.2 ID or Symbol -You can invoke methods directly, without parsing the string. First I -need to explain about symbols (whose data type is ID). ID is the -integer number to represent Ruby's identifiers such as variable names. -It can be accessed from Ruby in the form: +You can invoke methods directly, without parsing the string. First I need +to explain about ID. ID is the integer number to represent Ruby's +identifiers such as variable names. The Ruby data type corresponding to ID +is Symbol. It can be accessed from Ruby in the form: :Identifier -You can get the symbol value from a string within C code by using +You can get the ID value from a string within C code by using rb_intern(const char *name) +You can retrieve ID from Ruby object (Symbol or String) given as an +argument by using + + rb_to_id(VALUE symbol) + +You can convert C ID to Ruby Symbol by using + + VALUE ID2SYM(ID id) + +and to convert Ruby Symbol object to ID, use + + ID SYM2ID(VALUE symbol) + 2.2.3 Invoke Ruby method from C To invoke methods directly, you can use the function below diff --git a/README.EXT.ja b/README.EXT.ja index f8b625e7ef..30c4d520ba 100644 --- a/README.EXT.ja +++ b/README.EXT.ja @@ -380,7 +380,8 @@ C す.その前に,Rubyインタプリタ内でメソッドや変数名を指定する 時に使われているIDについて説明しておきましょう. -IDとは変数名,メソッド名を表す整数です.Rubyの中では +IDとは変数名,メソッド名を表す整数です.RubyではIDに対応する +オブジェクトとしてシンボル(Symbol)があり, :識別子 @@ -393,6 +394,14 @@ ID rb_to_id(VALUE symbol) +IDからシンボルを得るためには以下のマクロを使います. + + VALUE ID2SYM(ID id) + +シンボルからIDを得るためには以下のマクロを使います. + + ID SYM2ID(VALUE symbol) + 2.2.3 CからRubyのメソッドを呼び出す Cから文字列を経由せずにRubyのメソッドを呼び出すためには以下 diff --git a/bignum.c b/bignum.c index 425676d32c..6a7a83c085 100644 --- a/bignum.c +++ b/bignum.c @@ -1606,6 +1606,11 @@ rb_big_pow(x, y) if (yy > 0) { VALUE z = x; + if (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) { + rb_warn("in a**b, b may be too big"); + d = (double)yy; + break; + } for (;;) { yy -= 1; if (yy == 0) break; diff --git a/prec.c b/prec.c index dc89a01435..7b215fba09 100644 --- a/prec.c +++ b/prec.c @@ -57,9 +57,9 @@ prec_prec_i(x) /* * call-seq: - * num.prec_f => Integer + * num.prec_f => Float * - * Returns an +Float+ converted from _num_. It is equivalent + * Returns a +Float+ converted from _num_. It is equivalent * to prec(Float). */ -- cgit v1.2.3