mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* include/ruby/ruby.h (STR2CSTR): removed.
(rb_str2cstr): removed. * object.c (rb_str2cstr): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
849e730f15
commit
074a374c86
5 changed files with 11 additions and 26 deletions
|
@ -1,3 +1,10 @@
|
|||
Sat Jan 31 22:29:05 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/ruby.h (STR2CSTR): removed.
|
||||
(rb_str2cstr): removed.
|
||||
|
||||
* object.c (rb_str2cstr): removed.
|
||||
|
||||
Sat Jan 31 20:07:59 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/raddrinfo.c (addrinfo_ipv6_unspecified_p): new method.
|
||||
|
|
|
@ -103,7 +103,7 @@ numbers into C integers. These macros includes a type check,
|
|||
so an exception will be raised if the conversion failed. NUM2DBL()
|
||||
can be used to retrieve the double float value in the same way.
|
||||
|
||||
In version 1.7 or later it is recommended that you use the new macros
|
||||
You can use the macros
|
||||
StringValue() and StringValuePtr() to get a char* from a VALUE.
|
||||
StringValue(var) replaces var's value with the result of "var.to_str()".
|
||||
StringValuePtr(var) does same replacement and returns char*
|
||||
|
@ -118,10 +118,6 @@ the ArgumentError exception.
|
|||
StringValuePtr() doesn't gurantee to exist nul at the end of the
|
||||
result, and the result may contain nul.
|
||||
|
||||
In version 1.6 or earlier, STR2CSTR() was used to do the same thing
|
||||
but now it is deprecated in version 1.7, because STR2CSTR() has a risk
|
||||
of a dangling pointer problem in the to_str() implicit conversion.
|
||||
|
||||
Other data types have corresponding C structures, e.g. struct RArray
|
||||
for T_ARRAY etc. The VALUE of the type which has the corresponding
|
||||
structure can be cast to retrieve the pointer to the struct. The
|
||||
|
|
|
@ -115,11 +115,9 @@ FIXNUM
|
|||
(整数に変換できない場合には例外が発生する).同様にチェック無
|
||||
で使える変換マクロはdoubleを取り出す「NUM2DBL()」があります.
|
||||
|
||||
char* を取り出す場合,version 1.6 以前では「STR2CSTR()」とい
|
||||
うマクロを使っていましたが,これは to_str() による暗黙の型変
|
||||
換結果が GC される可能性があるため,version 1.7 以降では
|
||||
obsolete となり,代わりに StringValue() と StringValuePtr()
|
||||
を使う事を推奨しています.StringValue(var) は var が String
|
||||
char* を取り出す場合, StringValue() と StringValuePtr()
|
||||
を使います.
|
||||
StringValue(var) は var が String
|
||||
であれば何もせず,そうでなければ var を var.to_str() の結果
|
||||
に置き換えるマクロ,StringValuePtr(var) は同様に var を
|
||||
String に置き換えてから var のバイト列表現に対する char* を
|
||||
|
|
|
@ -515,11 +515,6 @@ ULONG2NUM(unsigned long v)
|
|||
return rb_uint2big(v);
|
||||
}
|
||||
|
||||
/* obsolete API - use StringValue() */
|
||||
char *rb_str2cstr(VALUE,long*);
|
||||
/* obsolete API - use StringValuePtr() */
|
||||
#define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)
|
||||
|
||||
#define NUM2CHR(x) (((TYPE(x) == T_STRING)&&(RSTRING_LEN(x)>=1))?\
|
||||
RSTRING_PTR(x)[0]:(char)(NUM2INT(x)&0xff))
|
||||
#define CHR2FIX(x) INT2FIX((long)((x)&0xff))
|
||||
|
|
11
object.c
11
object.c
|
@ -2304,17 +2304,6 @@ rb_num2dbl(VALUE val)
|
|||
return RFLOAT_VALUE(rb_Float(val));
|
||||
}
|
||||
|
||||
char*
|
||||
rb_str2cstr(VALUE str, long *len)
|
||||
{
|
||||
StringValue(str);
|
||||
if (len) *len = RSTRING_LEN(str);
|
||||
else if (RTEST(ruby_verbose) && RSTRING_LEN(str) != strlen(RSTRING_PTR(str))) {
|
||||
rb_warn("string contains \\0 character");
|
||||
}
|
||||
return RSTRING_PTR(str);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_String(VALUE val)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue