зеркало из https://github.com/github/ruby.git
stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
624d07b0e4
Коммит
12d2c8ba41
380
array.c
380
array.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
4
bignum.c
4
bignum.c
|
@ -1714,7 +1714,7 @@ bigmul1_karatsuba(VALUE x, VALUE y)
|
|||
t1 = xl; xl = xh; xh = t1;
|
||||
}
|
||||
bigadd_core(BDIGITS(xh), RBIGNUM_LEN(xh),
|
||||
BDIGITS(xl), RBIGNUM_LEN(xl),
|
||||
BDIGITS(xl), RBIGNUM_LEN(xl),
|
||||
BDIGITS(xh), RBIGNUM_LEN(xh));
|
||||
|
||||
/* yh <- yh + yl */
|
||||
|
@ -1723,7 +1723,7 @@ bigmul1_karatsuba(VALUE x, VALUE y)
|
|||
t1 = yl; yl = yh; yh = t1;
|
||||
}
|
||||
bigadd_core(BDIGITS(yh), RBIGNUM_LEN(yh),
|
||||
BDIGITS(yl), RBIGNUM_LEN(yl),
|
||||
BDIGITS(yl), RBIGNUM_LEN(yl),
|
||||
BDIGITS(yh), RBIGNUM_LEN(yh));
|
||||
}
|
||||
else yh = xh;
|
||||
|
|
|
@ -34,7 +34,7 @@ iseq_special_block(rb_iseq_t *iseq, void *builder)
|
|||
else {
|
||||
iseq->cached_special_block_builder = (void *)1;
|
||||
}
|
||||
|
||||
|
||||
if (iseq->parent_iseq) {
|
||||
parent = iseq->parent_iseq->self;
|
||||
}
|
||||
|
|
62
class.c
62
class.c
|
@ -82,7 +82,7 @@ clone_method(ID mid, NODE *body, struct clone_method_data *data)
|
|||
NODE *fbody = body->nd_body->nd_body;
|
||||
|
||||
if (nd_type(fbody) == RUBY_VM_METHOD_NODE) {
|
||||
fbody = NEW_NODE(RUBY_VM_METHOD_NODE, 0,
|
||||
fbody = NEW_NODE(RUBY_VM_METHOD_NODE, 0,
|
||||
rb_iseq_clone((VALUE)fbody->nd_body, data->klass),
|
||||
0);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ make_metametaclass(VALUE metaclass)
|
|||
}
|
||||
else {
|
||||
metametaclass = rb_class_boot(Qnil);
|
||||
RBASIC(metametaclass)->klass =
|
||||
RBASIC(metametaclass)->klass =
|
||||
(RBASIC(RBASIC(metaclass)->klass)->klass == RBASIC(metaclass)->klass)
|
||||
? make_metametaclass(RBASIC(metaclass)->klass)
|
||||
: RBASIC(RBASIC(metaclass)->klass)->klass;
|
||||
|
@ -212,9 +212,9 @@ make_metametaclass(VALUE metaclass)
|
|||
while (FL_TEST(super_of_metaclass, T_ICLASS)) {
|
||||
super_of_metaclass = RCLASS_SUPER(super_of_metaclass);
|
||||
}
|
||||
RCLASS_SUPER(metametaclass) =
|
||||
RCLASS_SUPER(metametaclass) =
|
||||
rb_iv_get(RBASIC(super_of_metaclass)->klass, "__attached__") == super_of_metaclass
|
||||
? RBASIC(super_of_metaclass)->klass
|
||||
? RBASIC(super_of_metaclass)->klass
|
||||
: make_metametaclass(super_of_metaclass);
|
||||
OBJ_INFECT(metametaclass, RCLASS_SUPER(metametaclass));
|
||||
|
||||
|
@ -422,7 +422,7 @@ rb_include_module(VALUE klass, VALUE module)
|
|||
if (!OBJ_UNTRUSTED(klass)) {
|
||||
rb_secure(4);
|
||||
}
|
||||
|
||||
|
||||
if (TYPE(module) != T_MODULE) {
|
||||
Check_Type(module, T_MODULE);
|
||||
}
|
||||
|
@ -461,16 +461,16 @@ rb_include_module(VALUE klass, VALUE module)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.included_modules -> array
|
||||
*
|
||||
*
|
||||
* Returns the list of modules included in <i>mod</i>.
|
||||
*
|
||||
*
|
||||
* module Mixin
|
||||
* end
|
||||
*
|
||||
*
|
||||
* module Outer
|
||||
* include Mixin
|
||||
* end
|
||||
*
|
||||
*
|
||||
* Mixin.included_modules #=> []
|
||||
* Outer.included_modules #=> [Mixin]
|
||||
*/
|
||||
|
@ -492,10 +492,10 @@ rb_mod_included_modules(VALUE mod)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.include?(module) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>module</i> is included in
|
||||
* <i>mod</i> or one of <i>mod</i>'s ancestors.
|
||||
*
|
||||
*
|
||||
* module A
|
||||
* end
|
||||
* class B
|
||||
|
@ -525,15 +525,15 @@ rb_mod_include_p(VALUE mod, VALUE mod2)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.ancestors -> array
|
||||
*
|
||||
*
|
||||
* Returns a list of modules included in <i>mod</i> (including
|
||||
* <i>mod</i> itself).
|
||||
*
|
||||
*
|
||||
* module Mod
|
||||
* include Math
|
||||
* include Comparable
|
||||
* end
|
||||
*
|
||||
*
|
||||
* Mod.ancestors #=> [Mod, Comparable, Math]
|
||||
* Math.ancestors #=> [Math]
|
||||
*/
|
||||
|
@ -612,7 +612,7 @@ method_entry(ID key, NODE *body, st_table *list)
|
|||
if (key == ID_ALLOCATOR) {
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
if (!st_lookup(list, key, 0)) {
|
||||
if (body ==0 || !body->nd_body->nd_body) {
|
||||
type = -1; /* none */
|
||||
|
@ -658,14 +658,14 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, lo
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.instance_methods(include_super=true) => array
|
||||
*
|
||||
*
|
||||
* Returns an array containing the names of instance methods that is callable
|
||||
* from outside in the receiver. For a module, these are the public methods;
|
||||
* for a class, they are the instance (not singleton) methods. With no
|
||||
* argument, or with an argument that is <code>false</code>, the
|
||||
* instance methods in <i>mod</i> are returned, otherwise the methods
|
||||
* in <i>mod</i> and <i>mod</i>'s superclasses are returned.
|
||||
*
|
||||
*
|
||||
* module A
|
||||
* def method1() end
|
||||
* end
|
||||
|
@ -675,7 +675,7 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, lo
|
|||
* class C < B
|
||||
* def method3() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* A.instance_methods #=> [:method1]
|
||||
* B.instance_methods(false) #=> [:method2]
|
||||
* C.instance_methods(false) #=> [:method3]
|
||||
|
@ -691,7 +691,7 @@ rb_class_instance_methods(int argc, VALUE *argv, VALUE mod)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.protected_instance_methods(include_super=true) => array
|
||||
*
|
||||
*
|
||||
* Returns a list of the protected instance methods defined in
|
||||
* <i>mod</i>. If the optional parameter is not <code>false</code>, the
|
||||
* methods of any ancestors are included.
|
||||
|
@ -706,11 +706,11 @@ rb_class_protected_instance_methods(int argc, VALUE *argv, VALUE mod)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.private_instance_methods(include_super=true) => array
|
||||
*
|
||||
*
|
||||
* Returns a list of the private instance methods defined in
|
||||
* <i>mod</i>. If the optional parameter is not <code>false</code>, the
|
||||
* methods of any ancestors are included.
|
||||
*
|
||||
*
|
||||
* module Mod
|
||||
* def method1() end
|
||||
* private :method1
|
||||
|
@ -729,7 +729,7 @@ rb_class_private_instance_methods(int argc, VALUE *argv, VALUE mod)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.public_instance_methods(include_super=true) => array
|
||||
*
|
||||
*
|
||||
* Returns a list of the public instance methods defined in <i>mod</i>.
|
||||
* If the optional parameter is not <code>false</code>, the methods of
|
||||
* any ancestors are included.
|
||||
|
@ -744,30 +744,30 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.singleton_methods(all=true) => array
|
||||
*
|
||||
*
|
||||
* Returns an array of the names of singleton methods for <i>obj</i>.
|
||||
* If the optional <i>all</i> parameter is true, the list will include
|
||||
* methods in modules included in <i>obj</i>.
|
||||
*
|
||||
*
|
||||
* module Other
|
||||
* def three() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* class Single
|
||||
* def Single.four() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* a = Single.new
|
||||
*
|
||||
*
|
||||
* def a.one()
|
||||
* end
|
||||
*
|
||||
*
|
||||
* class << a
|
||||
* include Other
|
||||
* def two()
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* Single.singleton_methods #=> [:four]
|
||||
* a.singleton_methods(false) #=> [:two, :one]
|
||||
* a.singleton_methods #=> [:two, :one, :three]
|
||||
|
@ -932,7 +932,7 @@ rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
|
|||
postargc = *q - '0';
|
||||
nonpostargc = argc - postargc;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
postargc = 0;
|
||||
nonpostargc = argc;
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
|
|||
if (nonpostargc < 0)
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
|
||||
argc, postargc);
|
||||
goto rest_arg;
|
||||
goto rest_arg;
|
||||
}
|
||||
else if (ISDIGIT(*p)) {
|
||||
/* leading mandatory arguments */
|
||||
|
|
24
compar.c
24
compar.c
|
@ -50,7 +50,7 @@ cmp_failed(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj == other => true or false
|
||||
*
|
||||
*
|
||||
* Compares two objects based on the receiver's <code><=></code>
|
||||
* method, returning true if it returns 0. Also returns true if
|
||||
* _obj_ and _other_ are the same object.
|
||||
|
@ -70,7 +70,7 @@ cmp_equal(VALUE x, VALUE y)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj > other => true or false
|
||||
*
|
||||
*
|
||||
* Compares two objects based on the receiver's <code><=></code>
|
||||
* method, returning true if it returns 1.
|
||||
*/
|
||||
|
@ -87,7 +87,7 @@ cmp_gt(VALUE x, VALUE y)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj >= other => true or false
|
||||
*
|
||||
*
|
||||
* Compares two objects based on the receiver's <code><=></code>
|
||||
* method, returning true if it returns 0 or 1.
|
||||
*/
|
||||
|
@ -104,7 +104,7 @@ cmp_ge(VALUE x, VALUE y)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj < other => true or false
|
||||
*
|
||||
*
|
||||
* Compares two objects based on the receiver's <code><=></code>
|
||||
* method, returning true if it returns -1.
|
||||
*/
|
||||
|
@ -121,7 +121,7 @@ cmp_lt(VALUE x, VALUE y)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj <= other => true or false
|
||||
*
|
||||
*
|
||||
* Compares two objects based on the receiver's <code><=></code>
|
||||
* method, returning true if it returns -1 or 0.
|
||||
*/
|
||||
|
@ -138,16 +138,16 @@ cmp_le(VALUE x, VALUE y)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.between?(min, max) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>false</code> if <i>obj</i> <code><=></code>
|
||||
* <i>min</i> is less than zero or if <i>anObject</i> <code><=></code>
|
||||
* <i>max</i> is greater than zero, <code>true</code> otherwise.
|
||||
*
|
||||
*
|
||||
* 3.between?(1, 5) #=> true
|
||||
* 6.between?(1, 5) #=> false
|
||||
* 'cat'.between?('ant', 'dog') #=> true
|
||||
* 'gnu'.between?('ant', 'dog') #=> false
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -167,7 +167,7 @@ cmp_between(VALUE x, VALUE min, VALUE max)
|
|||
* <code><=></code> to implement the conventional comparison operators
|
||||
* (<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>,
|
||||
* and <code>></code>) and the method <code>between?</code>.
|
||||
*
|
||||
*
|
||||
* class SizeMatters
|
||||
* include Comparable
|
||||
* attr :str
|
||||
|
@ -181,18 +181,18 @@ cmp_between(VALUE x, VALUE min, VALUE max)
|
|||
* @str
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* s1 = SizeMatters.new("Z")
|
||||
* s2 = SizeMatters.new("YY")
|
||||
* s3 = SizeMatters.new("XXX")
|
||||
* s4 = SizeMatters.new("WWWW")
|
||||
* s5 = SizeMatters.new("VVVVV")
|
||||
*
|
||||
*
|
||||
* s1 < s2 #=> true
|
||||
* s4.between?(s1, s3) #=> false
|
||||
* s4.between?(s3, s5) #=> true
|
||||
* [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV]
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
|
|
|
@ -3962,7 +3962,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
VALUE label;
|
||||
VALUE label_sym;
|
||||
|
||||
|
||||
CONST_ID(goto_id, "__goto__");
|
||||
CONST_ID(label_id, "__label__");
|
||||
|
||||
|
|
82
cont.c
82
cont.c
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************
|
||||
|
||||
cont.c -
|
||||
cont.c -
|
||||
|
||||
$Author$
|
||||
created at: Thu May 23 09:03:43 2007
|
||||
|
@ -461,24 +461,24 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
|
|||
* Continuations are somewhat analogous to a structured version of C's
|
||||
* <code>setjmp/longjmp</code> (although they contain more state, so
|
||||
* you might consider them closer to threads).
|
||||
*
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
*
|
||||
* arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
|
||||
* callcc{|$cc|}
|
||||
* puts(message = arr.shift)
|
||||
* $cc.call unless message =~ /Max/
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Freddie
|
||||
* Herbie
|
||||
* Ron
|
||||
* Max
|
||||
*
|
||||
*
|
||||
* This (somewhat contrived) example allows the inner loop to abandon
|
||||
* processing early:
|
||||
*
|
||||
*
|
||||
* callcc {|cont|
|
||||
* for i in 0..4
|
||||
* print "\n#{i}: "
|
||||
|
@ -489,9 +489,9 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
|
|||
* end
|
||||
* }
|
||||
* print "\n"
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* 0: 0 1 2 3 4
|
||||
* 1: 5 6 7 8 9
|
||||
* 2: 10 11 12 13 14
|
||||
|
@ -501,7 +501,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
|
|||
/*
|
||||
* call-seq:
|
||||
* callcc {|cont| block } => obj
|
||||
*
|
||||
*
|
||||
* Generates a <code>Continuation</code> object, which it passes to the
|
||||
* associated block. Performing a <em>cont</em><code>.call</code> will
|
||||
* cause the <code>callcc</code> to return (as will falling through the
|
||||
|
@ -543,13 +543,13 @@ make_passing_arg(int argc, VALUE *argv)
|
|||
* call-seq:
|
||||
* cont.call(args, ...)
|
||||
* cont[args, ...]
|
||||
*
|
||||
*
|
||||
* Invokes the continuation. The program continues from the end of the
|
||||
* <code>callcc</code> block. If no arguments are given, the original
|
||||
* <code>callcc</code> returns <code>nil</code>. If one argument is
|
||||
* given, <code>callcc</code> returns it. Otherwise, an array
|
||||
* containing <i>args</i> is returned.
|
||||
*
|
||||
*
|
||||
* callcc {|cont| cont.call } #=> nil
|
||||
* callcc {|cont| cont.call 1 } #=> 1
|
||||
* callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3]
|
||||
|
@ -592,26 +592,26 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
|||
* Document-class: Fiber
|
||||
*
|
||||
* Fibers are primitives for implementing light weight cooperative
|
||||
* concurrency in Ruby. Basically they are a means of creating code blocks
|
||||
* that can be paused and resumed, much like threads. The main difference
|
||||
* is that they are never preempted and that the scheduling must be done by
|
||||
* the programmer and not the VM.
|
||||
* concurrency in Ruby. Basically they are a means of creating code blocks
|
||||
* that can be paused and resumed, much like threads. The main difference
|
||||
* is that they are never preempted and that the scheduling must be done by
|
||||
* the programmer and not the VM.
|
||||
*
|
||||
* As opposed to other stackless light weight concurrency models, each fiber
|
||||
* comes with a small 4KB stack. This enables the fiber to be paused from deeply
|
||||
* nested function calls within the fiber block.
|
||||
*
|
||||
* When a fiber is created it will not run automatically. Rather it must be
|
||||
* be explicitly asked to run using the <code>Fiber#resume</code> method.
|
||||
* The code running inside the fiber can give up control by calling
|
||||
* <code>Fiber.yield</code> in which case it yields control back to caller
|
||||
* When a fiber is created it will not run automatically. Rather it must be
|
||||
* be explicitly asked to run using the <code>Fiber#resume</code> method.
|
||||
* The code running inside the fiber can give up control by calling
|
||||
* <code>Fiber.yield</code> in which case it yields control back to caller
|
||||
* (the caller of the <code>Fiber#resume</code>).
|
||||
*
|
||||
* Upon yielding or termination the Fiber returns the value of the last
|
||||
*
|
||||
* Upon yielding or termination the Fiber returns the value of the last
|
||||
* executed expression
|
||||
*
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
*
|
||||
* fiber = Fiber.new do
|
||||
* Fiber.yield 1
|
||||
* 2
|
||||
|
@ -620,20 +620,20 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
|||
* puts fiber.resume
|
||||
* puts fiber.resume
|
||||
* puts fiber.resume
|
||||
*
|
||||
*
|
||||
* <em>produces</em>
|
||||
*
|
||||
*
|
||||
* 1
|
||||
* 2
|
||||
* FiberError: dead fiber called
|
||||
*
|
||||
*
|
||||
* The <code>Fiber#resume</code> method accepts an arbitary number of
|
||||
* parameters, if it is the first call to <code>resume</code> then they
|
||||
* will be passed as block arguments. Otherwise they will be the return
|
||||
* value of the call to <code>Fiber.yield</code>
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
*
|
||||
* fiber = Fiber.new do |first|
|
||||
* second = Fiber.yield first + 2
|
||||
* end
|
||||
|
@ -643,7 +643,7 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
|||
* puts fiber.resume 18
|
||||
*
|
||||
* <em>produces</em>
|
||||
*
|
||||
*
|
||||
* 12
|
||||
* 14
|
||||
* FiberError: dead fiber called
|
||||
|
@ -923,7 +923,7 @@ rb_fiber_yield(int argc, VALUE *argv)
|
|||
/*
|
||||
* call-seq:
|
||||
* fiber.alive? -> true or false
|
||||
*
|
||||
*
|
||||
* Returns true if the fiber can still be resumed (or transferred to).
|
||||
* After finishing execution of the fiber block this method will always
|
||||
* return false.
|
||||
|
@ -939,13 +939,13 @@ rb_fiber_alive_p(VALUE fibval)
|
|||
/*
|
||||
* call-seq:
|
||||
* fiber.resume(args, ...) -> obj
|
||||
*
|
||||
*
|
||||
* Resumes the fiber from the point at which the last <code>Fiber.yield</code>
|
||||
* was called, or starts running it if it is the first call to
|
||||
* was called, or starts running it if it is the first call to
|
||||
* <code>resume</code>. Arguments passed to resume will be the value of
|
||||
* the <code>Fiber.yield</code> expression or will be passed as block
|
||||
* the <code>Fiber.yield</code> expression or will be passed as block
|
||||
* parameters to the fiber's block if this is the first <code>resume</code>.
|
||||
*
|
||||
*
|
||||
* Alternatively, when resume is called it evaluates to the arguments passed
|
||||
* to the next <code>Fiber.yield</code> statement inside the fiber's block
|
||||
* or to the block value if it runs to completion without any
|
||||
|
@ -960,15 +960,15 @@ rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib)
|
|||
/*
|
||||
* call-seq:
|
||||
* fiber.transfer(args, ...) -> obj
|
||||
*
|
||||
*
|
||||
* Transfer control to another fiber, resuming it from where it last
|
||||
* stopped or starting it if it was not resumed before. The calling
|
||||
* stopped or starting it if it was not resumed before. The calling
|
||||
* fiber will be suspended much like in a call to <code>Fiber.yield</code>.
|
||||
*
|
||||
* The fiber which recieves the transfer call is treats it much like
|
||||
*
|
||||
* The fiber which recieves the transfer call is treats it much like
|
||||
* a resume call. Arguments passed to transfer are treated like those
|
||||
* passed to resume.
|
||||
*
|
||||
*
|
||||
* You cannot resume a fiber that transferred control to another one.
|
||||
* This will cause a double resume error. You need to transfer control
|
||||
* back to this fiber before it can yield and resume.
|
||||
|
@ -982,7 +982,7 @@ rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fib)
|
|||
/*
|
||||
* call-seq:
|
||||
* Fiber.yield(args, ...) -> obj
|
||||
*
|
||||
*
|
||||
* Yields control back to the context that resumed the fiber, passing
|
||||
* along any arguments that were passed to it. The fiber will resume
|
||||
* processing at this point when <code>resume</code> is called next.
|
||||
|
@ -998,7 +998,7 @@ rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* Fiber.current() -> fiber
|
||||
*
|
||||
*
|
||||
* Returns the current fiber. You need to <code>require 'fiber'</code>
|
||||
* before using this method. If you are not running in the context of
|
||||
* a fiber this method will return the root fiber.
|
||||
|
|
2
debug.c
2
debug.c
|
@ -30,7 +30,7 @@ static const union {
|
|||
RUBY_ENC_CODERANGE_UNKNOWN = ENC_CODERANGE_UNKNOWN,
|
||||
RUBY_ENC_CODERANGE_7BIT = ENC_CODERANGE_7BIT,
|
||||
RUBY_ENC_CODERANGE_VALID = ENC_CODERANGE_VALID,
|
||||
RUBY_ENC_CODERANGE_BROKEN = ENC_CODERANGE_BROKEN,
|
||||
RUBY_ENC_CODERANGE_BROKEN = ENC_CODERANGE_BROKEN,
|
||||
RUBY_FL_MARK = FL_MARK,
|
||||
RUBY_FL_RESERVED = FL_RESERVED,
|
||||
RUBY_FL_FINALIZE = FL_FINALIZE,
|
||||
|
|
20
dln.c
20
dln.c
|
@ -766,7 +766,7 @@ load_1(int fd, long disp, const char *need_init)
|
|||
}
|
||||
} /* end.. look it up */
|
||||
else { /* is static */
|
||||
switch (R_SYMBOL(rel)) {
|
||||
switch (R_SYMBOL(rel)) {
|
||||
case N_TEXT:
|
||||
case N_DATA:
|
||||
datum = block;
|
||||
|
@ -1158,7 +1158,7 @@ aix_loaderror(const char *pathname)
|
|||
char *message[8], errbuf[1024];
|
||||
int i,j;
|
||||
|
||||
struct errtab {
|
||||
struct errtab {
|
||||
int errnum;
|
||||
char *errstr;
|
||||
} load_errtab[] = {
|
||||
|
@ -1181,7 +1181,7 @@ aix_loaderror(const char *pathname)
|
|||
|
||||
snprintf(errbuf, 1024, "load failed - %s ", pathname);
|
||||
|
||||
if (!loadquery(1, &message[0], sizeof(message)))
|
||||
if (!loadquery(1, &message[0], sizeof(message)))
|
||||
ERRBUF_APPEND(strerror(errno));
|
||||
for(i = 0; message[i] && *message[i]; i++) {
|
||||
int nerr = atoi(message[i]);
|
||||
|
@ -1189,7 +1189,7 @@ aix_loaderror(const char *pathname)
|
|||
if (nerr == load_errtab[i].errnum && load_errtab[i].errstr)
|
||||
ERRBUF_APPEND(load_errtab[i].errstr);
|
||||
}
|
||||
while (isdigit(*message[i])) message[i]++;
|
||||
while (isdigit(*message[i])) message[i]++;
|
||||
ERRBUF_APPEND(message[i]);
|
||||
ERRBUF_APPEND("\n");
|
||||
}
|
||||
|
@ -1339,7 +1339,7 @@ dln_load(const char *file)
|
|||
#define DLN_DEFINED
|
||||
/*----------------------------------------------------
|
||||
By SHIROYAMA Takayuki Psi@fortune.nest.or.jp
|
||||
|
||||
|
||||
Special Thanks...
|
||||
Yu tomoak-i@is.aist-nara.ac.jp,
|
||||
Mi hisho@tasihara.nest.or.jp,
|
||||
|
@ -1354,9 +1354,9 @@ dln_load(const char *file)
|
|||
char *object_files[2] = {NULL, NULL};
|
||||
|
||||
void (*init_fct)();
|
||||
|
||||
|
||||
object_files[0] = (char*)file;
|
||||
|
||||
|
||||
s = NXOpenFile(2,NX_WRITEONLY);
|
||||
|
||||
/* Load object file, if return value ==0 , load failed*/
|
||||
|
@ -1403,7 +1403,7 @@ dln_load(const char *file)
|
|||
/* lookup the initial function */
|
||||
if(!NSIsSymbolNameDefined(buf)) {
|
||||
rb_loaderror("Failed to lookup Init function %.200s",file);
|
||||
}
|
||||
}
|
||||
init_fct = NSAddressOfSymbol(NSLookupAndBindSymbol(buf));
|
||||
(*init_fct)();
|
||||
|
||||
|
@ -1425,7 +1425,7 @@ dln_load(const char *file)
|
|||
rb_loaderror("Failed to load add_on %.200s error_code=%x",
|
||||
file, img_id);
|
||||
}
|
||||
|
||||
|
||||
/* find symbol for module initialize function. */
|
||||
/* The Be Book KernelKit Images section described to use
|
||||
B_SYMBOL_TYPE_TEXT for symbol of function, not
|
||||
|
@ -1608,7 +1608,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, int size,
|
|||
|
||||
if (*dp == '~' && (l == 1 ||
|
||||
#if defined(DOSISH)
|
||||
dp[1] == '\\' ||
|
||||
dp[1] == '\\' ||
|
||||
#endif
|
||||
dp[1] == '/')) {
|
||||
char *home;
|
||||
|
|
|
@ -925,7 +925,7 @@ enc_find(VALUE klass, VALUE enc)
|
|||
* Encoding.compatible?(str1, str2) => enc or nil
|
||||
*
|
||||
* Checks the compatibility of two strings.
|
||||
* If they are compatible, means concatenatable,
|
||||
* If they are compatible, means concatenatable,
|
||||
* returns an encoding which the concatinated string will be.
|
||||
* If they are not compatible, nil is returned.
|
||||
*
|
||||
|
|
6
enum.c
6
enum.c
|
@ -821,7 +821,7 @@ name##_iter_i(VALUE i, VALUE *memo, int argc, VALUE *argv) \
|
|||
{ \
|
||||
return enum_##name##_func(enum_yield(argc, argv), memo); \
|
||||
}
|
||||
|
||||
|
||||
static VALUE
|
||||
enum_all_func(VALUE result, VALUE *memo)
|
||||
{
|
||||
|
@ -1428,8 +1428,8 @@ enum_each_with_index(int argc, VALUE *argv, VALUE obj)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* enum.reverse_each {|item| block }
|
||||
*
|
||||
* enum.reverse_each {|item| block }
|
||||
*
|
||||
* Traverses <i>enum</i> in reverse order.
|
||||
*/
|
||||
|
||||
|
|
38
error.c
38
error.c
|
@ -369,7 +369,7 @@ rb_exc_new3(VALUE etype, VALUE str)
|
|||
* call-seq:
|
||||
* Exception.new(msg = nil) => exception
|
||||
*
|
||||
* Construct a new Exception object, optionally passing in
|
||||
* Construct a new Exception object, optionally passing in
|
||||
* a message.
|
||||
*/
|
||||
|
||||
|
@ -390,12 +390,12 @@ exc_initialize(int argc, VALUE *argv, VALUE exc)
|
|||
*
|
||||
* call-seq:
|
||||
* exc.exception(string) -> an_exception or exc
|
||||
*
|
||||
*
|
||||
* With no argument, or if the argument is the same as the receiver,
|
||||
* return the receiver. Otherwise, create a new
|
||||
* exception object of the same class as the receiver, but with a
|
||||
* message equal to <code>string.to_str</code>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -476,27 +476,27 @@ exc_inspect(VALUE exc)
|
|||
/*
|
||||
* call-seq:
|
||||
* exception.backtrace => array
|
||||
*
|
||||
*
|
||||
* Returns any backtrace associated with the exception. The backtrace
|
||||
* is an array of strings, each containing either ``filename:lineNo: in
|
||||
* `method''' or ``filename:lineNo.''
|
||||
*
|
||||
*
|
||||
* def a
|
||||
* raise "boom"
|
||||
* end
|
||||
*
|
||||
*
|
||||
* def b
|
||||
* a()
|
||||
* end
|
||||
*
|
||||
*
|
||||
* begin
|
||||
* b()
|
||||
* rescue => detail
|
||||
* print detail.backtrace.join("\n")
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* prog.rb:2:in `a'
|
||||
* prog.rb:6:in `b'
|
||||
* prog.rb:10
|
||||
|
@ -536,11 +536,11 @@ rb_check_backtrace(VALUE bt)
|
|||
/*
|
||||
* call-seq:
|
||||
* exc.set_backtrace(array) => array
|
||||
*
|
||||
*
|
||||
* Sets the backtrace information associated with <i>exc</i>. The
|
||||
* argument must be an array of <code>String</code> objects in the
|
||||
* format described in <code>Exception#backtrace</code>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -552,9 +552,9 @@ exc_set_backtrace(VALUE exc, VALUE bt)
|
|||
/*
|
||||
* call-seq:
|
||||
* exc == obj => true or false
|
||||
*
|
||||
*
|
||||
* Equality---If <i>obj</i> is not an <code>Exception</code>, returns
|
||||
* <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
|
||||
* <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
|
||||
* <i>obj</i> share same class, messages, and backtrace.
|
||||
*/
|
||||
|
||||
|
@ -846,7 +846,7 @@ rb_invalid_str(const char *str, const char *type)
|
|||
rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING_PTR(s));
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Document-module: Errno
|
||||
*
|
||||
* Ruby exception objects are subclasses of <code>Exception</code>.
|
||||
|
@ -856,21 +856,21 @@ rb_invalid_str(const char *str, const char *type)
|
|||
* number generating its own subclass of <code>SystemCallError</code>.
|
||||
* As the subclass is created in module <code>Errno</code>, its name
|
||||
* will start <code>Errno::</code>.
|
||||
*
|
||||
*
|
||||
* The names of the <code>Errno::</code> classes depend on
|
||||
* the environment in which Ruby runs. On a typical Unix or Windows
|
||||
* platform, there are <code>Errno</code> classes such as
|
||||
* <code>Errno::EACCES</code>, <code>Errno::EAGAIN</code>,
|
||||
* <code>Errno::EINTR</code>, and so on.
|
||||
*
|
||||
*
|
||||
* The integer operating system error number corresponding to a
|
||||
* particular error is available as the class constant
|
||||
* <code>Errno::</code><em>error</em><code>::Errno</code>.
|
||||
*
|
||||
*
|
||||
* Errno::EACCES::Errno #=> 13
|
||||
* Errno::EAGAIN::Errno #=> 11
|
||||
* Errno::EINTR::Errno #=> 4
|
||||
*
|
||||
*
|
||||
* The full list of operating system errors on your particular platform
|
||||
* are available as the constants of <code>Errno</code>.
|
||||
*
|
||||
|
@ -1014,7 +1014,7 @@ syserr_eqq(VALUE self, VALUE exc)
|
|||
* statements in <code>begin/end</code> blocks. <code>Exception</code>
|
||||
* objects carry information about the exception---its type (the
|
||||
* exception's class name), an optional descriptive string, and
|
||||
* optional traceback information. Programs may subclass
|
||||
* optional traceback information. Programs may subclass
|
||||
* <code>Exception</code> to add additional information.
|
||||
*/
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ error_print(void)
|
|||
long len = RARRAY_LEN(errat);
|
||||
VALUE *ptr = RARRAY_PTR(errat);
|
||||
int skip = eclass == rb_eSysStackError;
|
||||
|
||||
|
||||
#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
|
||||
#define TRACE_HEAD 8
|
||||
#define TRACE_TAIL 5
|
||||
|
|
16
gc.c
16
gc.c
|
@ -118,7 +118,7 @@ getrusage_time(void)
|
|||
ULARGE_INTEGER ui;
|
||||
LONG_LONG q;
|
||||
double t;
|
||||
|
||||
|
||||
if (GetProcessTimes(GetCurrentProcess(),
|
||||
&creation_time, &exit_time, &kernel_time, &user_time) == 0)
|
||||
{
|
||||
|
@ -863,7 +863,7 @@ assign_heap_slot(rb_objspace_t *objspace)
|
|||
RVALUE *p, *pend, *membase;
|
||||
size_t hi, lo, mid;
|
||||
int objs;
|
||||
|
||||
|
||||
objs = HEAP_OBJ_LIMIT;
|
||||
p = (RVALUE*)malloc(HEAP_SIZE);
|
||||
|
||||
|
@ -962,7 +962,7 @@ static VALUE
|
|||
rb_newobj_from_heap(rb_objspace_t *objspace)
|
||||
{
|
||||
VALUE obj;
|
||||
|
||||
|
||||
if ((ruby_gc_stress && !ruby_disable_gc_stress) || !freelist) {
|
||||
if (!heaps_increment(objspace) && !garbage_collect(objspace)) {
|
||||
during_gc = 0;
|
||||
|
@ -1010,7 +1010,7 @@ rb_during_gc(void)
|
|||
rb_objspace_t *objspace = &rb_objspace;
|
||||
return during_gc;
|
||||
}
|
||||
|
||||
|
||||
VALUE
|
||||
rb_newobj(void)
|
||||
{
|
||||
|
@ -2761,7 +2761,7 @@ gc_profile_record_get(void)
|
|||
VALUE gc_profile = rb_ary_new();
|
||||
size_t i;
|
||||
rb_objspace_t *objspace = (&rb_objspace);
|
||||
|
||||
|
||||
if (!objspace->profile.run) {
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -2794,7 +2794,7 @@ gc_profile_record_get(void)
|
|||
* GC::Profiler.result -> string
|
||||
*
|
||||
* Report profile data to string.
|
||||
*
|
||||
*
|
||||
* It returns a string as:
|
||||
* GC 1 invokes.
|
||||
* Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms)
|
||||
|
@ -2808,7 +2808,7 @@ gc_profile_result(void)
|
|||
VALUE record;
|
||||
VALUE result;
|
||||
int i;
|
||||
|
||||
|
||||
record = gc_profile_record_get();
|
||||
if (objspace->profile.run && objspace->profile.count) {
|
||||
result = rb_sprintf("GC %d invokes.\n", NUM2INT(gc_count(0)));
|
||||
|
@ -2850,7 +2850,7 @@ gc_profile_result(void)
|
|||
* GC::Profiler.report
|
||||
*
|
||||
* GC::Profiler.result display
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
|
2
goruby.c
2
goruby.c
|
@ -1,4 +1,4 @@
|
|||
void Init_golf(void);
|
||||
void Init_golf(void);
|
||||
#define ruby_run_node goruby_run_node
|
||||
#include "main.c"
|
||||
#undef ruby_run_node
|
||||
|
|
2
id.c
2
id.c
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************
|
||||
|
||||
id.c -
|
||||
id.c -
|
||||
|
||||
$Author$
|
||||
created at: Thu Jul 12 04:37:51 2007
|
||||
|
|
50
io.c
50
io.c
|
@ -2718,7 +2718,7 @@ rb_io_lines(int argc, VALUE *argv, VALUE io)
|
|||
* Returns an enumerator that gives each byte (0..255) in <em>ios</em>.
|
||||
* The stream must be opened for reading or an <code>IOError</code>
|
||||
* will be raised.
|
||||
*
|
||||
*
|
||||
* f = File.new("testfile")
|
||||
* f.bytes.to_a #=> [104, 101, 108, 108, 111]
|
||||
* f.rewind
|
||||
|
@ -2734,11 +2734,11 @@ rb_io_bytes(VALUE io)
|
|||
/*
|
||||
* call-seq:
|
||||
* ios.chars => anEnumerator
|
||||
*
|
||||
*
|
||||
* Returns an enumerator that gives each character in <em>ios</em>.
|
||||
* The stream must be opened for reading or an <code>IOError</code>
|
||||
* will be raised.
|
||||
*
|
||||
*
|
||||
* f = File.new("testfile")
|
||||
* f.chars.to_a #=> ["h", "e", "l", "l", "o"]
|
||||
* f.rewind
|
||||
|
@ -4950,7 +4950,7 @@ rb_scan_open_args(int argc, VALUE *argv,
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, convconfig_p);
|
||||
|
||||
perm = NIL_P(vperm) ? 0666 : NUM2UINT(vperm);
|
||||
|
@ -5909,7 +5909,7 @@ rb_io_stdio_file(rb_io_t *fptr)
|
|||
* <code>IO</code> object or integer file descriptor and mode
|
||||
* string. See also <code>IO#fileno</code> and
|
||||
* <code>IO.for_fd</code>.
|
||||
*
|
||||
*
|
||||
* === Parameters
|
||||
* fd:: numeric file descriptor
|
||||
* mode:: file mode. a string or an integer
|
||||
|
@ -5919,12 +5919,12 @@ rb_io_stdio_file(rb_io_t *fptr)
|
|||
* When <code>mode</code> is an integer it must be combination of
|
||||
* the modes defined in <code>File::Constants</code>.
|
||||
*
|
||||
* When <code>mode</code> is a string it must be in one of the
|
||||
* When <code>mode</code> is a string it must be in one of the
|
||||
* following forms:
|
||||
* - "fmode",
|
||||
* - "fmode:extern",
|
||||
* - "fmode:extern:intern".
|
||||
* <code>extern</code> is the external encoding name for the IO.
|
||||
* <code>extern</code> is the external encoding name for the IO.
|
||||
* <code>intern</code> is the internal encoding.
|
||||
* <code>fmode</code> must be combination of the directives. See
|
||||
* the description of class +IO+ for a description of the directives.
|
||||
|
@ -5933,20 +5933,20 @@ rb_io_stdio_file(rb_io_t *fptr)
|
|||
* <code>opt</code> can have the following keys
|
||||
* :mode ::
|
||||
* same as <code>mode</code> parameter
|
||||
* :external_encoding ::
|
||||
* external encoding for the IO. "-" is a
|
||||
* :external_encoding ::
|
||||
* external encoding for the IO. "-" is a
|
||||
* synonym for the default external encoding.
|
||||
* :internal_encoding ::
|
||||
* internal encoding for the IO.
|
||||
* internal encoding for the IO.
|
||||
* "-" is a synonym for the default internal encoding.
|
||||
* If the value is nil no conversion occurs.
|
||||
* :encoding ::
|
||||
* If the value is nil no conversion occurs.
|
||||
* :encoding ::
|
||||
* specifies external and internal encodings as "extern:intern".
|
||||
* :textmode ::
|
||||
* If the value is truth value, same as "b" in argument <code>mode</code>.
|
||||
* :binmode ::
|
||||
* If the value is truth value, same as "t" in argument <code>mode</code>.
|
||||
*
|
||||
*
|
||||
* Also <code>opt</code> can have same keys in <code>String#encode</code> for
|
||||
* controlling conversion between the external encoding and the internal encoding.
|
||||
*
|
||||
|
@ -5968,7 +5968,7 @@ rb_io_stdio_file(rb_io_t *fptr)
|
|||
* io = IO.new(2, mode: 'w', cr_newline: true, external_encoding: Encoding::UTF_16LE)
|
||||
* io.puts "Hello, World!"
|
||||
*
|
||||
* both of aboves print "Hello, World!" in UTF-16LE to standard error output with
|
||||
* both of aboves print "Hello, World!" in UTF-16LE to standard error output with
|
||||
* converting EOL generated by <code>puts</code> to CR.
|
||||
*/
|
||||
|
||||
|
@ -6021,16 +6021,16 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
|
|||
*
|
||||
* Opens the file named by _filename_ according to
|
||||
* _mode_ (default is ``r'') and returns a new
|
||||
* <code>File</code> object.
|
||||
*
|
||||
* === Parameters
|
||||
* See the description of class +IO+ for a description of _mode_.
|
||||
* The file mode may optionally be specified as a +Fixnum+
|
||||
* by _or_-ing together the flags (O_RDONLY etc,
|
||||
* again described under +IO+).
|
||||
* <code>File</code> object.
|
||||
*
|
||||
* Optional permission bits may be given in _perm_.
|
||||
* These mode and permission bits are platform dependent;
|
||||
* === Parameters
|
||||
* See the description of class +IO+ for a description of _mode_.
|
||||
* The file mode may optionally be specified as a +Fixnum+
|
||||
* by _or_-ing together the flags (O_RDONLY etc,
|
||||
* again described under +IO+).
|
||||
*
|
||||
* Optional permission bits may be given in _perm_.
|
||||
* These mode and permission bits are platform dependent;
|
||||
* on Unix systems, see <code>open(2)</code> for details.
|
||||
*
|
||||
* Optional _opt_ parameter is same as in <code.IO.open</code>.
|
||||
|
@ -6285,9 +6285,9 @@ argf_next_argv(VALUE argf)
|
|||
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
|
||||
#ifdef HAVE_FCHOWN
|
||||
(void)fchown(fw, st.st_uid, st.st_gid);
|
||||
#else
|
||||
#else
|
||||
(void)chown(fn, st.st_uid, st.st_gid);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
rb_stdout = prep_io(fw, FMODE_WRITABLE, rb_cFile, fn);
|
||||
|
|
2
iseq.c
2
iseq.c
|
@ -1247,7 +1247,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
|
|||
rb_hash_aset(misc, ID2SYM(rb_intern("local_size")), INT2FIX(iseq->local_size));
|
||||
rb_hash_aset(misc, ID2SYM(rb_intern("stack_max")), INT2FIX(iseq->stack_max));
|
||||
|
||||
/*
|
||||
/*
|
||||
* [:magic, :major_version, :minor_version, :format_type, :misc,
|
||||
* :name, :filename, :type, :locals, :args,
|
||||
* :catch_table, :bytecode]
|
||||
|
|
14
load.c
14
load.c
|
@ -341,7 +341,7 @@ rb_load_protect(VALUE fname, int wrap, int *state)
|
|||
/*
|
||||
* call-seq:
|
||||
* load(filename, wrap=false) => true
|
||||
*
|
||||
*
|
||||
* Loads and executes the Ruby
|
||||
* program in the file _filename_. If the filename does not
|
||||
* resolve to an absolute path, the file is searched for in the library
|
||||
|
@ -406,7 +406,7 @@ load_unlock(const char *ftptr, int done)
|
|||
/*
|
||||
* call-seq:
|
||||
* require(string) => true or false
|
||||
*
|
||||
*
|
||||
* Ruby tries to load the library named _string_, returning
|
||||
* +true+ if successful. If the filename does not resolve to
|
||||
* an absolute path, it will be searched for in the directories listed
|
||||
|
@ -420,7 +420,7 @@ load_unlock(const char *ftptr, int done)
|
|||
* appears in <code>$"</code>. However, the file name is not converted
|
||||
* to an absolute path, so that ``<code>require 'a';require
|
||||
* './a'</code>'' will load <code>a.rb</code> twice.
|
||||
*
|
||||
*
|
||||
* require "my-library.rb"
|
||||
* require "db-driver"
|
||||
*/
|
||||
|
@ -638,11 +638,11 @@ ruby_init_ext(const char *name, void (*init)(void))
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.autoload(name, filename) => nil
|
||||
*
|
||||
*
|
||||
* Registers _filename_ to be loaded (using <code>Kernel::require</code>)
|
||||
* the first time that _module_ (which may be a <code>String</code> or
|
||||
* a symbol) is accessed in the namespace of _mod_.
|
||||
*
|
||||
*
|
||||
* module A
|
||||
* end
|
||||
* A.autoload(:B, "b")
|
||||
|
@ -672,11 +672,11 @@ rb_mod_autoload_p(VALUE mod, VALUE sym)
|
|||
/*
|
||||
* call-seq:
|
||||
* autoload(module, filename) => nil
|
||||
*
|
||||
*
|
||||
* Registers _filename_ to be loaded (using <code>Kernel::require</code>)
|
||||
* the first time that _module_ (which may be a <code>String</code> or
|
||||
* a symbol) is accessed.
|
||||
*
|
||||
*
|
||||
* autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
|
||||
*/
|
||||
|
||||
|
|
|
@ -1608,7 +1608,7 @@ load_ensure(struct load_arg *arg)
|
|||
* call-seq:
|
||||
* load( source [, proc] ) => obj
|
||||
* restore( source [, proc] ) => obj
|
||||
*
|
||||
*
|
||||
* Returns the result of converting the serialized data in source into a
|
||||
* Ruby object (possibly with associated subordinate objects). source
|
||||
* may be either an instance of IO or an object that responds to
|
||||
|
|
60
math.c
60
math.c
|
@ -64,10 +64,10 @@ infinity_check(VALUE arg, double res, const char *msg)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.atan2(y, x) => float
|
||||
*
|
||||
*
|
||||
* Computes the arc tangent given <i>y</i> and <i>x</i>. Returns
|
||||
* -PI..PI.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -81,7 +81,7 @@ math_atan2(VALUE obj, VALUE y, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.cos(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the cosine of <i>x</i> (expressed in radians). Returns
|
||||
* -1..1.
|
||||
*/
|
||||
|
@ -96,7 +96,7 @@ math_cos(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.sin(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the sine of <i>x</i> (expressed in radians). Returns
|
||||
* -1..1.
|
||||
*/
|
||||
|
@ -113,7 +113,7 @@ math_sin(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.tan(x) => float
|
||||
*
|
||||
*
|
||||
* Returns the tangent of <i>x</i> (expressed in radians).
|
||||
*/
|
||||
|
||||
|
@ -128,7 +128,7 @@ math_tan(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.acos(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the arc cosine of <i>x</i>. Returns 0..PI.
|
||||
*/
|
||||
|
||||
|
@ -148,7 +148,7 @@ math_acos(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.asin(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the arc sine of <i>x</i>. Returns -{PI/2} .. {PI/2}.
|
||||
*/
|
||||
|
||||
|
@ -168,7 +168,7 @@ math_asin(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.atan(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the arc tangent of <i>x</i>. Returns -{PI/2} .. {PI/2}.
|
||||
*/
|
||||
|
||||
|
@ -190,7 +190,7 @@ cosh(double x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.cosh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the hyperbolic cosine of <i>x</i> (expressed in radians).
|
||||
*/
|
||||
|
||||
|
@ -198,7 +198,7 @@ static VALUE
|
|||
math_cosh(VALUE obj, VALUE x)
|
||||
{
|
||||
Need_Float(x);
|
||||
|
||||
|
||||
return DBL2NUM(cosh(RFLOAT_VALUE(x)));
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ sinh(double x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.sinh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the hyperbolic sine of <i>x</i> (expressed in
|
||||
* radians).
|
||||
*/
|
||||
|
@ -236,7 +236,7 @@ tanh(double x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.tanh() => float
|
||||
*
|
||||
*
|
||||
* Computes the hyperbolic tangent of <i>x</i> (expressed in
|
||||
* radians).
|
||||
*/
|
||||
|
@ -251,7 +251,7 @@ math_tanh(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.acosh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the inverse hyperbolic cosine of <i>x</i>.
|
||||
*/
|
||||
|
||||
|
@ -271,7 +271,7 @@ math_acosh(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.asinh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the inverse hyperbolic sine of <i>x</i>.
|
||||
*/
|
||||
|
||||
|
@ -285,7 +285,7 @@ math_asinh(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.atanh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the inverse hyperbolic tangent of <i>x</i>.
|
||||
*/
|
||||
|
||||
|
@ -306,7 +306,7 @@ math_atanh(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.exp(x) => float
|
||||
*
|
||||
*
|
||||
* Returns e**x.
|
||||
*/
|
||||
|
||||
|
@ -330,7 +330,7 @@ math_exp(VALUE obj, VALUE x)
|
|||
* call-seq:
|
||||
* Math.log(numeric) => float
|
||||
* Math.log(num,base) => float
|
||||
*
|
||||
*
|
||||
* Returns the natural logarithm of <i>numeric</i>.
|
||||
* If additional second argument is given, it will be the base
|
||||
* of logarithm.
|
||||
|
@ -371,7 +371,7 @@ extern double log2(double);
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.log2(numeric) => float
|
||||
*
|
||||
*
|
||||
* Returns the base 2 logarithm of <i>numeric</i>.
|
||||
*/
|
||||
|
||||
|
@ -392,7 +392,7 @@ math_log2(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.log10(numeric) => float
|
||||
*
|
||||
*
|
||||
* Returns the base 10 logarithm of <i>numeric</i>.
|
||||
*/
|
||||
|
||||
|
@ -413,10 +413,10 @@ math_log10(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.sqrt(numeric) => float
|
||||
*
|
||||
*
|
||||
* Returns the non-negative square root of <i>numeric</i>.
|
||||
*
|
||||
* 0.upto(10) {|x|
|
||||
* 0.upto(10) {|x|
|
||||
* p [x, Math.sqrt(x), Math.sqrt(x)**2]
|
||||
* }
|
||||
* #=>
|
||||
|
@ -450,7 +450,7 @@ math_sqrt(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.cbrt(numeric) => float
|
||||
*
|
||||
*
|
||||
* Returns the cube root of <i>numeric</i>.
|
||||
*
|
||||
* -9.upto(9) {|x|
|
||||
|
@ -489,11 +489,11 @@ math_cbrt(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.frexp(numeric) => [ fraction, exponent ]
|
||||
*
|
||||
*
|
||||
* Returns a two-element array containing the normalized fraction (a
|
||||
* <code>Float</code>) and exponent (a <code>Fixnum</code>) of
|
||||
* <i>numeric</i>.
|
||||
*
|
||||
*
|
||||
* fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11]
|
||||
* fraction * 2**exponent #=> 1234.0
|
||||
*/
|
||||
|
@ -505,7 +505,7 @@ math_frexp(VALUE obj, VALUE x)
|
|||
int exp;
|
||||
|
||||
Need_Float(x);
|
||||
|
||||
|
||||
d = frexp(RFLOAT_VALUE(x), &exp);
|
||||
return rb_assoc_new(DBL2NUM(d), INT2NUM(exp));
|
||||
}
|
||||
|
@ -513,9 +513,9 @@ math_frexp(VALUE obj, VALUE x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.ldexp(flt, int) -> float
|
||||
*
|
||||
*
|
||||
* Returns the value of <i>flt</i>*(2**<i>int</i>).
|
||||
*
|
||||
*
|
||||
* fraction, exponent = Math.frexp(1234)
|
||||
* Math.ldexp(fraction, exponent) #=> 1234.0
|
||||
*/
|
||||
|
@ -530,10 +530,10 @@ math_ldexp(VALUE obj, VALUE x, VALUE n)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.hypot(x, y) => float
|
||||
*
|
||||
*
|
||||
* Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle
|
||||
* with sides <i>x</i> and <i>y</i>.
|
||||
*
|
||||
*
|
||||
* Math.hypot(3, 4) #=> 5.0
|
||||
*/
|
||||
|
||||
|
@ -689,7 +689,7 @@ exp1(sqrt)
|
|||
* trigonometric and transcendental functions. See class
|
||||
* <code>Float</code> for a list of constants that
|
||||
* define Ruby's floating point accuracy.
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
|
|
|
@ -2455,7 +2455,7 @@ fix_pow(VALUE x, VALUE y)
|
|||
if (a == -1) {
|
||||
if (b % 2 == 0)
|
||||
return INT2FIX(1);
|
||||
else
|
||||
else
|
||||
return INT2FIX(-1);
|
||||
}
|
||||
return int_pow(a, b);
|
||||
|
|
288
object.c
288
object.c
|
@ -36,7 +36,7 @@ static ID id_eq, id_eql, id_match, id_inspect, id_init_copy;
|
|||
/*
|
||||
* call-seq:
|
||||
* obj === other => true or false
|
||||
*
|
||||
*
|
||||
* Case Equality---For class <code>Object</code>, effectively the same
|
||||
* as calling <code>#==</code>, but typically overridden by descendents
|
||||
* to provide meaningful semantics in <code>case</code> statements.
|
||||
|
@ -64,7 +64,7 @@ rb_eql(VALUE obj1, VALUE obj2)
|
|||
* obj == other => true or false
|
||||
* obj.equal?(other) => true or false
|
||||
* obj.eql?(other) => true or false
|
||||
*
|
||||
*
|
||||
* Equality---At the <code>Object</code> level, <code>==</code> returns
|
||||
* <code>true</code> only if <i>obj</i> and <i>other</i> are the
|
||||
* same object. Typically, this method is overridden in descendent
|
||||
|
@ -83,7 +83,7 @@ rb_eql(VALUE obj1, VALUE obj2)
|
|||
* there are exceptions. <code>Numeric</code> types, for example,
|
||||
* perform type conversion across <code>==</code>, but not across
|
||||
* <code>eql?</code>, so:
|
||||
*
|
||||
*
|
||||
* 1 == 1.0 #=> true
|
||||
* 1.eql? 1.0 #=> false
|
||||
*/
|
||||
|
@ -144,13 +144,13 @@ rb_class_real(VALUE cl)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.class => class
|
||||
*
|
||||
*
|
||||
* Returns the class of <i>obj</i>, now preferred over
|
||||
* <code>Object#type</code>, as an object's type in Ruby is only
|
||||
* loosely tied to that object's class. This method must always be
|
||||
* called with an explicit receiver, as <code>class</code> is also a
|
||||
* reserved word in Ruby.
|
||||
*
|
||||
*
|
||||
* 1.class #=> Fixnum
|
||||
* self.class #=> Object
|
||||
*/
|
||||
|
@ -210,12 +210,12 @@ init_copy(VALUE dest, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.clone -> an_object
|
||||
*
|
||||
*
|
||||
* Produces a shallow copy of <i>obj</i>---the instance variables of
|
||||
* <i>obj</i> are copied, but not the objects they reference. Copies
|
||||
* the frozen and tainted state of <i>obj</i>. See also the discussion
|
||||
* under <code>Object#dup</code>.
|
||||
*
|
||||
*
|
||||
* class Klass
|
||||
* attr_accessor :str
|
||||
* end
|
||||
|
@ -251,7 +251,7 @@ rb_obj_clone(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.dup -> an_object
|
||||
*
|
||||
*
|
||||
* Produces a shallow copy of <i>obj</i>---the instance variables of
|
||||
* <i>obj</i> are copied, but not the objects they reference.
|
||||
* <code>dup</code> copies the tainted state of <i>obj</i>. See also
|
||||
|
@ -295,7 +295,7 @@ rb_obj_init_copy(VALUE obj, VALUE orig)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.to_s => string
|
||||
*
|
||||
*
|
||||
* Returns a string representing <i>obj</i>. The default
|
||||
* <code>to_s</code> prints the object's class and an encoding of the
|
||||
* object id. As a special case, the top-level object that is the
|
||||
|
@ -365,11 +365,11 @@ inspect_obj(VALUE obj, VALUE str, int recur)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.inspect => string
|
||||
*
|
||||
*
|
||||
* Returns a string containing a human-readable representation of
|
||||
* <i>obj</i>. If not overridden, uses the <code>to_s</code> method to
|
||||
* generate the string.
|
||||
*
|
||||
*
|
||||
* [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
|
||||
* Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
|
||||
*/
|
||||
|
@ -407,7 +407,7 @@ rb_obj_inspect(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.instance_of?(class) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>obj</i> is an instance of the given
|
||||
* class. See also <code>Object#kind_of?</code>.
|
||||
*/
|
||||
|
@ -433,11 +433,11 @@ rb_obj_is_instance_of(VALUE obj, VALUE c)
|
|||
* call-seq:
|
||||
* obj.is_a?(class) => true or false
|
||||
* obj.kind_of?(class) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>class</i> is the class of
|
||||
* <i>obj</i>, or if <i>class</i> is one of the superclasses of
|
||||
* <i>obj</i> or modules included in <i>obj</i>.
|
||||
*
|
||||
*
|
||||
* module M; end
|
||||
* class A
|
||||
* include M
|
||||
|
@ -482,7 +482,7 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.tap{|x|...} => obj
|
||||
*
|
||||
*
|
||||
* Yields <code>x</code> to the block, and then returns <code>x</code>.
|
||||
* The primary purpose of this method is to "tap into" a method chain,
|
||||
* in order to perform operations on intermediate results within the chain.
|
||||
|
@ -535,10 +535,10 @@ rb_obj_tap(VALUE obj)
|
|||
*
|
||||
* call-seq:
|
||||
* singleton_method_added(symbol)
|
||||
*
|
||||
*
|
||||
* Invoked as a callback whenever a singleton method is added to the
|
||||
* receiver.
|
||||
*
|
||||
*
|
||||
* module Chatty
|
||||
* def Chatty.singleton_method_added(id)
|
||||
* puts "Adding #{id.id2name}"
|
||||
|
@ -547,13 +547,13 @@ rb_obj_tap(VALUE obj)
|
|||
* def two() end
|
||||
* def Chatty.three() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Adding singleton_method_added
|
||||
* Adding one
|
||||
* Adding three
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -561,10 +561,10 @@ rb_obj_tap(VALUE obj)
|
|||
*
|
||||
* call-seq:
|
||||
* singleton_method_removed(symbol)
|
||||
*
|
||||
*
|
||||
* Invoked as a callback whenever a singleton method is removed from
|
||||
* the receiver.
|
||||
*
|
||||
*
|
||||
* module Chatty
|
||||
* def Chatty.singleton_method_removed(id)
|
||||
* puts "Removing #{id.id2name}"
|
||||
|
@ -577,9 +577,9 @@ rb_obj_tap(VALUE obj)
|
|||
* remove_method :one
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Removing three
|
||||
* Removing one
|
||||
*/
|
||||
|
@ -589,10 +589,10 @@ rb_obj_tap(VALUE obj)
|
|||
*
|
||||
* call-seq:
|
||||
* singleton_method_undefined(symbol)
|
||||
*
|
||||
*
|
||||
* Invoked as a callback whenever a singleton method is undefined in
|
||||
* the receiver.
|
||||
*
|
||||
*
|
||||
* module Chatty
|
||||
* def Chatty.singleton_method_undefined(id)
|
||||
* puts "Undefining #{id.id2name}"
|
||||
|
@ -602,9 +602,9 @@ rb_obj_tap(VALUE obj)
|
|||
* undef_method(:one)
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Undefining one
|
||||
*/
|
||||
|
||||
|
@ -644,7 +644,7 @@ rb_obj_dummy(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.tainted? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if the object is tainted.
|
||||
*/
|
||||
|
||||
|
@ -659,7 +659,7 @@ rb_obj_tainted(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.taint -> obj
|
||||
*
|
||||
*
|
||||
* Marks <i>obj</i> as tainted---if the <code>$SAFE</code> level is
|
||||
* set appropriately, many method calls which might alter the running
|
||||
* programs environment will refuse to accept tainted strings.
|
||||
|
@ -682,7 +682,7 @@ rb_obj_taint(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.untaint => obj
|
||||
*
|
||||
*
|
||||
* Removes the taint from <i>obj</i>.
|
||||
*/
|
||||
|
||||
|
@ -702,7 +702,7 @@ rb_obj_untaint(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.untrusted? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if the object is untrusted.
|
||||
*/
|
||||
|
||||
|
@ -717,7 +717,7 @@ rb_obj_untrusted(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.untrust -> obj
|
||||
*
|
||||
*
|
||||
* Marks <i>obj</i> as untrusted.
|
||||
*/
|
||||
|
||||
|
@ -738,7 +738,7 @@ rb_obj_untrust(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.trust => obj
|
||||
*
|
||||
*
|
||||
* Removes the untrusted mark from <i>obj</i>.
|
||||
*/
|
||||
|
||||
|
@ -766,18 +766,18 @@ static st_table *immediate_frozen_tbl = 0;
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.freeze => obj
|
||||
*
|
||||
*
|
||||
* Prevents further modifications to <i>obj</i>. A
|
||||
* <code>RuntimeError</code> will be raised if modification is attempted.
|
||||
* There is no way to unfreeze a frozen object. See also
|
||||
* <code>Object#frozen?</code>.
|
||||
*
|
||||
*
|
||||
* a = [ "a", "b", "c" ]
|
||||
* a.freeze
|
||||
* a << "z"
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* prog.rb:3:in `<<': can't modify frozen array (RuntimeError)
|
||||
* from prog.rb:3
|
||||
*/
|
||||
|
@ -803,9 +803,9 @@ rb_obj_freeze(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.frozen? => true or false
|
||||
*
|
||||
*
|
||||
* Returns the freeze status of <i>obj</i>.
|
||||
*
|
||||
*
|
||||
* a = [ "a", "b", "c" ]
|
||||
* a.freeze #=> ["a", "b", "c"]
|
||||
* a.frozen? #=> true
|
||||
|
@ -832,9 +832,9 @@ rb_obj_frozen_p(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* nil.to_i => 0
|
||||
*
|
||||
*
|
||||
* Always returns zero.
|
||||
*
|
||||
*
|
||||
* nil.to_i #=> 0
|
||||
*/
|
||||
|
||||
|
@ -848,9 +848,9 @@ nil_to_i(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* nil.to_f => 0.0
|
||||
*
|
||||
*
|
||||
* Always returns zero.
|
||||
*
|
||||
*
|
||||
* nil.to_f #=> 0.0
|
||||
*/
|
||||
|
||||
|
@ -863,7 +863,7 @@ nil_to_f(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* nil.to_s => ""
|
||||
*
|
||||
*
|
||||
* Always returns the empty string.
|
||||
*/
|
||||
|
||||
|
@ -878,9 +878,9 @@ nil_to_s(VALUE obj)
|
|||
*
|
||||
* call-seq:
|
||||
* nil.to_a => []
|
||||
*
|
||||
*
|
||||
* Always returns an empty array.
|
||||
*
|
||||
*
|
||||
* nil.to_a #=> []
|
||||
*/
|
||||
|
||||
|
@ -930,7 +930,7 @@ true_to_s(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* true & obj => true or false
|
||||
*
|
||||
*
|
||||
* And---Returns <code>false</code> if <i>obj</i> is
|
||||
* <code>nil</code> or <code>false</code>, <code>true</code> otherwise.
|
||||
*/
|
||||
|
@ -944,16 +944,16 @@ true_and(VALUE obj, VALUE obj2)
|
|||
/*
|
||||
* call-seq:
|
||||
* true | obj => true
|
||||
*
|
||||
*
|
||||
* Or---Returns <code>true</code>. As <i>anObject</i> is an argument to
|
||||
* a method call, it is always evaluated; there is no short-circuit
|
||||
* evaluation in this case.
|
||||
*
|
||||
*
|
||||
* true | puts("or")
|
||||
* true || puts("logical or")
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* or
|
||||
*/
|
||||
|
||||
|
@ -967,7 +967,7 @@ true_or(VALUE obj, VALUE obj2)
|
|||
/*
|
||||
* call-seq:
|
||||
* true ^ obj => !obj
|
||||
*
|
||||
*
|
||||
* Exclusive Or---Returns <code>true</code> if <i>obj</i> is
|
||||
* <code>nil</code> or <code>false</code>, <code>false</code>
|
||||
* otherwise.
|
||||
|
@ -987,7 +987,7 @@ true_xor(VALUE obj, VALUE obj2)
|
|||
* <code>FalseClass</code> and represents a logically false value in
|
||||
* boolean expressions. The class provides operators allowing
|
||||
* <code>false</code> to participate correctly in logical expressions.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1007,7 +1007,7 @@ false_to_s(VALUE obj)
|
|||
* call-seq:
|
||||
* false & obj => false
|
||||
* nil & obj => false
|
||||
*
|
||||
*
|
||||
* And---Returns <code>false</code>. <i>obj</i> is always
|
||||
* evaluated as it is the argument to a method call---there is no
|
||||
* short-circuit evaluation in this case.
|
||||
|
@ -1024,7 +1024,7 @@ false_and(VALUE obj, VALUE obj2)
|
|||
* call-seq:
|
||||
* false | obj => true or false
|
||||
* nil | obj => true or false
|
||||
*
|
||||
*
|
||||
* Or---Returns <code>false</code> if <i>obj</i> is
|
||||
* <code>nil</code> or <code>false</code>; <code>true</code> otherwise.
|
||||
*/
|
||||
|
@ -1041,11 +1041,11 @@ false_or(VALUE obj, VALUE obj2)
|
|||
* call-seq:
|
||||
* false ^ obj => true or false
|
||||
* nil ^ obj => true or false
|
||||
*
|
||||
*
|
||||
* Exclusive Or---If <i>obj</i> is <code>nil</code> or
|
||||
* <code>false</code>, returns <code>false</code>; otherwise, returns
|
||||
* <code>true</code>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -1086,7 +1086,7 @@ rb_false(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj =~ other => nil
|
||||
*
|
||||
*
|
||||
* Pattern Match---Overridden by descendents (notably
|
||||
* <code>Regexp</code> and <code>String</code>) to provide meaningful
|
||||
* pattern-match semantics.
|
||||
|
@ -1101,7 +1101,7 @@ rb_obj_match(VALUE obj1, VALUE obj2)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj !~ other => true or false
|
||||
*
|
||||
*
|
||||
* Returns true if two objects do not match (using the <i>=~</i>
|
||||
* method), otherwise false.
|
||||
*/
|
||||
|
@ -1124,11 +1124,11 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
|
|||
* included, module methods do not. Conversely, module methods may be
|
||||
* called without creating an encapsulating object, while instance
|
||||
* methods may not. (See <code>Module#module_function</code>)
|
||||
*
|
||||
*
|
||||
* In the descriptions that follow, the parameter <i>syml</i> refers
|
||||
* to a symbol, which is either a quoted string or a
|
||||
* <code>Symbol</code> (such as <code>:name</code>).
|
||||
*
|
||||
*
|
||||
* module Mod
|
||||
* include Math
|
||||
* CONST = 1
|
||||
|
@ -1139,7 +1139,7 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
|
|||
* Mod.class #=> Module
|
||||
* Mod.constants #=> [:CONST, :PI, :E]
|
||||
* Mod.instance_methods #=> [:meth]
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1177,7 +1177,7 @@ rb_mod_to_s(VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.freeze
|
||||
*
|
||||
*
|
||||
* Prevents further modifications to <i>mod</i>.
|
||||
*/
|
||||
|
||||
|
@ -1191,7 +1191,7 @@ rb_mod_freeze(VALUE mod)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod === obj => true or false
|
||||
*
|
||||
*
|
||||
* Case Equality---Returns <code>true</code> if <i>anObject</i> is an
|
||||
* instance of <i>mod</i> or one of <i>mod</i>'s descendents. Of
|
||||
* limited use for modules, but can be used in <code>case</code>
|
||||
|
@ -1209,9 +1209,9 @@ rb_mod_eqq(VALUE mod, VALUE arg)
|
|||
* mod <= other => true, false, or nil
|
||||
*
|
||||
* Returns true if <i>mod</i> is a subclass of <i>other</i> or
|
||||
* is the same as <i>other</i>. Returns
|
||||
* <code>nil</code> if there's no relationship between the two.
|
||||
* (Think of the relationship in terms of the class definition:
|
||||
* is the same as <i>other</i>. Returns
|
||||
* <code>nil</code> if there's no relationship between the two.
|
||||
* (Think of the relationship in terms of the class definition:
|
||||
* "class A<B" implies "A<B").
|
||||
*
|
||||
*/
|
||||
|
@ -1247,9 +1247,9 @@ rb_class_inherited_p(VALUE mod, VALUE arg)
|
|||
* call-seq:
|
||||
* mod < other => true, false, or nil
|
||||
*
|
||||
* Returns true if <i>mod</i> is a subclass of <i>other</i>. Returns
|
||||
* <code>nil</code> if there's no relationship between the two.
|
||||
* (Think of the relationship in terms of the class definition:
|
||||
* Returns true if <i>mod</i> is a subclass of <i>other</i>. Returns
|
||||
* <code>nil</code> if there's no relationship between the two.
|
||||
* (Think of the relationship in terms of the class definition:
|
||||
* "class A<B" implies "A<B").
|
||||
*
|
||||
*/
|
||||
|
@ -1267,9 +1267,9 @@ rb_mod_lt(VALUE mod, VALUE arg)
|
|||
* mod >= other => true, false, or nil
|
||||
*
|
||||
* Returns true if <i>mod</i> is an ancestor of <i>other</i>, or the
|
||||
* two modules are the same. Returns
|
||||
* <code>nil</code> if there's no relationship between the two.
|
||||
* (Think of the relationship in terms of the class definition:
|
||||
* two modules are the same. Returns
|
||||
* <code>nil</code> if there's no relationship between the two.
|
||||
* (Think of the relationship in terms of the class definition:
|
||||
* "class A<B" implies "B>A").
|
||||
*
|
||||
*/
|
||||
|
@ -1292,9 +1292,9 @@ rb_mod_ge(VALUE mod, VALUE arg)
|
|||
* call-seq:
|
||||
* mod > other => true, false, or nil
|
||||
*
|
||||
* Returns true if <i>mod</i> is an ancestor of <i>other</i>. Returns
|
||||
* <code>nil</code> if there's no relationship between the two.
|
||||
* (Think of the relationship in terms of the class definition:
|
||||
* Returns true if <i>mod</i> is an ancestor of <i>other</i>. Returns
|
||||
* <code>nil</code> if there's no relationship between the two.
|
||||
* (Think of the relationship in terms of the class definition:
|
||||
* "class A<B" implies "B>A").
|
||||
*
|
||||
*/
|
||||
|
@ -1309,7 +1309,7 @@ rb_mod_gt(VALUE mod, VALUE arg)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod <=> other_mod => -1, 0, +1, or nil
|
||||
*
|
||||
*
|
||||
* Comparison---Returns -1 if <i>mod</i> includes <i>other_mod</i>, 0 if
|
||||
* <i>mod</i> is the same as <i>other_mod</i>, and +1 if <i>mod</i> is
|
||||
* included by <i>other_mod</i> or if <i>mod</i> has no relationship with
|
||||
|
@ -1358,11 +1358,11 @@ rb_class_s_alloc(VALUE klass)
|
|||
* call-seq:
|
||||
* Module.new => mod
|
||||
* Module.new {|mod| block } => mod
|
||||
*
|
||||
*
|
||||
* Creates a new anonymous module. If a block is given, it is passed
|
||||
* the module object, and the block is evaluated in the context of this
|
||||
* module using <code>module_eval</code>.
|
||||
*
|
||||
*
|
||||
* Fred = Module.new do
|
||||
* def meth1
|
||||
* "hello"
|
||||
|
@ -1391,11 +1391,11 @@ rb_mod_initialize(VALUE module)
|
|||
/*
|
||||
* call-seq:
|
||||
* Class.new(super_class=Object) => a_class
|
||||
*
|
||||
*
|
||||
* Creates a new anonymous (unnamed) class with the given superclass
|
||||
* (or <code>Object</code> if no parameter is given). You can give a
|
||||
* class a name by assigning the class object to a constant.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -1424,23 +1424,23 @@ rb_class_initialize(int argc, VALUE *argv, VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* class.allocate() => obj
|
||||
*
|
||||
*
|
||||
* Allocates space for a new object of <i>class</i>'s class and does not
|
||||
* call initialize on the new instance. The returned object must be an
|
||||
* instance of <i>class</i>.
|
||||
*
|
||||
*
|
||||
* klass = Class.new do
|
||||
* def initialize(*args)
|
||||
* @initialized = true
|
||||
* end
|
||||
*
|
||||
*
|
||||
* def initialized?
|
||||
* @initialized || false
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* klass.allocate.initialized? #=> false
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
VALUE
|
||||
|
@ -1472,13 +1472,13 @@ rb_class_allocate_instance(VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* class.new(args, ...) => obj
|
||||
*
|
||||
*
|
||||
* Calls <code>allocate</code> to create a new object of
|
||||
* <i>class</i>'s class, then invokes that object's
|
||||
* <code>initialize</code> method, passing it <i>args</i>.
|
||||
* This is the method that ends up getting called whenever
|
||||
* an object is constructed using .new.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
VALUE
|
||||
|
@ -1495,9 +1495,9 @@ rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* class.superclass -> a_super_class or nil
|
||||
*
|
||||
*
|
||||
* Returns the superclass of <i>class</i>, or <code>nil</code>.
|
||||
*
|
||||
*
|
||||
* File.superclass #=> IO
|
||||
* IO.superclass #=> Object
|
||||
* Object.superclass #=> BasicObject
|
||||
|
@ -1508,7 +1508,7 @@ rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
|
|||
* returns nil when the given class hasn't a parent class:
|
||||
*
|
||||
* BasicObject.superclass #=> nil
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -1533,7 +1533,7 @@ rb_class_superclass(VALUE klass)
|
|||
* call-seq:
|
||||
* attr_reader(symbol, ...) => nil
|
||||
* attr(symbol, ...) => nil
|
||||
*
|
||||
*
|
||||
* Creates instance variables and corresponding methods that return the
|
||||
* value of each instance variable. Equivalent to calling
|
||||
* ``<code>attr</code><i>:name</i>'' on each name in turn.
|
||||
|
@ -1564,7 +1564,7 @@ rb_mod_attr(int argc, VALUE *argv, VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* attr_writer(symbol, ...) => nil
|
||||
*
|
||||
*
|
||||
* Creates an accessor method to allow assignment to the attribute
|
||||
* <i>aSymbol</i><code>.id2name</code>.
|
||||
*/
|
||||
|
@ -1583,12 +1583,12 @@ rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* attr_accessor(symbol, ...) => nil
|
||||
*
|
||||
*
|
||||
* Defines a named attribute for this module, where the name is
|
||||
* <i>symbol.</i><code>id2name</code>, creating an instance variable
|
||||
* (<code>@name</code>) and a corresponding access method to read it.
|
||||
* Also creates a method called <code>name=</code> to set the attribute.
|
||||
*
|
||||
*
|
||||
* module Mod
|
||||
* attr_accessor(:one, :two)
|
||||
* end
|
||||
|
@ -1609,9 +1609,9 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.const_get(sym, inherit=true) => obj
|
||||
*
|
||||
*
|
||||
* Returns the value of the named constant in <i>mod</i>.
|
||||
*
|
||||
*
|
||||
* Math.const_get(:PI) #=> 3.14159265358979
|
||||
*
|
||||
* If the constant is not defined or is defined by the ancestors and
|
||||
|
@ -1641,11 +1641,11 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.const_set(sym, obj) => obj
|
||||
*
|
||||
*
|
||||
* Sets the named constant to the given object, returning that object.
|
||||
* Creates a new constant if no constant with the given name previously
|
||||
* existed.
|
||||
*
|
||||
*
|
||||
* Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714
|
||||
* Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968
|
||||
*/
|
||||
|
@ -1665,10 +1665,10 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.const_defined?(sym, inherit=true) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if a constant with the given name is
|
||||
* defined by <i>mod</i>, or its ancestors if +inherit+ is not false.
|
||||
*
|
||||
*
|
||||
* Math.const_defined? "PI" #=> true
|
||||
* IO.const_defined? "SYNC" #=> true
|
||||
* IO.const_defined? "SYNC", false #=> false
|
||||
|
@ -1697,17 +1697,17 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.methods => array
|
||||
*
|
||||
*
|
||||
* Returns a list of the names of methods publicly accessible in
|
||||
* <i>obj</i>. This will include all the methods accessible in
|
||||
* <i>obj</i>'s ancestors.
|
||||
*
|
||||
*
|
||||
* class Klass
|
||||
* def kMethod()
|
||||
* end
|
||||
* end
|
||||
* k = Klass.new
|
||||
* k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
|
||||
* k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
|
||||
* # "class", "instance_variable_set",
|
||||
* # "methods", "extend", "__send__", "instance_eval"]
|
||||
* k.methods.length #=> 42
|
||||
|
@ -1738,7 +1738,7 @@ rb_obj_methods(int argc, VALUE *argv, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.protected_methods(all=true) => array
|
||||
*
|
||||
*
|
||||
* Returns the list of protected methods accessible to <i>obj</i>. If
|
||||
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
||||
* in the receiver will be listed.
|
||||
|
@ -1759,7 +1759,7 @@ rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.private_methods(all=true) => array
|
||||
*
|
||||
*
|
||||
* Returns the list of private methods accessible to <i>obj</i>. If
|
||||
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
||||
* in the receiver will be listed.
|
||||
|
@ -1780,7 +1780,7 @@ rb_obj_private_methods(int argc, VALUE *argv, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.public_methods(all=true) => array
|
||||
*
|
||||
*
|
||||
* Returns the list of public methods accessible to <i>obj</i>. If
|
||||
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
||||
* in the receiver will be listed.
|
||||
|
@ -1807,7 +1807,7 @@ rb_obj_public_methods(int argc, VALUE *argv, VALUE obj)
|
|||
* variable name should be included for regular instance
|
||||
* variables. Throws a <code>NameError</code> exception if the
|
||||
* supplied symbol is not valid as an instance variable name.
|
||||
*
|
||||
*
|
||||
* class Fred
|
||||
* def initialize(p1, p2)
|
||||
* @a, @b = p1, p2
|
||||
|
@ -1832,12 +1832,12 @@ rb_obj_ivar_get(VALUE obj, VALUE iv)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.instance_variable_set(symbol, obj) => obj
|
||||
*
|
||||
*
|
||||
* Sets the instance variable names by <i>symbol</i> to
|
||||
* <i>object</i>, thereby frustrating the efforts of the class's
|
||||
* author to attempt to provide proper encapsulation. The variable
|
||||
* did not have to exist prior to this call.
|
||||
*
|
||||
*
|
||||
* class Fred
|
||||
* def initialize(p1, p2)
|
||||
* @a, @b = p1, p2
|
||||
|
@ -1892,11 +1892,11 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.class_variable_get(symbol) => obj
|
||||
*
|
||||
*
|
||||
* Returns the value of the given class variable (or throws a
|
||||
* <code>NameError</code> exception). The <code>@@</code> part of the
|
||||
* variable name should be included for regular class variables
|
||||
*
|
||||
*
|
||||
* class Fred
|
||||
* @@foo = 99
|
||||
* end
|
||||
|
@ -1917,10 +1917,10 @@ rb_mod_cvar_get(VALUE obj, VALUE iv)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.class_variable_set(symbol, obj) => obj
|
||||
*
|
||||
*
|
||||
* Sets the class variable names by <i>symbol</i> to
|
||||
* <i>object</i>.
|
||||
*
|
||||
*
|
||||
* class Fred
|
||||
* @@foo = 99
|
||||
* def foo
|
||||
|
@ -2004,7 +2004,7 @@ convert_type(VALUE val, const char *tname, const char *method, int raise)
|
|||
NIL_P(val) ? "nil" :
|
||||
val == Qtrue ? "true" :
|
||||
val == Qfalse ? "false" :
|
||||
rb_obj_classname(val),
|
||||
rb_obj_classname(val),
|
||||
tname);
|
||||
}
|
||||
else {
|
||||
|
@ -2118,7 +2118,7 @@ rb_Integer(VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* Integer(arg) => integer
|
||||
*
|
||||
*
|
||||
* Converts <i>arg</i> to a <code>Fixnum</code> or <code>Bignum</code>.
|
||||
* Numeric types are converted directly (with floating point numbers
|
||||
* being truncated). If <i>arg</i> is a <code>String</code>, leading
|
||||
|
@ -2126,7 +2126,7 @@ rb_Integer(VALUE val)
|
|||
* <code>0x</code>) are honored. Others are converted using
|
||||
* <code>to_int</code> and <code>to_i</code>. This behavior is
|
||||
* different from that of <code>String#to_i</code>.
|
||||
*
|
||||
*
|
||||
* Integer(123.999) #=> 123
|
||||
* Integer("0x1a") #=> 26
|
||||
* Integer(Time.new) #=> 1204973019
|
||||
|
@ -2261,11 +2261,11 @@ rb_Float(VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* Float(arg) => float
|
||||
*
|
||||
*
|
||||
* Returns <i>arg</i> converted to a float. Numeric types are converted
|
||||
* directly, the rest are converted using <i>arg</i>.to_f. As of Ruby
|
||||
* 1.8, converting <code>nil</code> generates a <code>TypeError</code>.
|
||||
*
|
||||
*
|
||||
* Float(1) #=> 1.0
|
||||
* Float("123.456") #=> 123.456
|
||||
*/
|
||||
|
@ -2322,10 +2322,10 @@ rb_String(VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* String(arg) => string
|
||||
*
|
||||
*
|
||||
* Converts <i>arg</i> to a <code>String</code> by calling its
|
||||
* <code>to_s</code> method.
|
||||
*
|
||||
*
|
||||
* String(self) #=> "main"
|
||||
* String(self.class) #=> "Object"
|
||||
* String(123456) #=> "123456"
|
||||
|
@ -2354,10 +2354,10 @@ rb_Array(VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* Array(arg) => array
|
||||
*
|
||||
*
|
||||
* Returns <i>arg</i> as an <code>Array</code>. First tries to call
|
||||
* <i>arg</i><code>.to_ary</code>, then <i>arg</i><code>.to_a</code>.
|
||||
*
|
||||
*
|
||||
* Array(1..5) #=> [1, 2, 3, 4, 5]
|
||||
*/
|
||||
|
||||
|
@ -2391,7 +2391,7 @@ boot_defmetametaclass(VALUE klass, VALUE metametaclass)
|
|||
*
|
||||
* Classes in Ruby are first-class objects---each is an instance of
|
||||
* class <code>Class</code>.
|
||||
*
|
||||
*
|
||||
* When a new class is created (typically using <code>class Name ...
|
||||
* end</code>), an object of type <code>Class</code> is created and
|
||||
* assigned to a global constant (<code>Name</code> in this case). When
|
||||
|
@ -2399,7 +2399,7 @@ boot_defmetametaclass(VALUE klass, VALUE metametaclass)
|
|||
* <code>new</code> method in <code>Class</code> is run by default.
|
||||
* This can be demonstrated by overriding <code>new</code> in
|
||||
* <code>Class</code>:
|
||||
*
|
||||
*
|
||||
* class Class
|
||||
* alias oldNew new
|
||||
* def new(*args)
|
||||
|
@ -2407,21 +2407,21 @@ boot_defmetametaclass(VALUE klass, VALUE metametaclass)
|
|||
* oldNew(*args)
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* class Name
|
||||
* end
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* n = Name.new
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Creating a new Name
|
||||
*
|
||||
*
|
||||
* Classes, modules, and objects are interrelated. In the diagram
|
||||
* that follows, the vertical arrows represent inheritance, and the
|
||||
* parentheses meta-classes. All metaclasses are instances
|
||||
* parentheses meta-classes. All metaclasses are instances
|
||||
* of the class `Class'.
|
||||
*
|
||||
* +-----------------+
|
||||
|
@ -2453,13 +2453,13 @@ boot_defmetametaclass(VALUE klass, VALUE metametaclass)
|
|||
* class hierarchy is a direct subclass of <code>BasicObject</code>. Its
|
||||
* methods are therefore available to all objects unless explicitly
|
||||
* overridden.
|
||||
*
|
||||
*
|
||||
* <code>Object</code> mixes in the <code>Kernel</code> module, making
|
||||
* the built-in kernel functions globally accessible. Although the
|
||||
* instance methods of <code>Object</code> are defined by the
|
||||
* <code>Kernel</code> module, we have chosen to document them here for
|
||||
* clarity.
|
||||
*
|
||||
*
|
||||
* In the descriptions of Object's methods, the parameter <i>symbol</i> refers
|
||||
* to a symbol, which is either a quoted string or a
|
||||
* <code>Symbol</code> (such as <code>:name</code>).
|
||||
|
@ -2509,7 +2509,7 @@ Init_Object(void)
|
|||
rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
|
||||
|
||||
rb_define_method(rb_mKernel, "nil?", rb_false, 0);
|
||||
rb_define_method(rb_mKernel, "===", rb_equal, 1);
|
||||
rb_define_method(rb_mKernel, "===", rb_equal, 1);
|
||||
rb_define_method(rb_mKernel, "=~", rb_obj_match, 1);
|
||||
rb_define_method(rb_mKernel, "!~", rb_obj_not_match, 1);
|
||||
rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1);
|
||||
|
@ -2595,24 +2595,24 @@ Init_Object(void)
|
|||
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
|
||||
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
|
||||
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
|
||||
rb_define_method(rb_cModule, "public_instance_methods",
|
||||
rb_define_method(rb_cModule, "public_instance_methods",
|
||||
rb_class_public_instance_methods, -1); /* in class.c */
|
||||
rb_define_method(rb_cModule, "protected_instance_methods",
|
||||
rb_define_method(rb_cModule, "protected_instance_methods",
|
||||
rb_class_protected_instance_methods, -1); /* in class.c */
|
||||
rb_define_method(rb_cModule, "private_instance_methods",
|
||||
rb_define_method(rb_cModule, "private_instance_methods",
|
||||
rb_class_private_instance_methods, -1); /* in class.c */
|
||||
|
||||
rb_define_method(rb_cModule, "constants", rb_mod_constants, -1); /* in variable.c */
|
||||
rb_define_method(rb_cModule, "const_get", rb_mod_const_get, -1);
|
||||
rb_define_method(rb_cModule, "const_set", rb_mod_const_set, 2);
|
||||
rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, -1);
|
||||
rb_define_private_method(rb_cModule, "remove_const",
|
||||
rb_define_private_method(rb_cModule, "remove_const",
|
||||
rb_mod_remove_const, 1); /* in variable.c */
|
||||
rb_define_method(rb_cModule, "const_missing",
|
||||
rb_define_method(rb_cModule, "const_missing",
|
||||
rb_mod_const_missing, 1); /* in variable.c */
|
||||
rb_define_method(rb_cModule, "class_variables",
|
||||
rb_define_method(rb_cModule, "class_variables",
|
||||
rb_mod_class_variables, 0); /* in variable.c */
|
||||
rb_define_method(rb_cModule, "remove_class_variable",
|
||||
rb_define_method(rb_cModule, "remove_class_variable",
|
||||
rb_mod_remove_cvar, 1); /* in variable.c */
|
||||
rb_define_method(rb_cModule, "class_variable_get", rb_mod_cvar_get, 1);
|
||||
rb_define_method(rb_cModule, "class_variable_set", rb_mod_cvar_set, 2);
|
||||
|
|
2
parse.y
2
parse.y
|
@ -3498,7 +3498,7 @@ block_call : command do_block
|
|||
}
|
||||
else {
|
||||
block_dup_check($1->nd_args, $2);
|
||||
}
|
||||
}
|
||||
$2->nd_iter = $1;
|
||||
$$ = $2;
|
||||
fixpos($$, $1);
|
||||
|
|
136
proc.c
136
proc.c
|
@ -294,12 +294,12 @@ rb_binding_new(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* binding -> a_binding
|
||||
*
|
||||
*
|
||||
* Returns a +Binding+ object, describing the variable and
|
||||
* method bindings at the point of call. This object can be used when
|
||||
* calling +eval+ to execute the evaluated command in this
|
||||
* environment. Also see the description of class +Binding+.
|
||||
*
|
||||
*
|
||||
* def getBinding(param)
|
||||
* return binding
|
||||
* end
|
||||
|
@ -397,12 +397,12 @@ proc_new(VALUE klass, int is_lambda)
|
|||
* call-seq:
|
||||
* Proc.new {|...| block } => a_proc
|
||||
* Proc.new => a_proc
|
||||
*
|
||||
*
|
||||
* Creates a new <code>Proc</code> object, bound to the current
|
||||
* context. <code>Proc::new</code> may be called without a block only
|
||||
* within a method with an attached block, in which case that block is
|
||||
* converted to the <code>Proc</code> object.
|
||||
*
|
||||
*
|
||||
* def proc_from
|
||||
* Proc.new
|
||||
* end
|
||||
|
@ -466,7 +466,7 @@ proc_lambda(void)
|
|||
* prc.call(params,...) => obj
|
||||
* prc[params,...] => obj
|
||||
* prc.(params,...) => obj
|
||||
*
|
||||
*
|
||||
* Invokes the block, setting the block's parameters to the values in
|
||||
* <i>params</i> using something close to method calling semantics.
|
||||
* Generates a warning if multiple values are passed to a proc that
|
||||
|
@ -481,15 +481,15 @@ proc_lambda(void)
|
|||
*
|
||||
* Returns the value of the last expression evaluated in the block. See
|
||||
* also <code>Proc#yield</code>.
|
||||
*
|
||||
*
|
||||
* a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
|
||||
* a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
|
||||
* a_proc[9, 1, 2, 3] #=> [9, 18, 27]
|
||||
* a_proc = Proc.new {|a,b| a}
|
||||
* a_proc.call(1,2,3)
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError)
|
||||
* from prog.rb:4:in `call'
|
||||
* from prog.rb:5
|
||||
|
@ -498,7 +498,7 @@ proc_lambda(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* prc === obj => obj
|
||||
*
|
||||
*
|
||||
* Invokes the block, with <i>obj</i> as the block's parameter. It is
|
||||
* to allow a proc object to be a target of when clause in the case statement.
|
||||
*/
|
||||
|
@ -555,14 +555,14 @@ rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
|
|||
/*
|
||||
* call-seq:
|
||||
* prc.arity -> fixnum
|
||||
*
|
||||
*
|
||||
* Returns the number of arguments that would not be ignored. If the block
|
||||
* is declared to take no arguments, returns 0. If the block is known
|
||||
* to take exactly n arguments, returns n. If the block has optional
|
||||
* arguments, return -n-1, where n is the number of mandatory
|
||||
* arguments. A <code>proc</code> with no argument declarations
|
||||
* is the same a block declaring <code>||</code> as its arguments.
|
||||
*
|
||||
*
|
||||
* Proc.new {}.arity #=> 0
|
||||
* Proc.new {||}.arity #=> 0
|
||||
* Proc.new {|a|}.arity #=> 1
|
||||
|
@ -761,14 +761,14 @@ proc_to_s(VALUE self)
|
|||
const char *cname = rb_obj_classname(self);
|
||||
rb_iseq_t *iseq;
|
||||
const char *is_lambda;
|
||||
|
||||
|
||||
GetProcPtr(self, proc);
|
||||
iseq = proc->block.iseq;
|
||||
is_lambda = proc->is_lambda ? " (lambda)" : "";
|
||||
|
||||
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
|
||||
int line_no = 0;
|
||||
|
||||
|
||||
if (iseq->insn_info_table) {
|
||||
line_no = rb_iseq_first_lineno(iseq);
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ proc_to_s(VALUE self)
|
|||
/*
|
||||
* call-seq:
|
||||
* prc.to_proc -> prc
|
||||
*
|
||||
*
|
||||
* Part of the protocol for converting objects to <code>Proc</code>
|
||||
* objects. Instances of class <code>Proc</code> simply return
|
||||
* themselves.
|
||||
|
@ -883,7 +883,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
|||
* associated with an iterator. They may also be unbound from one
|
||||
* object (creating an <code>UnboundMethod</code>) and bound to
|
||||
* another.
|
||||
*
|
||||
*
|
||||
* class Thing
|
||||
* def square(n)
|
||||
* n*n
|
||||
|
@ -891,10 +891,10 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
|||
* end
|
||||
* thing = Thing.new
|
||||
* meth = thing.method(:square)
|
||||
*
|
||||
*
|
||||
* meth.call(9) #=> 81
|
||||
* [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9]
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -952,7 +952,7 @@ method_hash(VALUE method)
|
|||
/*
|
||||
* call-seq:
|
||||
* meth.unbind => unbound_method
|
||||
*
|
||||
*
|
||||
* Dissociates <i>meth</i> from it's current receiver. The resulting
|
||||
* <code>UnboundMethod</code> can subsequently be bound to a new object
|
||||
* of the same class (see <code>UnboundMethod</code>).
|
||||
|
@ -981,7 +981,7 @@ method_unbind(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* meth.receiver => object
|
||||
*
|
||||
*
|
||||
* Returns the bound receiver of the method object.
|
||||
*/
|
||||
|
||||
|
@ -997,7 +997,7 @@ method_receiver(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* meth.name => symbol
|
||||
*
|
||||
*
|
||||
* Returns the name of the method.
|
||||
*/
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ method_name(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* meth.owner => class_or_module
|
||||
*
|
||||
*
|
||||
* Returns the class or module that defines the method.
|
||||
*/
|
||||
|
||||
|
@ -1029,13 +1029,13 @@ method_owner(VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.method(sym) => method
|
||||
*
|
||||
*
|
||||
* Looks up the named method as a receiver in <i>obj</i>, returning a
|
||||
* <code>Method</code> object (or raising <code>NameError</code>). The
|
||||
* <code>Method</code> object acts as a closure in <i>obj</i>'s object
|
||||
* instance, so instance variables and the value of <code>self</code>
|
||||
* remain available.
|
||||
*
|
||||
*
|
||||
* class Demo
|
||||
* def initialize(n)
|
||||
* @iv = n
|
||||
|
@ -1044,11 +1044,11 @@ method_owner(VALUE obj)
|
|||
* "Hello, @iv = #{@iv}"
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* k = Demo.new(99)
|
||||
* m = k.method(:hello)
|
||||
* m.call #=> "Hello, @iv = 99"
|
||||
*
|
||||
*
|
||||
* l = Demo.new('Fred')
|
||||
* m = l.method("hello")
|
||||
* m.call #=> "Hello, @iv = Fred"
|
||||
|
@ -1069,10 +1069,10 @@ rb_obj_public_method(VALUE obj, VALUE vid)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.instance_method(symbol) => unbound_method
|
||||
*
|
||||
*
|
||||
* Returns an +UnboundMethod+ representing the given
|
||||
* instance method in _mod_.
|
||||
*
|
||||
*
|
||||
* class Interpreter
|
||||
* def do_a() print "there, "; end
|
||||
* def do_d() print "Hello "; end
|
||||
|
@ -1088,13 +1088,13 @@ rb_obj_public_method(VALUE obj, VALUE vid)
|
|||
* string.each_byte {|b| Dispatcher[b].bind(self).call }
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* interpreter = Interpreter.new
|
||||
* interpreter.interpret('dave')
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Hello there, Dave!
|
||||
*/
|
||||
|
||||
|
@ -1114,14 +1114,14 @@ rb_mod_public_instance_method(VALUE mod, VALUE vid)
|
|||
* call-seq:
|
||||
* define_method(symbol, method) => new_method
|
||||
* define_method(symbol) { block } => proc
|
||||
*
|
||||
*
|
||||
* Defines an instance method in the receiver. The _method_
|
||||
* parameter can be a +Proc+ or +Method+ object.
|
||||
* If a block is specified, it is used as the method body. This block
|
||||
* is evaluated using <code>instance_eval</code>, a point that is
|
||||
* tricky to demonstrate because <code>define_method</code> is private.
|
||||
* (This is why we resort to the +send+ hack in this example.)
|
||||
*
|
||||
*
|
||||
* class A
|
||||
* def fred
|
||||
* puts "In Fred"
|
||||
|
@ -1139,9 +1139,9 @@ rb_mod_public_instance_method(VALUE mod, VALUE vid)
|
|||
* a.wilma
|
||||
* a.create_method(:betty) { p self }
|
||||
* a.betty
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* In Fred
|
||||
* Charge it!
|
||||
* #<B:0x401b39e8>
|
||||
|
@ -1242,10 +1242,10 @@ method_clone(VALUE self)
|
|||
* call-seq:
|
||||
* meth.call(args, ...) => obj
|
||||
* meth[args, ...] => obj
|
||||
*
|
||||
*
|
||||
* Invokes the <i>meth</i> with the specified arguments, returning the
|
||||
* method's return value.
|
||||
*
|
||||
*
|
||||
* m = 12.method("+")
|
||||
* m.call(3) #=> 15
|
||||
* m.call(20) #=> 32
|
||||
|
@ -1296,17 +1296,17 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
|||
* with a particular object: these method objects are bound to that
|
||||
* object. Bound method objects for an object can be created using
|
||||
* <code>Object#method</code>.
|
||||
*
|
||||
*
|
||||
* Ruby also supports unbound methods; methods objects that are not
|
||||
* associated with a particular object. These can be created either by
|
||||
* calling <code>Module#instance_method</code> or by calling
|
||||
* <code>unbind</code> on a bound method object. The result of both of
|
||||
* these is an <code>UnboundMethod</code> object.
|
||||
*
|
||||
*
|
||||
* Unbound methods can only be called after they are bound to an
|
||||
* object. That object must be be a kind_of? the method's original
|
||||
* class.
|
||||
*
|
||||
*
|
||||
* class Square
|
||||
* def area
|
||||
* @side * @side
|
||||
|
@ -1315,17 +1315,17 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
|||
* @side = side
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* area_un = Square.instance_method(:area)
|
||||
*
|
||||
*
|
||||
* s = Square.new(12)
|
||||
* area = area_un.bind(s)
|
||||
* area.call #=> 144
|
||||
*
|
||||
*
|
||||
* Unbound methods are a reference to the method at the time it was
|
||||
* objectified: subsequent changes to the underlying class will not
|
||||
* affect the unbound method.
|
||||
*
|
||||
*
|
||||
* class Test
|
||||
* def test
|
||||
* :original
|
||||
|
@ -1340,17 +1340,17 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
|||
* t = Test.new
|
||||
* t.test #=> :modified
|
||||
* um.bind(t).call #=> :original
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* umeth.bind(obj) -> method
|
||||
*
|
||||
*
|
||||
* Bind <i>umeth</i> to <i>obj</i>. If <code>Klass</code> was the class
|
||||
* from which <i>umeth</i> was obtained,
|
||||
* <code>obj.kind_of?(Klass)</code> must be true.
|
||||
*
|
||||
*
|
||||
* class A
|
||||
* def test
|
||||
* puts "In test, class = #{self.class}"
|
||||
|
@ -1360,8 +1360,8 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
|||
* end
|
||||
* class C < B
|
||||
* end
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* um = B.instance_method(:test)
|
||||
* bm = um.bind(C.new)
|
||||
* bm.call
|
||||
|
@ -1369,9 +1369,9 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
|||
* bm.call
|
||||
* bm = um.bind(A.new)
|
||||
* bm.call
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* In test, class = C
|
||||
* In test, class = B
|
||||
* prog.rb:16:in `bind': bind argument must be an instance of B (TypeError)
|
||||
|
@ -1438,14 +1438,14 @@ rb_node_arity(NODE* body)
|
|||
/*
|
||||
* call-seq:
|
||||
* meth.arity => fixnum
|
||||
*
|
||||
*
|
||||
* Returns an indication of the number of arguments accepted by a
|
||||
* method. Returns a nonnegative integer for methods that take a fixed
|
||||
* number of arguments. For Ruby methods that take a variable number of
|
||||
* arguments, returns -n-1, where n is the number of required
|
||||
* arguments. For methods written in C, returns -1 if the call takes a
|
||||
* variable number of arguments.
|
||||
*
|
||||
*
|
||||
* class C
|
||||
* def one; end
|
||||
* def two(a); end
|
||||
|
@ -1461,7 +1461,7 @@ rb_node_arity(NODE* body)
|
|||
* c.method(:four).arity #=> 2
|
||||
* c.method(:five).arity #=> -3
|
||||
* c.method(:six).arity #=> -3
|
||||
*
|
||||
*
|
||||
* "cat".method(:size).arity #=> 0
|
||||
* "cat".method(:replace).arity #=> 1
|
||||
* "cat".method(:squeeze).arity #=> -1
|
||||
|
@ -1643,7 +1643,7 @@ rb_proc_new(
|
|||
/*
|
||||
* call-seq:
|
||||
* meth.to_proc => prc
|
||||
*
|
||||
*
|
||||
* Returns a <code>Proc</code> object corresponding to this method.
|
||||
*/
|
||||
|
||||
|
@ -1705,15 +1705,15 @@ localjump_reason(VALUE exc)
|
|||
/*
|
||||
* call-seq:
|
||||
* prc.binding => binding
|
||||
*
|
||||
*
|
||||
* Returns the binding associated with <i>prc</i>. Note that
|
||||
* <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
|
||||
* <code>Binding</code> object as its second parameter.
|
||||
*
|
||||
*
|
||||
* def fred(param)
|
||||
* proc {}
|
||||
* end
|
||||
*
|
||||
*
|
||||
* b = fred(99)
|
||||
* eval("param", b.binding) #=> 99
|
||||
*/
|
||||
|
@ -1840,18 +1840,18 @@ proc_curry(int argc, VALUE *argv, VALUE self)
|
|||
* <code>Proc</code> objects are blocks of code that have been bound to
|
||||
* a set of local variables. Once bound, the code may be called in
|
||||
* different contexts and still access those variables.
|
||||
*
|
||||
*
|
||||
* def gen_times(factor)
|
||||
* return Proc.new {|n| n*factor }
|
||||
* end
|
||||
*
|
||||
*
|
||||
* times3 = gen_times(3)
|
||||
* times5 = gen_times(5)
|
||||
*
|
||||
*
|
||||
* times3.call(12) #=> 36
|
||||
* times5.call(5) #=> 25
|
||||
* times3.call(times5.call(4)) #=> 60
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
|
@ -1951,11 +1951,11 @@ Init_Proc(void)
|
|||
* are all retained. Binding objects can be created using
|
||||
* <code>Kernel#binding</code>, and are made available to the callback
|
||||
* of <code>Kernel#set_trace_func</code>.
|
||||
*
|
||||
*
|
||||
* These binding objects can be passed as the second argument of the
|
||||
* <code>Kernel#eval</code> method, establishing an environment for the
|
||||
* evaluation.
|
||||
*
|
||||
*
|
||||
* class Demo
|
||||
* def initialize(n)
|
||||
* @secret = n
|
||||
|
@ -1964,18 +1964,18 @@ Init_Proc(void)
|
|||
* return binding()
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* k1 = Demo.new(99)
|
||||
* b1 = k1.getBinding
|
||||
* k2 = Demo.new(-3)
|
||||
* b2 = k2.getBinding
|
||||
*
|
||||
*
|
||||
* eval("@secret", b1) #=> 99
|
||||
* eval("@secret", b2) #=> -3
|
||||
* eval("@secret") #=> nil
|
||||
*
|
||||
*
|
||||
* Binding objects have no class-specific methods.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
|
|
18
random.c
18
random.c
|
@ -9,7 +9,7 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
/*
|
||||
/*
|
||||
This is based on trimmed version of MT19937. To get the original version,
|
||||
contact <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html>.
|
||||
|
||||
|
@ -24,7 +24,7 @@ The original copyright notice follows.
|
|||
or init_by_array(mt, init_key, key_length).
|
||||
|
||||
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
||||
All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -37,8 +37,8 @@ The original copyright notice follows.
|
|||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The names of its contributors may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
3. The names of its contributors may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
|
@ -59,7 +59,7 @@ The original copyright notice follows.
|
|||
email: matumoto@math.keio.ac.jp
|
||||
*/
|
||||
|
||||
/* Period parameters */
|
||||
/* Period parameters */
|
||||
#define N 624
|
||||
#define M 397
|
||||
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
|
||||
|
@ -340,7 +340,7 @@ random_seed(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* srand(number=0) => old_seed
|
||||
*
|
||||
*
|
||||
* Seeds the pseudorandom number generator to the value of
|
||||
* <i>number</i>. If <i>number</i> is omitted
|
||||
* or zero, seeds the generator using a combination of the time, the
|
||||
|
@ -369,7 +369,7 @@ rb_f_srand(int argc, VALUE *argv, VALUE obj)
|
|||
return old;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static unsigned long
|
||||
make_mask(unsigned long x)
|
||||
{
|
||||
x = x | x >> 1;
|
||||
|
@ -465,7 +465,7 @@ rb_rand_internal(unsigned long i)
|
|||
/*
|
||||
* call-seq:
|
||||
* rand(max=0) => number
|
||||
*
|
||||
*
|
||||
* Converts <i>max</i> to an integer using max1 =
|
||||
* max<code>.to_i.abs</code>. If the result is zero, returns a
|
||||
* pseudorandom floating point number greater than or equal to 0.0 and
|
||||
|
@ -474,7 +474,7 @@ rb_rand_internal(unsigned long i)
|
|||
* may be used to ensure repeatable sequences of random numbers between
|
||||
* different runs of the program. Ruby currently uses a modified
|
||||
* Mersenne Twister with a period of 2**19937-1.
|
||||
*
|
||||
*
|
||||
* srand 1234 #=> 0
|
||||
* [ rand, rand ] #=> [0.191519450163469, 0.49766366626136]
|
||||
* [ rand(10), rand(1000) ] #=> [6, 817]
|
||||
|
|
88
range.c
88
range.c
|
@ -44,7 +44,7 @@ range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
|
|||
|
||||
args[0] = beg;
|
||||
args[1] = end;
|
||||
|
||||
|
||||
if (!FIXNUM_P(beg) || !FIXNUM_P(end)) {
|
||||
VALUE v;
|
||||
|
||||
|
@ -70,7 +70,7 @@ rb_range_new(VALUE beg, VALUE end, int exclude_end)
|
|||
/*
|
||||
* call-seq:
|
||||
* Range.new(start, end, exclusive=false) => range
|
||||
*
|
||||
*
|
||||
* Constructs a range using the given <i>start</i> and <i>end</i>. If the third
|
||||
* parameter is omitted or is <code>false</code>, the <i>range</i> will include
|
||||
* the end object; otherwise, it will be excluded.
|
||||
|
@ -80,7 +80,7 @@ static VALUE
|
|||
range_initialize(int argc, VALUE *argv, VALUE range)
|
||||
{
|
||||
VALUE beg, end, flags;
|
||||
|
||||
|
||||
rb_scan_args(argc, argv, "21", &beg, &end, &flags);
|
||||
/* Ranges are immutable, so that they should be initialized only once. */
|
||||
if (RANGE_EXCL(range) != Qnil) {
|
||||
|
@ -95,7 +95,7 @@ range_initialize(int argc, VALUE *argv, VALUE range)
|
|||
/*
|
||||
* call-seq:
|
||||
* rng.exclude_end? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>rng</i> excludes its end value.
|
||||
*/
|
||||
|
||||
|
@ -109,15 +109,15 @@ range_exclude_end_p(VALUE range)
|
|||
/*
|
||||
* call-seq:
|
||||
* rng == obj => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> only if <i>obj</i> is a Range, has equivalent
|
||||
* beginning and end items (by comparing them with <code>==</code>), and has
|
||||
* the same #exclude_end? setting as <i>rng</t>.
|
||||
*
|
||||
*
|
||||
* (0..2) == (0..2) #=> true
|
||||
* (0..2) == Range.new(0,2) #=> true
|
||||
* (0..2) == (0...2) #=> false
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -171,15 +171,15 @@ r_le(VALUE a, VALUE b)
|
|||
/*
|
||||
* call-seq:
|
||||
* rng.eql?(obj) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> only if <i>obj</i> is a Range, has equivalent
|
||||
* beginning and end items (by comparing them with #eql?), and has the same
|
||||
* #exclude_end? setting as <i>rng</i>.
|
||||
*
|
||||
*
|
||||
* (0..2) == (0..2) #=> true
|
||||
* (0..2) == Range.new(0,2) #=> true
|
||||
* (0..2) == (0...2) #=> false
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -274,19 +274,19 @@ extern int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
|
|||
/*
|
||||
* call-seq:
|
||||
* rng.step(n=1) {| obj | block } => rng
|
||||
*
|
||||
*
|
||||
* Iterates over <i>rng</i>, passing each <i>n</i>th element to the block. If
|
||||
* the range contains numbers, <i>n</i> is added for each iteration. Otherwise
|
||||
* <code>step</code> invokes <code>succ</code> to iterate through range
|
||||
* elements. The following code uses class <code>Xs</code>, which is defined
|
||||
* in the class-level documentation.
|
||||
*
|
||||
*
|
||||
* range = Xs.new(1)..Xs.new(10)
|
||||
* range.step(2) {|x| puts x}
|
||||
* range.step(3) {|x| puts x}
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* 1 x
|
||||
* 3 xxx
|
||||
* 5 xxxxx
|
||||
|
@ -330,7 +330,7 @@ range_step(int argc, VALUE *argv, VALUE range)
|
|||
|
||||
if (!EXCL(range))
|
||||
end += 1;
|
||||
i = FIX2LONG(b);
|
||||
i = FIX2LONG(b);
|
||||
while (i < end) {
|
||||
rb_yield(LONG2NUM(i));
|
||||
if (i + unit < i) break;
|
||||
|
@ -392,18 +392,18 @@ each_i(VALUE v, void *arg)
|
|||
/*
|
||||
* call-seq:
|
||||
* rng.each {| i | block } => rng
|
||||
*
|
||||
*
|
||||
* Iterates over the elements <i>rng</i>, passing each in turn to the
|
||||
* block. You can only iterate if the start object of the range
|
||||
* supports the +succ+ method (which means that you can't iterate over
|
||||
* ranges of +Float+ objects).
|
||||
*
|
||||
*
|
||||
* (10..15).each do |n|
|
||||
* print n, ' '
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* 10 11 12 13 14 15
|
||||
*/
|
||||
|
||||
|
@ -447,7 +447,7 @@ range_each(VALUE range)
|
|||
/*
|
||||
* call-seq:
|
||||
* rng.begin => obj
|
||||
*
|
||||
*
|
||||
* Returns the first object in <i>rng</i>.
|
||||
*/
|
||||
|
||||
|
@ -461,9 +461,9 @@ range_begin(VALUE range)
|
|||
/*
|
||||
* call-seq:
|
||||
* rng.end => obj
|
||||
*
|
||||
*
|
||||
* Returns the object that defines the end of <i>rng</i>.
|
||||
*
|
||||
*
|
||||
* (1..10).end #=> 10
|
||||
* (1...10).end #=> 10
|
||||
*/
|
||||
|
@ -494,7 +494,7 @@ first_i(VALUE i, VALUE *ary)
|
|||
* call-seq:
|
||||
* rng.first => obj
|
||||
* rng.first(n) => an_array
|
||||
*
|
||||
*
|
||||
* Returns the first object in <i>rng</i>, or the first +n+ elements.
|
||||
*/
|
||||
|
||||
|
@ -518,7 +518,7 @@ range_first(int argc, VALUE *argv, VALUE range)
|
|||
* call-seq:
|
||||
* rng.last => obj
|
||||
* rng.last(n) => an_array
|
||||
*
|
||||
*
|
||||
* Returns the last object in <i>rng</i>, or the last +n+ elements.
|
||||
*/
|
||||
|
||||
|
@ -528,7 +528,7 @@ range_last(int argc, VALUE *argv, VALUE range)
|
|||
VALUE rb_ary_last(int, VALUE *, VALUE);
|
||||
|
||||
if (argc == 0) return RANGE_END(range);
|
||||
return rb_ary_last(argc, argv, rb_Array(range));
|
||||
return rb_ary_last(argc, argv, rb_Array(range));
|
||||
}
|
||||
|
||||
|
||||
|
@ -536,11 +536,11 @@ range_last(int argc, VALUE *argv, VALUE range)
|
|||
* call-seq:
|
||||
* rng.min => obj
|
||||
* rng.min {| a,b | block } => obj
|
||||
*
|
||||
*
|
||||
* Returns the minimum value in <i>rng</i>. The second uses
|
||||
* the block to compare values. Returns nil if the first
|
||||
* value in range is larger than the last value.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
@ -565,11 +565,11 @@ range_min(VALUE range)
|
|||
* call-seq:
|
||||
* rng.max => obj
|
||||
* rng.max {| a,b | block } => obj
|
||||
*
|
||||
*
|
||||
* Returns the maximum value in <i>rng</i>. The second uses
|
||||
* the block to compare values. Returns nil if the first
|
||||
* value in range is larger than the last value.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -698,7 +698,7 @@ inspect_range(VALUE range, VALUE dummy, int recur)
|
|||
* call-seq:
|
||||
* rng.inspect => string
|
||||
*
|
||||
* Convert this range object to a printable form (using
|
||||
* Convert this range object to a printable form (using
|
||||
* <code>inspect</code> to convert the start and end
|
||||
* objects).
|
||||
*/
|
||||
|
@ -713,20 +713,20 @@ range_inspect(VALUE range)
|
|||
/*
|
||||
* call-seq:
|
||||
* rng === obj => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>obj</i> is an element of
|
||||
* <i>rng</i>, <code>false</code> otherwise. Conveniently,
|
||||
* <code>===</code> is the comparison operator used by
|
||||
* <code>case</code> statements.
|
||||
*
|
||||
*
|
||||
* case 79
|
||||
* when 1..50 then print "low\n"
|
||||
* when 51..75 then print "medium\n"
|
||||
* when 76..100 then print "high\n"
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* high
|
||||
*/
|
||||
|
||||
|
@ -741,11 +741,11 @@ range_eqq(VALUE range, VALUE val)
|
|||
* call-seq:
|
||||
* rng.member?(val) => true or false
|
||||
* rng.include?(val) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>obj</i> is an element of
|
||||
* <i>rng</i>, <code>false</code> otherwise. If beg and end are
|
||||
* numeric, comparison is done according magnitude of values.
|
||||
*
|
||||
*
|
||||
* ("a".."z").include?("g") # => true
|
||||
* ("a".."z").include?("A") # => false
|
||||
*/
|
||||
|
@ -801,11 +801,11 @@ range_include(VALUE range, VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* rng.cover?(val) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>obj</i> is between beg and end,
|
||||
* i.e <code>beg <= obj <= end</code> (or <i>end</i> exclusive when
|
||||
* <code>exclude_end?</code> is true).
|
||||
*
|
||||
*
|
||||
* ("a".."z").cover?("c") #=> true
|
||||
* ("a".."z").cover?("5") #=> false
|
||||
*/
|
||||
|
@ -874,17 +874,17 @@ range_alloc(VALUE klass)
|
|||
* run from the start to the end inclusively. Those created using
|
||||
* <code>...</code> exclude the end value. When used as an iterator,
|
||||
* ranges return each value in the sequence.
|
||||
*
|
||||
*
|
||||
* (-1..-5).to_a #=> []
|
||||
* (-5..-1).to_a #=> [-5, -4, -3, -2, -1]
|
||||
* ('a'..'e').to_a #=> ["a", "b", "c", "d", "e"]
|
||||
* ('a'...'e').to_a #=> ["a", "b", "c", "d"]
|
||||
*
|
||||
*
|
||||
* Ranges can be constructed using objects of any type, as long as the
|
||||
* objects can be compared using their <code><=></code> operator and
|
||||
* they support the <code>succ</code> method to return the next object
|
||||
* in sequence.
|
||||
*
|
||||
*
|
||||
* class Xs # represent a string of 'x's
|
||||
* include Comparable
|
||||
* attr :length
|
||||
|
@ -904,18 +904,18 @@ range_alloc(VALUE klass)
|
|||
* 'x' * @length
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* r = Xs.new(3)..Xs.new(6) #=> xxx..xxxxxx
|
||||
* r.to_a #=> [xxx, xxxx, xxxxx, xxxxxx]
|
||||
* r.member?(Xs.new(5)) #=> true
|
||||
*
|
||||
*
|
||||
* In the previous code example, class <code>Xs</code> includes the
|
||||
* <code>Comparable</code> module. This is because
|
||||
* <code>Enumerable#member?</code> checks for equality using
|
||||
* <code>==</code>. Including <code>Comparable</code> ensures that the
|
||||
* <code>==</code> method is defined in terms of the <code><=></code>
|
||||
* method implemented in <code>Xs</code>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
|
|
20
re.c
20
re.c
|
@ -708,7 +708,7 @@ reg_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end,
|
|||
* A key of the hash is a name of the named captures.
|
||||
* A value of the hash is an array which is list of indexes of corresponding
|
||||
* named captures.
|
||||
*
|
||||
*
|
||||
* /(?<foo>.)(?<bar>.)/.named_captures
|
||||
* #=> {"foo"=>[1], "bar"=>[2]}
|
||||
*
|
||||
|
@ -2139,7 +2139,7 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
|
|||
goto escape_asis;
|
||||
}
|
||||
}
|
||||
/* xxx: How about more than 199 subexpressions? */
|
||||
/* xxx: How about more than 199 subexpressions? */
|
||||
|
||||
case '0': /* \0, \0O, \0OO */
|
||||
|
||||
|
@ -2350,7 +2350,7 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
|
|||
if (options & ARG_ENCODING_NONE) {
|
||||
re->basic.flags |= REG_ENCODING_NONE;
|
||||
}
|
||||
|
||||
|
||||
re->ptr = make_regexp(RSTRING_PTR(unescaped), RSTRING_LEN(unescaped), enc,
|
||||
options & ARG_REG_OPTION_MASK, err);
|
||||
if (!re->ptr) return -1;
|
||||
|
@ -2576,7 +2576,7 @@ reg_match_pos(VALUE re, VALUE *strp, long pos)
|
|||
*
|
||||
* If it is not matched, nil is assigned for the variables.
|
||||
*
|
||||
* /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = "
|
||||
* /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = "
|
||||
* p lhs #=> nil
|
||||
* p rhs #=> nil
|
||||
*
|
||||
|
@ -2694,18 +2694,18 @@ rb_reg_match2(VALUE re)
|
|||
*
|
||||
* /(.)(.)(.)/.match("abc")[2] #=> "b"
|
||||
* /(.)(.)/.match("abc", 1)[2] #=> "c"
|
||||
*
|
||||
*
|
||||
* If a block is given, invoke the block with MatchData if match succeed, so
|
||||
* that you can write
|
||||
*
|
||||
*
|
||||
* pat.match(str) {|m| ...}
|
||||
*
|
||||
*
|
||||
* instead of
|
||||
*
|
||||
*
|
||||
* if m = pat.match(str)
|
||||
* ...
|
||||
* end
|
||||
*
|
||||
*
|
||||
* The return value is a value from block execution in this case.
|
||||
*/
|
||||
|
||||
|
@ -3200,7 +3200,7 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
|
|||
case 'k':
|
||||
if (s < e && ASCGET(s, e, &clen) == '<') {
|
||||
char *name, *name_end;
|
||||
|
||||
|
||||
name_end = name = s + clen;
|
||||
while (name_end < e) {
|
||||
c = ASCGET(name_end, e, &clen);
|
||||
|
|
28
regcomp.c
28
regcomp.c
|
@ -2555,7 +2555,7 @@ is_not_included(Node* x, Node* y, regex_t* reg)
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -3294,7 +3294,7 @@ expand_case_fold_string_alt(int item_num, OnigCaseFoldCodeItem items[],
|
|||
for (i = 0; i < item_num; i++) {
|
||||
snode = onig_node_new_str(NULL, NULL);
|
||||
if (IS_NULL(snode)) goto mem_err;
|
||||
|
||||
|
||||
for (j = 0; j < items[i].code_len; j++) {
|
||||
len = ONIGENC_CODE_TO_MBC(reg->enc, items[i].code[j], buf);
|
||||
if (len < 0) {
|
||||
|
@ -4004,15 +4004,15 @@ distance_value(MinMaxLen* mm)
|
|||
{
|
||||
/* 1000 / (min-max-dist + 1) */
|
||||
static const short int dist_vals[] = {
|
||||
1000, 500, 333, 250, 200, 167, 143, 125, 111, 100,
|
||||
91, 83, 77, 71, 67, 63, 59, 56, 53, 50,
|
||||
48, 45, 43, 42, 40, 38, 37, 36, 34, 33,
|
||||
32, 31, 30, 29, 29, 28, 27, 26, 26, 25,
|
||||
24, 24, 23, 23, 22, 22, 21, 21, 20, 20,
|
||||
20, 19, 19, 19, 18, 18, 18, 17, 17, 17,
|
||||
16, 16, 16, 16, 15, 15, 15, 15, 14, 14,
|
||||
14, 14, 14, 14, 13, 13, 13, 13, 13, 13,
|
||||
12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
|
||||
1000, 500, 333, 250, 200, 167, 143, 125, 111, 100,
|
||||
91, 83, 77, 71, 67, 63, 59, 56, 53, 50,
|
||||
48, 45, 43, 42, 40, 38, 37, 36, 34, 33,
|
||||
32, 31, 30, 29, 29, 28, 27, 26, 26, 25,
|
||||
24, 24, 23, 23, 22, 22, 21, 21, 20, 20,
|
||||
20, 19, 19, 19, 18, 18, 18, 17, 17, 17,
|
||||
16, 16, 16, 16, 15, 15, 15, 15, 14, 14,
|
||||
14, 14, 14, 14, 13, 13, 13, 13, 13, 13,
|
||||
12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
|
||||
11, 11, 11, 11, 11, 10, 10, 10, 10, 10
|
||||
};
|
||||
|
||||
|
@ -4899,7 +4899,7 @@ set_optimize_exact_info(regex_t* reg, OptExactInfo* e)
|
|||
reg->exact = str_dup(e->s, e->s + e->len);
|
||||
CHECK_NULL_RETURN_MEMERR(reg->exact);
|
||||
reg->exact_end = reg->exact + e->len;
|
||||
|
||||
|
||||
allow_reverse =
|
||||
ONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);
|
||||
|
||||
|
@ -5938,7 +5938,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
|
|||
p_len_string(f, len, 1, bp);
|
||||
bp += len;
|
||||
break;
|
||||
|
||||
|
||||
case OP_EXACTMB2N1:
|
||||
p_string(f, 2, bp); bp += 2; break;
|
||||
case OP_EXACTMB2N2:
|
||||
|
@ -5958,7 +5958,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
|
|||
case OP_EXACTMBN:
|
||||
{
|
||||
int mb_len;
|
||||
|
||||
|
||||
GET_LENGTH_INC(mb_len, bp);
|
||||
GET_LENGTH_INC(len, bp);
|
||||
fprintf(f, ":%d:%d:", mb_len, len);
|
||||
|
|
4
regenc.c
4
regenc.c
|
@ -123,7 +123,7 @@ onigenc_strlen(OnigEncoding enc, const UChar* p, const UChar* end)
|
|||
{
|
||||
int n = 0;
|
||||
UChar* q = (UChar* )p;
|
||||
|
||||
|
||||
while (q < end) {
|
||||
q += ONIGENC_MBC_ENC_LEN(enc, q, end);
|
||||
n++;
|
||||
|
@ -137,7 +137,7 @@ onigenc_strlen_null(OnigEncoding enc, const UChar* s)
|
|||
int n = 0;
|
||||
UChar* p = (UChar* )s;
|
||||
UChar* e = p + strlen((const char *)s);
|
||||
|
||||
|
||||
while (1) {
|
||||
if (*p == '\0') {
|
||||
UChar* q;
|
||||
|
|
|
@ -251,7 +251,7 @@ onig_error_code_to_str(UChar* s, int code, ...)
|
|||
onig_error_code_to_str(s, code, va_alist)
|
||||
UChar* s;
|
||||
int code;
|
||||
va_dcl
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
UChar *p, *q;
|
||||
|
|
14
regexec.c
14
regexec.c
|
@ -220,13 +220,13 @@ static int
|
|||
onig_region_resize_clear(OnigRegion* region, int n)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
||||
r = onig_region_resize(region, n);
|
||||
if (r != 0) return r;
|
||||
onig_region_clear(region);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
extern int
|
||||
onig_region_set(OnigRegion* region, int at, int beg, int end)
|
||||
{
|
||||
|
@ -236,7 +236,7 @@ onig_region_set(OnigRegion* region, int at, int beg, int end)
|
|||
int r = onig_region_resize(region, at + 1);
|
||||
if (r < 0) return r;
|
||||
}
|
||||
|
||||
|
||||
region->beg[at] = beg;
|
||||
region->end[at] = end;
|
||||
return 0;
|
||||
|
@ -2149,7 +2149,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
|||
int len;
|
||||
UChar *pstart, *pend;
|
||||
|
||||
/* if you want to remove following line,
|
||||
/* if you want to remove following line,
|
||||
you should check in parse and compile time. */
|
||||
if (mem > num_mem) goto fail;
|
||||
if (mem_end_stk[mem] == INVALID_STACK_INDEX) goto fail;
|
||||
|
@ -2181,7 +2181,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
|||
int len;
|
||||
UChar *pstart, *pend;
|
||||
|
||||
/* if you want to remove following line,
|
||||
/* if you want to remove following line,
|
||||
you should check in parse and compile time. */
|
||||
if (mem > num_mem) goto fail;
|
||||
if (mem_end_stk[mem] == INVALID_STACK_INDEX) goto fail;
|
||||
|
@ -2310,7 +2310,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
|||
MOP_OUT;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -2987,7 +2987,7 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end,
|
|||
static int
|
||||
set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED,
|
||||
int** skip)
|
||||
|
||||
|
||||
{
|
||||
int i, len;
|
||||
|
||||
|
|
16
regparse.c
16
regparse.c
|
@ -50,7 +50,7 @@ const OnigSyntaxType OnigSyntaxRuby = {
|
|||
ONIG_SYN_OP2_CCLASS_SET_OP | ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL |
|
||||
ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META | ONIG_SYN_OP2_ESC_V_VTAB |
|
||||
ONIG_SYN_OP2_ESC_H_XDIGIT )
|
||||
, ( SYN_GNU_REGEX_BV |
|
||||
, ( SYN_GNU_REGEX_BV |
|
||||
ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV |
|
||||
ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND |
|
||||
ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
|
||||
|
@ -2658,7 +2658,7 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
|
|||
}
|
||||
else {
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
is_num = 0;
|
||||
is_num = 0;
|
||||
}
|
||||
}
|
||||
else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
|
||||
|
@ -2846,7 +2846,7 @@ find_str_position(OnigCodePoint s[], int n, UChar* from, UChar* to,
|
|||
OnigCodePoint x;
|
||||
UChar *q;
|
||||
UChar *p = from;
|
||||
|
||||
|
||||
while (p < to) {
|
||||
x = ONIGENC_MBC_TO_CODE(enc, p, to);
|
||||
q = p + enclen(enc, p, to);
|
||||
|
@ -3407,7 +3407,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
|
|||
goto skip_backref;
|
||||
}
|
||||
|
||||
if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_DECIMAL_BACKREF) &&
|
||||
if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_DECIMAL_BACKREF) &&
|
||||
(num <= env->num_mem || num <= 9)) { /* This spec. from GNU regex */
|
||||
if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {
|
||||
if (num > env->num_mem || IS_NULL(SCANENV_MEM_NODES(env)[num]))
|
||||
|
@ -4388,7 +4388,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end,
|
|||
CC_ESC_WARN(env, (UChar* )"-");
|
||||
goto range_end_val;
|
||||
}
|
||||
|
||||
|
||||
if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC)) {
|
||||
CC_ESC_WARN(env, (UChar* )"-");
|
||||
goto sb_char; /* [0-9-a] is allowed as [0-9\-a] */
|
||||
|
@ -5073,7 +5073,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
|
|||
r = parse_subexp(&target, tok, term, src, end, env);
|
||||
env->option = prev;
|
||||
if (r < 0) return r;
|
||||
NENCLOSE(*np)->target = target;
|
||||
NENCLOSE(*np)->target = target;
|
||||
return tok->type;
|
||||
}
|
||||
break;
|
||||
|
@ -5241,7 +5241,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
|
|||
xmemcpy(new_key, &key, sizeof(type_cclass_key));
|
||||
onig_st_add_direct(OnigTypeCClassTable, (st_data_t )new_key,
|
||||
(st_data_t )*np);
|
||||
|
||||
|
||||
THREAD_ATOMIC_END;
|
||||
}
|
||||
else {
|
||||
|
@ -5387,7 +5387,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
|
|||
NQTFR(qn)->greedy = tok->u.repeat.greedy;
|
||||
r = set_quantifier(qn, *targetp, group, env);
|
||||
if (r < 0) return r;
|
||||
|
||||
|
||||
if (tok->u.repeat.possessive != 0) {
|
||||
Node* en;
|
||||
en = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
|
||||
|
|
|
@ -67,8 +67,8 @@ const OnigSyntaxType OnigSyntaxPosixExtended = {
|
|||
ONIG_SYN_OP_BRACE_INTERVAL |
|
||||
ONIG_SYN_OP_PLUS_ONE_INF | ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_VBAR_ALT )
|
||||
, 0
|
||||
, ( ONIG_SYN_CONTEXT_INDEP_ANCHORS |
|
||||
ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS |
|
||||
, ( ONIG_SYN_CONTEXT_INDEP_ANCHORS |
|
||||
ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS |
|
||||
ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP |
|
||||
ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
|
||||
, ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
|
||||
|
|
8
signal.c
8
signal.c
|
@ -306,14 +306,14 @@ ruby_default_signal(int sig)
|
|||
/*
|
||||
* call-seq:
|
||||
* Process.kill(signal, pid, ...) => fixnum
|
||||
*
|
||||
*
|
||||
* Sends the given signal to the specified process id(s), or to the
|
||||
* current process if _pid_ is zero. _signal_ may be an
|
||||
* integer signal number or a POSIX signal name (either with or without
|
||||
* a +SIG+ prefix). If _signal_ is negative (or starts
|
||||
* with a minus sign), kills process groups instead of
|
||||
* processes. Not all signals are available on all platforms.
|
||||
*
|
||||
*
|
||||
* pid = fork do
|
||||
* Signal.trap("HUP") { puts "Ouch!"; exit }
|
||||
* # ... do some work ...
|
||||
|
@ -321,9 +321,9 @@ ruby_default_signal(int sig)
|
|||
* # ...
|
||||
* Process.kill("HUP", pid)
|
||||
* Process.wait
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Ouch!
|
||||
*/
|
||||
|
||||
|
|
22
sprintf.c
22
sprintf.c
|
@ -31,7 +31,7 @@ static char*
|
|||
remove_sign_bits(char *str, int base)
|
||||
{
|
||||
char *s, *t;
|
||||
|
||||
|
||||
s = t = str;
|
||||
|
||||
if (base == 16) {
|
||||
|
@ -171,10 +171,10 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
|||
* call-seq:
|
||||
* format(format_string [, arguments...] ) => string
|
||||
* sprintf(format_string [, arguments...] ) => string
|
||||
*
|
||||
*
|
||||
* Returns the string resulting from applying <i>format_string</i> to
|
||||
* any additional arguments. Within the format string, any characters
|
||||
* other than format sequences are copied to the result.
|
||||
* other than format sequences are copied to the result.
|
||||
*
|
||||
* The syntax of a format sequence is follows.
|
||||
*
|
||||
|
@ -210,13 +210,13 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
|||
*
|
||||
* Field | Float Format
|
||||
* ------+--------------------------------------------------------------
|
||||
* e | Convert floating point argument into exponential notation
|
||||
* e | Convert floating point argument into exponential notation
|
||||
* | with one digit before the decimal point as [-]d.dddddde[+-]dd.
|
||||
* | The precision specifies the number of digits after the decimal
|
||||
* | point (defaulting to six).
|
||||
* E | Equivalent to `e', but uses an uppercase E to indicate
|
||||
* | the exponent.
|
||||
* f | Convert floating point argument as [-]ddd.dddddd,
|
||||
* f | Convert floating point argument as [-]ddd.dddddd,
|
||||
* | where the precision specifies the number of digits after
|
||||
* | the decimal point.
|
||||
* g | Convert a floating point number using exponential form
|
||||
|
@ -234,13 +234,13 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
|||
* | sequence contains a precision, at most that many characters
|
||||
* | will be copied.
|
||||
* % | A percent sign itself will be displayed. No argument taken.
|
||||
*
|
||||
*
|
||||
* The flags modifies the behavior of the formats.
|
||||
* The flag characters are:
|
||||
*
|
||||
* Flag | Applies to | Meaning
|
||||
* ---------+---------------+-----------------------------------------
|
||||
* space | bBdiouxX | Leave a space at the start of
|
||||
* space | bBdiouxX | Leave a space at the start of
|
||||
* | eEfgG | non-negative numbers.
|
||||
* | (numeric fmt) | For `o', `x', `X', `b' and `B', use
|
||||
* | | a minus sign with absolute value for
|
||||
|
@ -276,9 +276,9 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
|||
* | (numeric fmt) | is used for negative numbers formatted as
|
||||
* | | complements.
|
||||
* ---------+---------------+-----------------------------------------
|
||||
* * | all | Use the next argument as the field width.
|
||||
* * | all | Use the next argument as the field width.
|
||||
* | | If negative, left-justify the result. If the
|
||||
* | | asterisk is followed by a number and a dollar
|
||||
* | | asterisk is followed by a number and a dollar
|
||||
* | | sign, use the indicated argument as the width.
|
||||
*
|
||||
* Examples of flags:
|
||||
|
@ -336,7 +336,7 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
|||
* sprintf("%#g", 123.4) #=> "123.400"
|
||||
* sprintf("%g", 123456) #=> "123456"
|
||||
* sprintf("%#g", 123456) #=> "123456."
|
||||
*
|
||||
*
|
||||
* The field width is an optional integer, followed optionally by a
|
||||
* period and a precision. The width specifies the minimum number of
|
||||
* characters that will be written to the result for this field.
|
||||
|
@ -389,7 +389,7 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
|||
* # precision for `e' is number of
|
||||
* # digits after the decimal point <------>
|
||||
* sprintf("%20.8e", 1234.56789) #=> " 1.23456789e+03"
|
||||
*
|
||||
*
|
||||
* # precision for `f' is number of
|
||||
* # digits after the decimal point <------>
|
||||
* sprintf("%20.8f", 1234.56789) #=> " 1234.56789000"
|
||||
|
|
|
@ -465,7 +465,7 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
|
|||
/*
|
||||
* From: Chip Rosenthal <chip@chinacat.unicom.com>
|
||||
* Date: Sun, 19 Mar 1995 00:33:29 -0600 (CST)
|
||||
*
|
||||
*
|
||||
* Warning: the %z [code] is implemented by inspecting the
|
||||
* timezone name conditional compile settings, and
|
||||
* inferring a method to get timezone offsets. I've tried
|
||||
|
|
70
struct.c
70
struct.c
|
@ -76,10 +76,10 @@ rb_struct_s_members_m(VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* struct.members => array
|
||||
*
|
||||
*
|
||||
* Returns an array of strings representing the names of the instance
|
||||
* variables.
|
||||
*
|
||||
*
|
||||
* Customer = Struct.new(:name, :address, :zip)
|
||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
* joe.members #=> [:name, :address, :zip]
|
||||
|
@ -293,7 +293,7 @@ rb_struct_define(const char *name, ...)
|
|||
* <code>Struct</code>s in the system and should start with a capital
|
||||
* letter. Assigning a structure class to a constant effectively gives
|
||||
* the class the name of the constant.
|
||||
*
|
||||
*
|
||||
* <code>Struct::new</code> returns a new <code>Class</code> object,
|
||||
* which can then be used to create specific instances of the new
|
||||
* structure. The number of actual parameters must be
|
||||
|
@ -302,12 +302,12 @@ rb_struct_define(const char *name, ...)
|
|||
* parameters will raise an \E{ArgumentError}.
|
||||
*
|
||||
* The remaining methods listed in this section (class and instance)
|
||||
* are defined for this generated class.
|
||||
*
|
||||
* are defined for this generated class.
|
||||
*
|
||||
* # Create a structure with a name in Struct
|
||||
* Struct.new("Customer", :name, :address) #=> Struct::Customer
|
||||
* Struct::Customer.new("Dave", "123 Main") #=> #<struct Struct::Customer name="Dave", address="123 Main">
|
||||
*
|
||||
*
|
||||
* # Create a structure named by its constant
|
||||
* Customer = Struct.new(:name, :address) #=> Customer
|
||||
* Customer.new("Dave", "123 Main") #=> #<struct Customer name="Dave", address="123 Main">
|
||||
|
@ -426,16 +426,16 @@ rb_struct_new(VALUE klass, ...)
|
|||
/*
|
||||
* call-seq:
|
||||
* struct.each {|obj| block } => struct
|
||||
*
|
||||
*
|
||||
* Calls <i>block</i> once for each instance variable, passing the
|
||||
* value as a parameter.
|
||||
*
|
||||
*
|
||||
* Customer = Struct.new(:name, :address, :zip)
|
||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
* joe.each {|x| puts(x) }
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Joe Smith
|
||||
* 123 Maple, Anytown NC
|
||||
* 12345
|
||||
|
@ -456,16 +456,16 @@ rb_struct_each(VALUE s)
|
|||
/*
|
||||
* call-seq:
|
||||
* struct.each_pair {|sym, obj| block } => struct
|
||||
*
|
||||
*
|
||||
* Calls <i>block</i> once for each instance variable, passing the name
|
||||
* (as a symbol) and the value as parameters.
|
||||
*
|
||||
*
|
||||
* Customer = Struct.new(:name, :address, :zip)
|
||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
* joe.each_pair {|name, value| puts("#{name} => #{value}") }
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* name => Joe Smith
|
||||
* address => 123 Maple, Anytown NC
|
||||
* zip => 12345
|
||||
|
@ -545,9 +545,9 @@ rb_struct_inspect(VALUE s)
|
|||
* call-seq:
|
||||
* struct.to_a => array
|
||||
* struct.values => array
|
||||
*
|
||||
*
|
||||
* Returns the values for this instance as an array.
|
||||
*
|
||||
*
|
||||
* Customer = Struct.new(:name, :address, :zip)
|
||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
* joe.to_a[1] #=> "123 Maple, Anytown NC"
|
||||
|
@ -596,17 +596,17 @@ rb_struct_aref_id(VALUE s, ID id)
|
|||
/*
|
||||
* call-seq:
|
||||
* struct[symbol] => anObject
|
||||
* struct[fixnum] => anObject
|
||||
*
|
||||
* struct[fixnum] => anObject
|
||||
*
|
||||
* Attribute Reference---Returns the value of the instance variable
|
||||
* named by <i>symbol</i>, or indexed (0..length-1) by
|
||||
* <i>fixnum</i>. Will raise <code>NameError</code> if the named
|
||||
* variable does not exist, or <code>IndexError</code> if the index is
|
||||
* out of range.
|
||||
*
|
||||
*
|
||||
* Customer = Struct.new(:name, :address, :zip)
|
||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
*
|
||||
*
|
||||
* joe["name"] #=> "Joe Smith"
|
||||
* joe[:name] #=> "Joe Smith"
|
||||
* joe[0] #=> "Joe Smith"
|
||||
|
@ -658,19 +658,19 @@ rb_struct_aset_id(VALUE s, ID id, VALUE val)
|
|||
* call-seq:
|
||||
* struct[symbol] = obj => obj
|
||||
* struct[fixnum] = obj => obj
|
||||
*
|
||||
*
|
||||
* Attribute Assignment---Assigns to the instance variable named by
|
||||
* <i>symbol</i> or <i>fixnum</i> the value <i>obj</i> and
|
||||
* returns it. Will raise a <code>NameError</code> if the named
|
||||
* variable does not exist, or an <code>IndexError</code> if the index
|
||||
* is out of range.
|
||||
*
|
||||
*
|
||||
* Customer = Struct.new(:name, :address, :zip)
|
||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
*
|
||||
*
|
||||
* joe["name"] = "Luke"
|
||||
* joe[:zip] = "90210"
|
||||
*
|
||||
*
|
||||
* joe.name #=> "Luke"
|
||||
* joe.zip #=> "90210"
|
||||
*/
|
||||
|
@ -704,15 +704,15 @@ struct_entry(VALUE s, long n)
|
|||
return rb_struct_aref(s, LONG2NUM(n));
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* call-seq:
|
||||
* struct.values_at(selector,... ) => an_array
|
||||
*
|
||||
* Returns an array containing the elements in
|
||||
* _self_ corresponding to the given selector(s). The selectors
|
||||
* may be either integer indices or ranges.
|
||||
* may be either integer indices or ranges.
|
||||
* See also </code>.select<code>.
|
||||
*
|
||||
*
|
||||
* a = %w{ a b c d e f }
|
||||
* a.values_at(1, 3, 5)
|
||||
* a.values_at(1, 3, 5, 7)
|
||||
|
@ -729,12 +729,12 @@ rb_struct_values_at(int argc, VALUE *argv, VALUE s)
|
|||
/*
|
||||
* call-seq:
|
||||
* struct.select {|i| block } => array
|
||||
*
|
||||
*
|
||||
* Invokes the block passing in successive elements from
|
||||
* <i>struct</i>, returning an array containing those elements
|
||||
* for which the block returns a true value (equivalent to
|
||||
* <code>Enumerable#select</code>).
|
||||
*
|
||||
*
|
||||
* Lots = Struct.new(:a, :b, :c, :d, :e, :f)
|
||||
* l = Lots.new(11, 22, 33, 44, 55, 66)
|
||||
* l.select {|v| (v % 2).zero? } #=> [22, 44, 66]
|
||||
|
@ -762,12 +762,12 @@ rb_struct_select(int argc, VALUE *argv, VALUE s)
|
|||
/*
|
||||
* call-seq:
|
||||
* struct == other_struct => true or false
|
||||
*
|
||||
*
|
||||
* Equality---Returns <code>true</code> if <i>other_struct</i> is
|
||||
* equal to this one: they must be of the same class as generated by
|
||||
* <code>Struct::new</code>, and the values of all instance variables
|
||||
* must be equal (according to <code>Object#==</code>).
|
||||
*
|
||||
*
|
||||
* Customer = Struct.new(:name, :address, :zip)
|
||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
* joejr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
|
@ -847,9 +847,9 @@ rb_struct_eql(VALUE s, VALUE s2)
|
|||
* call-seq:
|
||||
* struct.length => fixnum
|
||||
* struct.size => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the number of instance variables.
|
||||
*
|
||||
*
|
||||
* Customer = Struct.new(:name, :address, :zip)
|
||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||
* joe.length #=> 3
|
||||
|
@ -865,13 +865,13 @@ rb_struct_size(VALUE s)
|
|||
* A <code>Struct</code> is a convenient way to bundle a number of
|
||||
* attributes together, using accessor methods, without having to write
|
||||
* an explicit class.
|
||||
*
|
||||
*
|
||||
* The <code>Struct</code> class is a generator of specific classes,
|
||||
* each one of which is defined to hold a set of variables and their
|
||||
* accessors. In these examples, we'll call the generated class
|
||||
* ``<i>Customer</i>Class,'' and we'll show an example instance of that
|
||||
* class as ``<i>Customer</i>Inst.''
|
||||
*
|
||||
*
|
||||
* In the descriptions that follow, the parameter <i>symbol</i> refers
|
||||
* to a symbol, which is either a quoted string or a
|
||||
* <code>Symbol</code> (such as <code>:name</code>).
|
||||
|
|
158
time.c
158
time.c
|
@ -74,18 +74,18 @@ time_modify(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* Time.new -> time
|
||||
*
|
||||
*
|
||||
* Returns a <code>Time</code> object initialized to the current system
|
||||
* time. <b>Note:</b> The object created will be created using the
|
||||
* resolution available on your system clock, and so may include
|
||||
* fractional seconds.
|
||||
*
|
||||
*
|
||||
* a = Time.new #=> 2007-11-19 07:50:02 -0600
|
||||
* b = Time.new #=> 2007-11-19 07:50:02 -0600
|
||||
* a == b #=> false
|
||||
* "%.6f" % a.to_f #=> "1195480202.282373"
|
||||
* "%.6f" % b.to_f #=> "1195480202.283415"
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -104,7 +104,7 @@ time_init(VALUE time)
|
|||
}
|
||||
#else
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timeval tv;
|
||||
if (gettimeofday(&tv, 0) < 0) {
|
||||
rb_sys_fail("gettimeofday");
|
||||
}
|
||||
|
@ -297,14 +297,14 @@ rb_time_timespec(VALUE time)
|
|||
* Time.at(time) => time
|
||||
* Time.at(seconds_with_frac) => time
|
||||
* Time.at(seconds, microseconds_with_frac) => time
|
||||
*
|
||||
*
|
||||
* Creates a new time object with the value given by <i>time</i>,
|
||||
* the given number of <i>seconds_with_frac</i>, or
|
||||
* <i>seconds</i> and <i>microseconds_with_frac</i> from the Epoch.
|
||||
* <i>seconds_with_frac</i> and <i>microseconds_with_frac</i>
|
||||
* can be Integer, Float, Rational, or other Numeric.
|
||||
* non-portable feature allows the offset to be negative on some systems.
|
||||
*
|
||||
*
|
||||
* Time.at(0) #=> 1969-12-31 18:00:00 -0600
|
||||
* Time.at(Time.at(0)) #=> 1969-12-31 18:00:00 -0600
|
||||
* Time.at(946702800) #=> 1999-12-31 23:00:00 -0600
|
||||
|
@ -667,7 +667,7 @@ search_time_t(struct tm *tptr, int utc_p)
|
|||
|
||||
To avoid overflow in this assignment, `d' is restricted to less than
|
||||
sqrt(2**31). By this restriction and other reasons, the guess is
|
||||
not accurate and some error is expected. `range' approximates
|
||||
not accurate and some error is expected. `range' approximates
|
||||
the maximum error.
|
||||
|
||||
When these parameters are not suitable, i.e. guess is not within
|
||||
|
@ -726,7 +726,7 @@ search_time_t(struct tm *tptr, int utc_p)
|
|||
}
|
||||
|
||||
if (guess <= guess_lo || guess_hi <= guess) {
|
||||
/* Precious guess is invalid. try binary search. */
|
||||
/* Precious guess is invalid. try binary search. */
|
||||
guess = guess_lo / 2 + guess_hi / 2;
|
||||
if (guess <= guess_lo)
|
||||
guess = guess_lo + 1;
|
||||
|
@ -738,7 +738,7 @@ search_time_t(struct tm *tptr, int utc_p)
|
|||
tm = GUESS(&guess);
|
||||
if (!tm) goto error;
|
||||
have_guess = 0;
|
||||
|
||||
|
||||
d = tmcmp(tptr, tm);
|
||||
if (d < 0) {
|
||||
guess_hi = guess;
|
||||
|
@ -922,7 +922,7 @@ time_utc_or_local(int argc, VALUE *argv, int utc_p, VALUE klass)
|
|||
* Time.gm(year, month, day, hour, min, sec_with_frac) => time
|
||||
* Time.gm(year, month, day, hour, min, sec, usec_with_frac) => time
|
||||
* Time.gm(sec, min, hour, day, month, year, wday, yday, isdst, tz) => time
|
||||
*
|
||||
*
|
||||
* Creates a time based on given values, interpreted as UTC (GMT). The
|
||||
* year must be specified. Other values default to the minimum value
|
||||
* for that field (and may be <code>nil</code> or omitted). Months may
|
||||
|
@ -960,10 +960,10 @@ time_s_mkutc(int argc, VALUE *argv, VALUE klass)
|
|||
* Time.mktime(year, month, day, hour, min, sec_with_frac) => time
|
||||
* Time.mktime(year, month, day, hour, min, sec, usec_with_frac) => time
|
||||
* Time.mktime(sec, min, hour, day, month, year, wday, yday, isdst, tz) => time
|
||||
*
|
||||
*
|
||||
* Same as <code>Time::gm</code>, but interprets the values in the
|
||||
* local time zone.
|
||||
*
|
||||
*
|
||||
* Time.local(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 -0600
|
||||
*/
|
||||
|
||||
|
@ -977,10 +977,10 @@ time_s_mktime(int argc, VALUE *argv, VALUE klass)
|
|||
* call-seq:
|
||||
* time.to_i => int
|
||||
* time.tv_sec => int
|
||||
*
|
||||
*
|
||||
* Returns the value of <i>time</i> as an integer number of seconds
|
||||
* since the Epoch.
|
||||
*
|
||||
*
|
||||
* t = Time.now
|
||||
* "%10.5f" % t.to_f #=> "1049896564.17839"
|
||||
* t.to_i #=> 1049896564
|
||||
|
@ -998,10 +998,10 @@ time_to_i(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.to_f => float
|
||||
*
|
||||
*
|
||||
* Returns the value of <i>time</i> as a floating point number of
|
||||
* seconds since the Epoch.
|
||||
*
|
||||
*
|
||||
* t = Time.now
|
||||
* "%10.5f" % t.to_f #=> "1049896564.13654"
|
||||
* t.to_i #=> 1049896564
|
||||
|
@ -1023,9 +1023,9 @@ time_to_f(VALUE time)
|
|||
* call-seq:
|
||||
* time.usec => int
|
||||
* time.tv_usec => int
|
||||
*
|
||||
*
|
||||
* Returns just the number of microseconds for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:03:26 -0600
|
||||
* "%10.6f" % t.to_f #=> "1195481006.775195"
|
||||
* t.usec #=> 775195
|
||||
|
@ -1044,9 +1044,9 @@ time_usec(VALUE time)
|
|||
* call-seq:
|
||||
* time.nsec => int
|
||||
* time.tv_nsec => int
|
||||
*
|
||||
*
|
||||
* Returns just the number of nanoseconds for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-17 15:18:03 +0900
|
||||
* "%10.9f" % t.to_f #=> "1195280283.536151409"
|
||||
* t.nsec #=> 536151406
|
||||
|
@ -1068,15 +1068,15 @@ time_nsec(VALUE time)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* time <=> other_time => -1, 0, +1
|
||||
*
|
||||
* time <=> other_time => -1, 0, +1
|
||||
*
|
||||
* Comparison---Compares <i>time</i> with <i>other_time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:12:12 -0600
|
||||
* t2 = t + 2592000 #=> 2007-12-19 08:12:12 -0600
|
||||
* t <=> t2 #=> -1
|
||||
* t2 <=> t #=> 1
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:13:38 -0600
|
||||
* t2 = t + 0.1 #=> 2007-11-19 08:13:38 -0600
|
||||
* t.nsec #=> 98222999
|
||||
|
@ -1144,10 +1144,10 @@ time_eql(VALUE time1, VALUE time2)
|
|||
* call-seq:
|
||||
* time.utc? => true or false
|
||||
* time.gmt? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> represents a time in UTC
|
||||
* (GMT).
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:15:23 -0600
|
||||
* t.utc? #=> false
|
||||
* t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
||||
|
@ -1216,10 +1216,10 @@ time_dup(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.localtime => time
|
||||
*
|
||||
*
|
||||
* Converts <i>time</i> to local time (using the local time zone in
|
||||
* effect for this process) modifying the receiver.
|
||||
*
|
||||
*
|
||||
* t = Time.gm(2000, "jan", 1, 20, 15, 1) #=> 2000-01-01 20:15:01 UTC
|
||||
* t.gmt? #=> true
|
||||
* t.localtime #=> 2000-01-01 14:15:01 -0600
|
||||
|
@ -1256,9 +1256,9 @@ time_localtime(VALUE time)
|
|||
* call-seq:
|
||||
* time.gmtime => time
|
||||
* time.utc => time
|
||||
*
|
||||
*
|
||||
* Converts <i>time</i> to UTC (GMT), modifying the receiver.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:18:31 -0600
|
||||
* t.gmt? #=> false
|
||||
* t.gmtime #=> 2007-11-19 14:18:31 UTC
|
||||
|
@ -1299,10 +1299,10 @@ time_gmtime(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.getlocal => new_time
|
||||
*
|
||||
*
|
||||
* Returns a new <code>new_time</code> object representing <i>time</i> in
|
||||
* local time (using the local time zone in effect for this process).
|
||||
*
|
||||
*
|
||||
* t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
||||
* t.gmt? #=> true
|
||||
* l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
||||
|
@ -1320,10 +1320,10 @@ time_getlocaltime(VALUE time)
|
|||
* call-seq:
|
||||
* time.getgm => new_time
|
||||
* time.getutc => new_time
|
||||
*
|
||||
*
|
||||
* Returns a new <code>new_time</code> object representing <i>time</i> in
|
||||
* UTC.
|
||||
*
|
||||
*
|
||||
* t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
|
||||
* t.gmt? #=> false
|
||||
* y = t.getgm #=> 2000-01-02 02:15:01 UTC
|
||||
|
@ -1348,9 +1348,9 @@ time_get_tm(VALUE time, int gmt)
|
|||
* call-seq:
|
||||
* time.asctime => string
|
||||
* time.ctime => string
|
||||
*
|
||||
*
|
||||
* Returns a canonical string representation of <i>time</i>.
|
||||
*
|
||||
*
|
||||
* Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
|
||||
*/
|
||||
|
||||
|
@ -1383,14 +1383,14 @@ rb_strftime(char *s, size_t maxsize, const char *format,
|
|||
* call-seq:
|
||||
* time.inspect => string
|
||||
* time.to_s => string
|
||||
*
|
||||
*
|
||||
* Returns a string representing <i>time</i>. Equivalent to calling
|
||||
* <code>Time#strftime</code> with a format string of
|
||||
* ``<code>%Y-%m-%d</code> <code>%H:%M:%S</code> <code>%z</code>''
|
||||
* for a local time and
|
||||
* ``<code>%Y-%m-%d</code> <code>%H:%M:%S</code> <code>UTC</code>''
|
||||
* for a UTC time.
|
||||
*
|
||||
*
|
||||
* Time.now.to_s #=> "2007-10-05 16:09:51 +0900"
|
||||
* Time.now.utc.to_s #=> "2007-10-05 07:09:51 UTC"
|
||||
*/
|
||||
|
@ -1461,10 +1461,10 @@ time_add(struct time_object *tobj, VALUE offset, int sign)
|
|||
/*
|
||||
* call-seq:
|
||||
* time + numeric => time
|
||||
*
|
||||
*
|
||||
* Addition---Adds some number of seconds (possibly fractional) to
|
||||
* <i>time</i> and returns that value as a new time.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:22:21 -0600
|
||||
* t + (60 * 60 * 24) #=> 2007-11-20 08:22:21 -0600
|
||||
*/
|
||||
|
@ -1485,11 +1485,11 @@ time_plus(VALUE time1, VALUE time2)
|
|||
* call-seq:
|
||||
* time - other_time => float
|
||||
* time - numeric => time
|
||||
*
|
||||
*
|
||||
* Difference---Returns a new time that represents the difference
|
||||
* between two times, or subtracts the given number of seconds in
|
||||
* <i>numeric</i> from <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:23:10 -0600
|
||||
* t2 = t + 2592000 #=> 2007-12-19 08:23:10 -0600
|
||||
* t2 - t #=> 2592000.0
|
||||
|
@ -1551,12 +1551,12 @@ rb_time_succ(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.sec => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the second of the minute (0..60)<em>[Yes, seconds really can
|
||||
* range from zero to 60. This allows the system to inject leap seconds
|
||||
* every now and then to correct for the fact that years are not really
|
||||
* a convenient number of hours long.]</em> for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:25:02 -0600
|
||||
* t.sec #=> 2
|
||||
*/
|
||||
|
@ -1576,9 +1576,9 @@ time_sec(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.min => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the minute of the hour (0..59) for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:25:51 -0600
|
||||
* t.min #=> 25
|
||||
*/
|
||||
|
@ -1598,9 +1598,9 @@ time_min(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.hour => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the hour of the day (0..23) for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:26:20 -0600
|
||||
* t.hour #=> 8
|
||||
*/
|
||||
|
@ -1621,9 +1621,9 @@ time_hour(VALUE time)
|
|||
* call-seq:
|
||||
* time.day => fixnum
|
||||
* time.mday => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the day of the month (1..n) for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:27:03 -0600
|
||||
* t.day #=> 19
|
||||
* t.mday #=> 19
|
||||
|
@ -1645,9 +1645,9 @@ time_mday(VALUE time)
|
|||
* call-seq:
|
||||
* time.mon => fixnum
|
||||
* time.month => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the month of the year (1..12) for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:27:30 -0600
|
||||
* t.mon #=> 11
|
||||
* t.month #=> 11
|
||||
|
@ -1668,9 +1668,9 @@ time_mon(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.year => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the year for <i>time</i> (including the century).
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:27:51 -0600
|
||||
* t.year #=> 2007
|
||||
*/
|
||||
|
@ -1690,10 +1690,10 @@ time_year(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.wday => fixnum
|
||||
*
|
||||
*
|
||||
* Returns an integer representing the day of the week, 0..6, with
|
||||
* Sunday == 0.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-20 02:35:35 -0600
|
||||
* t.wday #=> 2
|
||||
* t.sunday? #=> false
|
||||
|
@ -1729,9 +1729,9 @@ time_wday(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.sunday? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> represents Sunday.
|
||||
*
|
||||
*
|
||||
* t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600
|
||||
* t.sunday? #=> true
|
||||
*/
|
||||
|
@ -1745,7 +1745,7 @@ time_sunday(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.monday? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> represents Monday.
|
||||
*
|
||||
* t = Time.local(2003, 8, 4) #=> 2003-08-04 00:00:00 -0500
|
||||
|
@ -1761,7 +1761,7 @@ time_monday(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.tuesday? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> represents Tuesday.
|
||||
*
|
||||
* t = Time.local(1991, 2, 19) #=> 1991-02-19 00:00:00 -0600
|
||||
|
@ -1777,7 +1777,7 @@ time_tuesday(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.wednesday? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> represents Wednesday.
|
||||
*
|
||||
* t = Time.local(1993, 2, 24) #=> 1993-02-24 00:00:00 -0600
|
||||
|
@ -1793,7 +1793,7 @@ time_wednesday(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.thursday? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> represents Thursday.
|
||||
*
|
||||
* t = Time.local(1995, 12, 21) #=> 1995-12-21 00:00:00 -0600
|
||||
|
@ -1809,7 +1809,7 @@ time_thursday(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.friday? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> represents Friday.
|
||||
*
|
||||
* t = Time.local(1987, 12, 18) #=> 1987-12-18 00:00:00 -0600
|
||||
|
@ -1825,7 +1825,7 @@ time_friday(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.saturday? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> represents Saturday.
|
||||
*
|
||||
* t = Time.local(2006, 6, 10) #=> 2006-06-10 00:00:00 -0500
|
||||
|
@ -1841,9 +1841,9 @@ time_saturday(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.yday => fixnum
|
||||
*
|
||||
*
|
||||
* Returns an integer representing the day of the year, 1..366.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:32:31 -0600
|
||||
* t.yday #=> 323
|
||||
*/
|
||||
|
@ -1864,10 +1864,10 @@ time_yday(VALUE time)
|
|||
* call-seq:
|
||||
* time.isdst => true or false
|
||||
* time.dst? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>time</i> occurs during Daylight
|
||||
* Saving Time in its time zone.
|
||||
*
|
||||
*
|
||||
* # CST6CDT:
|
||||
* Time.local(2000, 1, 1).zone #=> "CST"
|
||||
* Time.local(2000, 1, 1).isdst #=> false
|
||||
|
@ -1900,10 +1900,10 @@ time_isdst(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.zone => string
|
||||
*
|
||||
*
|
||||
* Returns the name of the time zone used for <i>time</i>. As of Ruby
|
||||
* 1.8, returns ``UTC'' rather than ``GMT'' for UTC times.
|
||||
*
|
||||
*
|
||||
* t = Time.gm(2000, "jan", 1, 20, 15, 1)
|
||||
* t.zone #=> "UTC"
|
||||
* t = Time.local(2000, "jan", 1, 20, 15, 1)
|
||||
|
@ -1918,7 +1918,7 @@ time_zone(VALUE time)
|
|||
char buf[64];
|
||||
int len;
|
||||
#endif
|
||||
|
||||
|
||||
GetTimeval(time, tobj);
|
||||
if (tobj->tm_got == 0) {
|
||||
time_get_tm(time, tobj->gmt);
|
||||
|
@ -1943,10 +1943,10 @@ time_zone(VALUE time)
|
|||
* time.gmt_offset => fixnum
|
||||
* time.gmtoff => fixnum
|
||||
* time.utc_offset => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the offset in seconds between the timezone of <i>time</i>
|
||||
* and UTC.
|
||||
*
|
||||
*
|
||||
* t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
||||
* t.gmt_offset #=> 0
|
||||
* l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
||||
|
@ -1998,14 +1998,14 @@ time_utc_offset(VALUE time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.to_a => array
|
||||
*
|
||||
*
|
||||
* Returns a ten-element <i>array</i> of values for <i>time</i>:
|
||||
* {<code>[ sec, min, hour, day, month, year, wday, yday, isdst, zone
|
||||
* ]</code>}. See the individual methods for an explanation of the
|
||||
* valid ranges of each value. The ten elements can be passed directly
|
||||
* to <code>Time::utc</code> or <code>Time::local</code> to create a
|
||||
* new <code>Time</code>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:36:01 -0600
|
||||
* now = t.to_a #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"]
|
||||
*/
|
||||
|
@ -2067,7 +2067,7 @@ rb_strftime_alloc(char **buf, const char *format,
|
|||
/*
|
||||
* call-seq:
|
||||
* time.strftime( string ) => string
|
||||
*
|
||||
*
|
||||
* Formats <i>time</i> according to the directives in the given format
|
||||
* string. Any text not listed as a directive will be passed through
|
||||
* to the output string.
|
||||
|
@ -2107,7 +2107,7 @@ rb_strftime_alloc(char **buf, const char *format,
|
|||
* %Y - Year with century
|
||||
* %Z - Time zone name
|
||||
* %% - Literal ``%'' character
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> 2007-11-19 08:37:48 -0600
|
||||
* t.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
|
||||
* t.strftime("at %I:%M%p") #=> "at 08:37AM"
|
||||
|
@ -2247,7 +2247,7 @@ time_dump(int argc, VALUE *argv, VALUE time)
|
|||
VALUE str;
|
||||
|
||||
rb_scan_args(argc, argv, "01", 0);
|
||||
str = time_mdump(time);
|
||||
str = time_mdump(time);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
@ -2370,7 +2370,7 @@ time_load(VALUE klass, VALUE str)
|
|||
* as equivalent. GMT is the older way of referring to these
|
||||
* baseline times but persists in the names of calls on POSIX
|
||||
* systems.
|
||||
*
|
||||
*
|
||||
* All times are stored with some number of nanoseconds. Be aware of
|
||||
* this fact when comparing times with each other---times that are
|
||||
* apparently equal when displayed may be different when compared.
|
||||
|
|
20
transcode.c
20
transcode.c
|
@ -1269,13 +1269,13 @@ rb_econv_convert0(rb_econv_t *ec,
|
|||
memcpy(*output_ptr, data_start, len);
|
||||
*output_ptr += len;
|
||||
ec->elems[ec->num_trans-1].out_data_start =
|
||||
ec->elems[ec->num_trans-1].out_data_end =
|
||||
ec->elems[ec->num_trans-1].out_data_end =
|
||||
ec->elems[ec->num_trans-1].out_buf_start;
|
||||
has_output = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ec->in_buf_start &&
|
||||
if (ec->in_buf_start &&
|
||||
ec->in_data_start != ec->in_data_end) {
|
||||
res = rb_trans_conv(ec, (const unsigned char **)&ec->in_data_start, ec->in_data_end, output_ptr, output_stop,
|
||||
(flags&~ECONV_AFTER_OUTPUT)|ECONV_PARTIAL_INPUT, &result_position);
|
||||
|
@ -1519,7 +1519,7 @@ allocate_converted_string(const char *sname, const char *dname,
|
|||
|
||||
/* result: 0:success -1:failure */
|
||||
int
|
||||
rb_econv_insert_output(rb_econv_t *ec,
|
||||
rb_econv_insert_output(rb_econv_t *ec,
|
||||
const unsigned char *str, size_t len, const char *str_encoding)
|
||||
{
|
||||
const char *insert_encoding = rb_econv_encoding_to_insert_output(ec);
|
||||
|
@ -1863,7 +1863,7 @@ rb_econv_binmode(rb_econv_t *ec)
|
|||
if (entry->transcoder)
|
||||
trs[n++] = entry->transcoder;
|
||||
}
|
||||
|
||||
|
||||
num_trans = ec->num_trans;
|
||||
j = 0;
|
||||
for (i = 0; i < num_trans; i++) {
|
||||
|
@ -3107,7 +3107,7 @@ rb_econv_init_by_convpath(VALUE self, VALUE convpath,
|
|||
* p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>],
|
||||
* # "universal_newline"]
|
||||
*
|
||||
* # But, if the last encoding is ASCII incompatible,
|
||||
* # But, if the last encoding is ASCII incompatible,
|
||||
* # decorators are inserted before the last conversion.
|
||||
* ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true)
|
||||
* p ec.convpath #=> ["crlf_newline",
|
||||
|
@ -3218,7 +3218,7 @@ static VALUE
|
|||
econv_source_encoding(VALUE self)
|
||||
{
|
||||
rb_econv_t *ec = check_econv(self);
|
||||
if (!ec->source_encoding)
|
||||
if (!ec->source_encoding)
|
||||
return Qnil;
|
||||
return rb_enc_from_encoding(ec->source_encoding);
|
||||
}
|
||||
|
@ -3233,7 +3233,7 @@ static VALUE
|
|||
econv_destination_encoding(VALUE self)
|
||||
{
|
||||
rb_econv_t *ec = check_econv(self);
|
||||
if (!ec->destination_encoding)
|
||||
if (!ec->destination_encoding)
|
||||
return Qnil;
|
||||
return rb_enc_from_encoding(ec->destination_encoding);
|
||||
}
|
||||
|
@ -3638,7 +3638,7 @@ econv_finish(VALUE self)
|
|||
*
|
||||
* # \xff is invalid as EUC-JP.
|
||||
* ec = Encoding::Converter.new("EUC-JP", "Shift_JIS")
|
||||
* ec.primitive_convert(src="\xff", dst="", nil, 10)
|
||||
* ec.primitive_convert(src="\xff", dst="", nil, 10)
|
||||
* p ec.primitive_errinfo
|
||||
* #=> [:invalid_byte_sequence, "EUC-JP", "UTF-8", "\xFF", ""]
|
||||
*
|
||||
|
@ -3659,7 +3659,7 @@ econv_finish(VALUE self)
|
|||
* # Encoding::Converter::PARTIAL_INPUT prevents invalid errors by
|
||||
* # partial characters.
|
||||
* ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
||||
* ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT)
|
||||
* ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT)
|
||||
* p ec.primitive_errinfo
|
||||
* #=> [:source_buffer_empty, nil, nil, nil, nil]
|
||||
*
|
||||
|
@ -3823,7 +3823,7 @@ econv_putback(int argc, VALUE *argv, VALUE self)
|
|||
* ec.last_error -> exception or nil
|
||||
*
|
||||
* Returns an exception object for the last conversion.
|
||||
* Returns nil if the last conversion did not produce an error.
|
||||
* Returns nil if the last conversion did not produce an error.
|
||||
*
|
||||
* "error" means that
|
||||
* Encoding::InvalidByteSequenceError and Encoding::UndefinedConversionError for
|
||||
|
|
16
util.c
16
util.c
|
@ -101,7 +101,7 @@ scan_digits(const char *str, int base, size_t *retlen, int *overflow)
|
|||
*overflow = 1;
|
||||
ret *= base;
|
||||
x = ret;
|
||||
ret += d;
|
||||
ret += d;
|
||||
if (ret < x)
|
||||
*overflow = 1;
|
||||
}
|
||||
|
@ -217,11 +217,11 @@ ruby_strtoul(const char *str, char **endptr, int base)
|
|||
* Style 1: The suffix begins with a '.'. The extension is replaced.
|
||||
* If the name matches the original name, use the fallback method.
|
||||
*
|
||||
* Style 2: The suffix is a single character, not a '.'. Try to add the
|
||||
* Style 2: The suffix is a single character, not a '.'. Try to add the
|
||||
* suffix to the following places, using the first one that works.
|
||||
* [1] Append to extension.
|
||||
* [2] Append to filename,
|
||||
* [3] Replace end of extension,
|
||||
* [1] Append to extension.
|
||||
* [2] Append to filename,
|
||||
* [3] Replace end of extension,
|
||||
* [4] Replace end of filename.
|
||||
* If the name matches the original name, use the fallback method.
|
||||
*
|
||||
|
@ -257,7 +257,7 @@ ruby_strtoul(const char *str, char **endptr, int base)
|
|||
* longname.fil => longname.fi~
|
||||
* longname.fi~ => longnam~.fi~
|
||||
* longnam~.fi~ => longnam~.$$$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
@ -311,7 +311,7 @@ ruby_add_suffix(VALUE str, const char *suffix)
|
|||
strcpy(p, suffix);
|
||||
}
|
||||
else if (suffix[1] == '\0') { /* Style 2 */
|
||||
if (extlen < 4) {
|
||||
if (extlen < 4) {
|
||||
ext[extlen] = *suffix;
|
||||
ext[++extlen] = '\0';
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ fallback:
|
|||
}
|
||||
|
||||
#if defined(__CYGWIN32__) || defined(_WIN32)
|
||||
static int
|
||||
static int
|
||||
valid_filename(const char *s)
|
||||
{
|
||||
int fd;
|
||||
|
|
|
@ -215,7 +215,6 @@ rb_call0(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv,
|
|||
return method_missing(recv, mid, argc, argv,
|
||||
scope == 2 ? NOEX_VCALL : 0);
|
||||
}
|
||||
|
||||
|
||||
if (mid != idMethodMissing) {
|
||||
/* receiver specified form for private method */
|
||||
|
@ -227,7 +226,7 @@ rb_call0(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv,
|
|||
/* self must be kind of a specified form for protected method */
|
||||
if (((noex & NOEX_MASK) & NOEX_PROTECTED) && scope == 0) {
|
||||
VALUE defined_class = klass;
|
||||
|
||||
|
||||
if (TYPE(defined_class) == T_ICLASS) {
|
||||
defined_class = RBASIC(defined_class)->klass;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ vm_push_frame(rb_thread_t * th, const rb_iseq_t * iseq,
|
|||
int i;
|
||||
|
||||
/* setup vm value stack */
|
||||
|
||||
|
||||
/* nil initialize */
|
||||
for (i=0; i < local_size; i++) {
|
||||
*sp = Qnil;
|
||||
|
@ -798,7 +798,7 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq,
|
|||
else {
|
||||
int r = iseq->arg_rest;
|
||||
|
||||
if (iseq->arg_post_len ||
|
||||
if (iseq->arg_post_len ||
|
||||
iseq->arg_opts) { /* TODO: implement simple version for (iseq->arg_post_len==0 && iseq->arg_opts > 0) */
|
||||
opt_pc = vm_yield_setup_block_args_complex(th, iseq, argc, argv);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче