From 53e15970365cd5315f608c46e4a1ffde89726a00 Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 26 Apr 2016 04:40:24 +0000 Subject: * README.EXT{,.ja}: `nul` should be uppercase. change 'nul' => 'NUL'. [Fix GH-1172] derived from a patch by craft4coder * doc/extension.rdoc: Improvements to english grammers. [Bug #12246][ruby-core:74792][ci skip] derived from a patch by Marcus Stollsteimer git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@54773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ README.EXT | 52 ++++++++++++++++++++++++++-------------------------- README.EXT.ja | 6 +++--- version.h | 2 +- 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index dd1265d873..2cfdb2c2f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Apr 26 13:38:31 2016 NAKAMURA Usaku + + * README.EXT{,.ja}: `nul` should be uppercase. + change 'nul' => 'NUL'. [Fix GH-1172] + derived from a patch by craft4coder + + * doc/extension.rdoc: Improvements to english grammers. + [Bug #12246][ruby-core:74792][ci skip] + derived from a patch by Marcus Stollsteimer + Tue Apr 26 13:25:25 2016 Marcus Stollsteimer * encoding.c: Fix return value of `Encoding::ISO8859_1.name` diff --git a/README.EXT b/README.EXT index 62bf4f3089..3e010c3002 100644 --- a/README.EXT +++ b/README.EXT @@ -9,7 +9,7 @@ Ruby variables do not have a static type, and data themselves have types, so data will need to be converted between the languages. Data in Ruby are represented by the C type `VALUE'. Each VALUE data -has its data-type. +has its data type. To retrieve C data from a VALUE, you need to: @@ -18,7 +18,7 @@ To retrieve C data from a VALUE, you need to: Converting to the wrong data type may cause serious problems. -== Data-Types +== Data Types The Ruby interpreter has the following data types: @@ -74,7 +74,7 @@ data types, your code will look something like this: break; } -There is the data-type check function +There is the data type check function void Check_Type(VALUE value, int type) @@ -94,7 +94,7 @@ The equivalent C constants are: Qnil, Qfalse, Qtrue. Note that Qfalse is false in C also (i.e. 0), but not Qnil. The T_FIXNUM data is a 31bit or 63bit length fixed integer. -This size is depend on the size of long: if long is 32bit then +This size depends on the size of long: if long is 32bit then T_FIXNUM is 31bit, if long is 64bit then T_FIXNUM is 63bit. T_FIXNUM can be converted to a C integer by using the FIX2INT() macro or FIX2LONG(). Though you have to check that the @@ -102,32 +102,32 @@ data is really FIXNUM before using them, they are faster. FIX2LONG() never raises exceptions, but FIX2INT() raises RangeError if the result is bigger or smaller than the size of int. There are also NUM2INT() and NUM2LONG() which converts any Ruby -numbers into C integers. These macros includes a type check, +numbers into C integers. These macros include 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. 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* +StringValuePtr(var) does the same replacement and returns char* representation of var. These macros will skip the replacement if var is a String. Notice that the macros take only the lvalue as their argument, to change the value of var in place. You can also use the macro named StringValueCStr(). This is just -like StringValuePtr(), but always add nul character at the end of -the result. If the result contains nul character, this macro causes +like StringValuePtr(), but always add NUL character at the end of +the result. If the result contains NUL character, this macro causes the ArgumentError exception. -StringValuePtr() doesn't guarantee the existence of a nul at the end -of the result, and the result may contain nul. +StringValuePtr() doesn't guarantee the existence of a NUL at the end +of the result, and the result may contain NUL. 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 casting macro will be of the form RXXXX for each data type; for instance, RARRAY(obj). See "ruby.h". However, we do not recommend -to access RXXXX data directly because these data structure is complex. -Use corresponding rb_xxx() functions to access internal struct. +to access RXXXX data directly because these data structures are complex. +Use corresponding rb_xxx() functions to access the internal struct. For example, to access an entry of array, use rb_ary_entry(ary, offset) and rb_ary_store(ary, offset, obj). @@ -145,22 +145,22 @@ To convert C data to Ruby values: FIXNUM :: - left shift 1 bit, and turn on LSB. + left shift 1 bit, and turn on its least significant bit (LSB). Other pointer values:: cast to VALUE. -You can determine whether a VALUE is pointer or not by checking its LSB. +You can determine whether a VALUE is a pointer or not by checking its LSB. -Notice Ruby does not allow arbitrary pointer values to be a VALUE. They +Notice: Ruby does not allow arbitrary pointer values to be a VALUE. They should be pointers to the structures which Ruby knows about. The known structures are defined in . -To convert C numbers to Ruby values, use these macros. +To convert C numbers to Ruby values, use these macros: INT2FIX() :: for integers within 31bits. -INT2NUM() :: for arbitrary sized integer. +INT2NUM() :: for arbitrary sized integers. INT2NUM() converts an integer into a Bignum if it is out of the FIXNUM range, but is a bit slower. @@ -258,7 +258,7 @@ rb_utf8_str_new_literal(const char *ptr) :: rb_str_resize(VALUE str, long len) :: - Resizes Ruby string to len bytes. If str is not modifiable, this + Resizes a Ruby string to len bytes. If str is not modifiable, this function raises an exception. The length of str must be set in advance. If len is less than the old length the content beyond len bytes is discarded, else if len is greater than the old length @@ -268,9 +268,9 @@ rb_str_resize(VALUE str, long len) :: rb_str_set_len(VALUE str, long len) :: - Sets the length of Ruby string. If str is not modifiable, this + Sets the length of a Ruby string. If str is not modifiable, this function raises an exception. This function preserves the content - upto len bytes, regardless RSTRING_LEN(str). len must not exceed + up to len bytes, regardless RSTRING_LEN(str). len must not exceed the capacity of str. === Array Functions @@ -398,9 +398,9 @@ There are two functions to define private/protected methods: void rb_define_protected_method(VALUE klass, const char *name, VALUE (*func)(), int argc) -At last, rb_define_module_function defines a module functions, +At last, rb_define_module_function defines a module function, which are private AND singleton methods of the module. -For example, sqrt is the module function defined in Math module. +For example, sqrt is a module function defined in the Math module. It can be called in the following way: Math.sqrt(4) @@ -476,7 +476,7 @@ function: VALUE rb_eval_string_protect(const char *str, int *state) -It returns nil when an error occur. Moreover, *state is zero if str was +It returns nil when an error occurred. Moreover, *state is zero if str was successfully evaluated, or nonzero otherwise. === ID or Symbol @@ -560,7 +560,7 @@ See also Constant Definition above. = Information Sharing Between Ruby and C -=== Ruby Constants That C Can Be Accessed From C +=== Ruby Constants That Can Be Accessed From C As stated in section 1.3, the following Ruby constants can be referred from C. @@ -658,7 +658,7 @@ A pointer to the structure will be assigned to the variable sval. See the example below for details. -= Example - Creating dbm Extension += Example - Creating the dbm Extension OK, here's the example of making an extension library. This is the extension to access DBMs. The full source is included in the ext/ @@ -1153,7 +1153,7 @@ rb_str_new2(s) :: char * -> String -== Defining Class and Module +== Defining Classes and Modules VALUE rb_define_class(const char *name, VALUE super) :: diff --git a/README.EXT.ja b/README.EXT.ja index d67ea2a3ba..b662d4dfdb 100644 --- a/README.EXT.ja +++ b/README.EXT.ja @@ -126,10 +126,10 @@ var は lvalue である必要があります. また,StringValuePtr() に類似した StringValueCStr() というマ クロもあります.StringValueCStr(var) は var を String に置き 換えてから var の文字列表現に対する char* を返します.返され -る文字列の末尾には nul 文字が付加されます.なお,途中に nul +る文字列の末尾には NUL 文字が付加されます.なお,途中に NUL 文字が含まれる場合は ArgumentError が発生します. -一方,StringValuePtr() では,末尾に nul 文字がある保証はなく, -途中に nul 文字が含まれている可能性もあります. +一方,StringValuePtr() では,末尾に NUL 文字がある保証はなく, +途中に NUL 文字が含まれている可能性もあります. それ以外のデータタイプは対応するCの構造体があります.対応す る構造体のあるVALUEはそのままキャスト(型変換)すれば構造体の diff --git a/version.h b/version.h index bd5868eefb..c63860c228 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.5" #define RUBY_RELEASE_DATE "2016-04-26" -#define RUBY_PATCHLEVEL 318 +#define RUBY_PATCHLEVEL 319 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 4 -- cgit v1.2.3