mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
* *.[chy]: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
69743fbd85
commit
3f0d0b9398
33 changed files with 1687 additions and 1687 deletions
48
class.c
48
class.c
|
@ -408,7 +408,7 @@ rb_include_module(klass, module)
|
|||
if (!OBJ_TAINTED(klass)) {
|
||||
rb_secure(4);
|
||||
}
|
||||
|
||||
|
||||
if (TYPE(module) != T_MODULE) {
|
||||
Check_Type(module, T_MODULE);
|
||||
}
|
||||
|
@ -447,16 +447,16 @@ rb_include_module(klass, 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]
|
||||
*/
|
||||
|
@ -479,10 +479,10 @@ rb_mod_included_modules(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
|
||||
|
@ -514,15 +514,15 @@ rb_mod_include_p(mod, 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]
|
||||
*/
|
||||
|
@ -663,14 +663,14 @@ class_instance_method_list(argc, argv, mod, func)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.instance_methods(include_super=true) => array
|
||||
*
|
||||
*
|
||||
* Returns an array containing the names of public instance methods 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
|
||||
|
@ -680,7 +680,7 @@ class_instance_method_list(argc, argv, mod, func)
|
|||
* class C < B
|
||||
* def method3() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* A.instance_methods #=> ["method1"]
|
||||
* B.instance_methods(false) #=> ["method2"]
|
||||
* C.instance_methods(false) #=> ["method3"]
|
||||
|
@ -699,7 +699,7 @@ rb_class_instance_methods(argc, argv, 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.
|
||||
|
@ -717,11 +717,11 @@ rb_class_protected_instance_methods(argc, argv, 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
|
||||
|
@ -743,7 +743,7 @@ rb_class_private_instance_methods(argc, argv, 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.
|
||||
|
@ -761,30 +761,30 @@ rb_class_public_instance_methods(argc, argv, 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"]
|
||||
|
|
24
compar.c
24
compar.c
|
@ -72,7 +72,7 @@ cmp_failed()
|
|||
/*
|
||||
* 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.
|
||||
|
@ -93,7 +93,7 @@ cmp_equal(x, 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.
|
||||
*/
|
||||
|
@ -112,7 +112,7 @@ cmp_gt(x, 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.
|
||||
*/
|
||||
|
@ -131,7 +131,7 @@ cmp_ge(x, 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.
|
||||
*/
|
||||
|
@ -151,7 +151,7 @@ cmp_lt(x, 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.
|
||||
*/
|
||||
|
@ -170,16 +170,16 @@ cmp_le(x, 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
|
||||
|
@ -200,7 +200,7 @@ cmp_between(x, min, 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
|
||||
|
@ -214,18 +214,18 @@ cmp_between(x, min, 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
|
||||
|
|
2
dir.c
2
dir.c
|
@ -1679,7 +1679,7 @@ dir_globs(argc, argv, flags)
|
|||
* Dir[ string [, string ...] ] => array
|
||||
*
|
||||
* Equivalent to calling
|
||||
* <code>Dir.glob(</code><i>array,</i><code>0)</code> and
|
||||
* <code>Dir.glob(</code><i>array,</i><code>0)</code> and
|
||||
* <code>Dir.glob([</code><i>string,...</i><code>],0)</code>.
|
||||
*
|
||||
*/
|
||||
|
|
24
dln.c
24
dln.c
|
@ -814,7 +814,7 @@ load_1(fd, disp, 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;
|
||||
|
@ -1226,7 +1226,7 @@ aix_loaderror(const char *pathname)
|
|||
char *message[8], errbuf[1024];
|
||||
int i,j;
|
||||
|
||||
struct errtab {
|
||||
struct errtab {
|
||||
int errnum;
|
||||
char *errstr;
|
||||
} load_errtab[] = {
|
||||
|
@ -1249,7 +1249,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]);
|
||||
|
@ -1257,7 +1257,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");
|
||||
}
|
||||
|
@ -1416,7 +1416,7 @@ dln_load(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,
|
||||
|
@ -1431,9 +1431,9 @@ dln_load(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*/
|
||||
|
@ -1480,7 +1480,7 @@ dln_load(file)
|
|||
/* lookup the initial function */
|
||||
if(!NSIsSymbolNameDefined(buf)) {
|
||||
rb_loaderror("Failed to lookup Init function %.200s",file);
|
||||
}
|
||||
}
|
||||
init_fct = NSAddressOfSymbol(NSLookupAndBindSymbol(buf));
|
||||
(*init_fct)();
|
||||
|
||||
|
@ -1502,7 +1502,7 @@ dln_load(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
|
||||
|
@ -1564,7 +1564,7 @@ dln_load(file)
|
|||
|
||||
/* Load the fragment (or return the connID if it is already loaded */
|
||||
fragname[0] = 0;
|
||||
err = GetDiskFragment(&libspec, 0, 0, fragname,
|
||||
err = GetDiskFragment(&libspec, 0, 0, fragname,
|
||||
kLoadCFrag, &connID, &mainAddr,
|
||||
errMessage);
|
||||
if (err) {
|
||||
|
@ -1615,8 +1615,8 @@ dln_load(file)
|
|||
|
||||
status = lib$find_image_symbol (
|
||||
&fname_d,
|
||||
&buf_d,
|
||||
&init_fct,
|
||||
&buf_d,
|
||||
&init_fct,
|
||||
&image_d);
|
||||
|
||||
lib$establish(0);
|
||||
|
|
4
enum.c
4
enum.c
|
@ -1517,8 +1517,8 @@ enum_each_with_index(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
|
@ -340,7 +340,7 @@ rb_exc_new3(etype, 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.
|
||||
*/
|
||||
|
||||
|
@ -364,12 +364,12 @@ exc_initialize(argc, argv, 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
|
||||
|
@ -457,27 +457,27 @@ exc_inspect(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
|
||||
|
@ -519,11 +519,11 @@ rb_check_backtrace(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
|
||||
|
@ -795,7 +795,7 @@ rb_invalid_str(str, type)
|
|||
rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING(s)->ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Document-module: Errno
|
||||
*
|
||||
* Ruby exception objects are subclasses of <code>Exception</code>.
|
||||
|
@ -805,21 +805,21 @@ rb_invalid_str(str, 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>.
|
||||
*
|
||||
|
@ -974,7 +974,7 @@ syserr_eqq(self, 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.
|
||||
*/
|
||||
|
||||
|
@ -1132,14 +1132,14 @@ rb_sys_warning(fmt, va_alist)
|
|||
char buf[BUFSIZ];
|
||||
va_list args;
|
||||
int errno_save;
|
||||
|
||||
|
||||
errno_save = errno;
|
||||
|
||||
if (!RTEST(ruby_verbose)) return;
|
||||
|
||||
snprintf(buf, BUFSIZ, "warning: %s", fmt);
|
||||
snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
|
||||
|
||||
|
||||
va_init_list(args, fmt);
|
||||
warn_print(buf, args);
|
||||
va_end(args);
|
||||
|
|
2
gc.c
2
gc.c
|
@ -436,7 +436,7 @@ add_heap()
|
|||
}
|
||||
#define RANY(o) ((RVALUE*)(o))
|
||||
|
||||
int
|
||||
int
|
||||
rb_during_gc()
|
||||
{
|
||||
return during_gc;
|
||||
|
|
2
intern.h
2
intern.h
|
@ -12,7 +12,7 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
/*
|
||||
/*
|
||||
* Functions and variables that are used by more than one source file of
|
||||
* the kernel.
|
||||
*/
|
||||
|
|
|
@ -1434,7 +1434,7 @@ clear_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
|
||||
|
|
54
math.c
54
math.c
|
@ -46,10 +46,10 @@ domain_check(x, 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
|
||||
|
@ -64,7 +64,7 @@ math_atan2(obj, y, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.cos(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the cosine of <i>x</i> (expressed in radians). Returns
|
||||
* -1..1.
|
||||
*/
|
||||
|
@ -80,7 +80,7 @@ math_cos(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.sin(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the sine of <i>x</i> (expressed in radians). Returns
|
||||
* -1..1.
|
||||
*/
|
||||
|
@ -98,7 +98,7 @@ math_sin(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.tan(x) => float
|
||||
*
|
||||
*
|
||||
* Returns the tangent of <i>x</i> (expressed in radians).
|
||||
*/
|
||||
|
||||
|
@ -114,7 +114,7 @@ math_tan(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.acos(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the arc cosine of <i>x</i>. Returns 0..PI.
|
||||
*/
|
||||
|
||||
|
@ -134,7 +134,7 @@ math_acos(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.asin(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the arc sine of <i>x</i>. Returns -{PI/2} .. {PI/2}.
|
||||
*/
|
||||
|
||||
|
@ -154,7 +154,7 @@ math_asin(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.atan(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the arc tangent of <i>x</i>. Returns -{PI/2} .. {PI/2}.
|
||||
*/
|
||||
|
||||
|
@ -178,7 +178,7 @@ cosh(x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.cosh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the hyperbolic cosine of <i>x</i> (expressed in radians).
|
||||
*/
|
||||
|
||||
|
@ -187,7 +187,7 @@ math_cosh(obj, x)
|
|||
VALUE obj, x;
|
||||
{
|
||||
Need_Float(x);
|
||||
|
||||
|
||||
return rb_float_new(cosh(RFLOAT(x)->value));
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ sinh(x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.sinh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the hyperbolic sine of <i>x</i> (expressed in
|
||||
* radians).
|
||||
*/
|
||||
|
@ -228,7 +228,7 @@ tanh(x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.tanh() => float
|
||||
*
|
||||
*
|
||||
* Computes the hyperbolic tangent of <i>x</i> (expressed in
|
||||
* radians).
|
||||
*/
|
||||
|
@ -244,7 +244,7 @@ math_tanh(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.acosh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the inverse hyperbolic cosine of <i>x</i>.
|
||||
*/
|
||||
|
||||
|
@ -264,7 +264,7 @@ math_acosh(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.asinh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the inverse hyperbolic sine of <i>x</i>.
|
||||
*/
|
||||
|
||||
|
@ -279,7 +279,7 @@ math_asinh(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.atanh(x) => float
|
||||
*
|
||||
*
|
||||
* Computes the inverse hyperbolic tangent of <i>x</i>.
|
||||
*/
|
||||
|
||||
|
@ -299,7 +299,7 @@ math_atanh(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.exp(x) => float
|
||||
*
|
||||
*
|
||||
* Returns e**x.
|
||||
*/
|
||||
|
||||
|
@ -323,7 +323,7 @@ math_exp(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.log(numeric) => float
|
||||
*
|
||||
*
|
||||
* Returns the natural logarithm of <i>numeric</i>.
|
||||
*/
|
||||
|
||||
|
@ -343,7 +343,7 @@ math_log(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.log10(numeric) => float
|
||||
*
|
||||
*
|
||||
* Returns the base 10 logarithm of <i>numeric</i>.
|
||||
*/
|
||||
|
||||
|
@ -363,7 +363,7 @@ math_log10(obj, x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Math.sqrt(numeric) => float
|
||||
*
|
||||
*
|
||||
* Returns the non-negative square root of <i>numeric</i>.
|
||||
*/
|
||||
|
||||
|
@ -383,11 +383,11 @@ math_sqrt(obj, 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
|
||||
*/
|
||||
|
@ -400,7 +400,7 @@ math_frexp(obj, x)
|
|||
int exp;
|
||||
|
||||
Need_Float(x);
|
||||
|
||||
|
||||
d = frexp(RFLOAT(x)->value, &exp);
|
||||
return rb_assoc_new(rb_float_new(d), INT2NUM(exp));
|
||||
}
|
||||
|
@ -408,9 +408,9 @@ math_frexp(obj, 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
|
||||
*/
|
||||
|
@ -426,10 +426,10 @@ math_ldexp(obj, x, 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
|
||||
*/
|
||||
|
||||
|
@ -476,7 +476,7 @@ math_erfc(obj, x)
|
|||
* trigonometric and transcendental functions. See class
|
||||
* <code>Float</code> for a list of constants that
|
||||
* define Ruby's floating point accuracy.
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
|
|
|
@ -2371,7 +2371,7 @@ fix_pow(x, y)
|
|||
if (a == -1) {
|
||||
if (b % 2 == 0)
|
||||
return INT2FIX(1);
|
||||
else
|
||||
else
|
||||
return INT2FIX(-1);
|
||||
}
|
||||
if (b > 0) {
|
||||
|
|
36
pack.c
36
pack.c
|
@ -348,13 +348,13 @@ num2i32(x)
|
|||
}
|
||||
|
||||
#if SIZEOF_LONG == SIZE32
|
||||
# define EXTEND32(x)
|
||||
# define EXTEND32(x)
|
||||
#else
|
||||
/* invariant in modulo 1<<31 */
|
||||
# define EXTEND32(x) do { if (!natint) {(x) = (((1L<<31)-1-(x))^~(~0L<<31));}} while(0)
|
||||
#endif
|
||||
#if SIZEOF_SHORT == SIZE16
|
||||
# define EXTEND16(x)
|
||||
# define EXTEND16(x)
|
||||
#else
|
||||
# define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15));}} while(0)
|
||||
#endif
|
||||
|
@ -374,7 +374,7 @@ static int uv_to_utf8 _((char*,unsigned long));
|
|||
/*
|
||||
* call-seq:
|
||||
* arr.pack ( aTemplateString ) -> aBinaryString
|
||||
*
|
||||
*
|
||||
* Packs the contents of <i>arr</i> into a binary sequence according to
|
||||
* the directives in <i>aTemplateString</i> (see the table below)
|
||||
* Directives ``A,'' ``a,'' and ``Z'' may be followed by a count,
|
||||
|
@ -387,13 +387,13 @@ static int uv_to_utf8 _((char*,unsigned long));
|
|||
* platform's native size for the specified type; otherwise, they use a
|
||||
* platform-independent size. Spaces are ignored in the template
|
||||
* string. See also <code>String#unpack</code>.
|
||||
*
|
||||
*
|
||||
* a = [ "a", "b", "c" ]
|
||||
* n = [ 65, 66, 67 ]
|
||||
* a.pack("A3A3A3") #=> "a b c "
|
||||
* a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000"
|
||||
* n.pack("ccc") #=> "ABC"
|
||||
*
|
||||
*
|
||||
* Directives for +pack+.
|
||||
*
|
||||
* Directive Meaning
|
||||
|
@ -1163,11 +1163,11 @@ infected_str_new(ptr, len, str)
|
|||
OBJ_INFECT(s, str);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* str.unpack(format) => anArray
|
||||
*
|
||||
*
|
||||
* Decodes <i>str</i> (which may contain binary data) according to the
|
||||
* format string, returning an array of each value extracted. The
|
||||
* format string consists of a sequence of single-character directives,
|
||||
|
@ -1180,7 +1180,7 @@ infected_str_new(ptr, len, str)
|
|||
* platform's native size for the specified type; otherwise, it uses a
|
||||
* platform-independent consistent size. Spaces are ignored in the
|
||||
* format string. See also <code>Array#pack</code>.
|
||||
*
|
||||
*
|
||||
* "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "]
|
||||
* "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"]
|
||||
* "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "]
|
||||
|
@ -1192,7 +1192,7 @@ infected_str_new(ptr, len, str)
|
|||
*
|
||||
* This table summarizes the various formats and the Ruby classes
|
||||
* returned by each.
|
||||
*
|
||||
*
|
||||
* Format | Returns | Function
|
||||
* -------+---------+-----------------------------------------
|
||||
* A | String | with trailing nulls and spaces removed
|
||||
|
@ -1264,17 +1264,17 @@ infected_str_new(ptr, len, str)
|
|||
* p | String | treat sizeof(char *) characters as a
|
||||
* | | pointer to a null-terminated string
|
||||
* -------+---------+-----------------------------------------
|
||||
* Q | Integer | treat 8 characters as an unsigned
|
||||
* Q | Integer | treat 8 characters as an unsigned
|
||||
* | | quad word (64 bits)
|
||||
* -------+---------+-----------------------------------------
|
||||
* q | Integer | treat 8 characters as a signed
|
||||
* q | Integer | treat 8 characters as a signed
|
||||
* | | quad word (64 bits)
|
||||
* -------+---------+-----------------------------------------
|
||||
* S | Fixnum | treat two (different if _ used)
|
||||
* | | successive characters as an unsigned
|
||||
* | | short in native byte order
|
||||
* -------+---------+-----------------------------------------
|
||||
* s | Fixnum | Treat two (different if _ used)
|
||||
* s | Fixnum | Treat two (different if _ used)
|
||||
* | | successive characters as a signed short
|
||||
* | | in native byte order
|
||||
* -------+---------+-----------------------------------------
|
||||
|
@ -1297,7 +1297,7 @@ infected_str_new(ptr, len, str)
|
|||
* Z | String | with trailing nulls removed
|
||||
* | | upto first null with *
|
||||
* -------+---------+-----------------------------------------
|
||||
* @ | --- | skip to the offset given by the
|
||||
* @ | --- | skip to the offset given by the
|
||||
* | | length argument
|
||||
* -------+---------+-----------------------------------------
|
||||
*/
|
||||
|
@ -1663,7 +1663,7 @@ pack_unpack(str, fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
|
||||
|
||||
case 'E':
|
||||
PACK_LENGTH_ADJUST(double,sizeof(double));
|
||||
while (len-- > 0) {
|
||||
|
@ -1677,7 +1677,7 @@ pack_unpack(str, fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
|
||||
|
||||
case 'D':
|
||||
case 'd':
|
||||
PACK_LENGTH_ADJUST(double,sizeof(double));
|
||||
|
@ -1703,7 +1703,7 @@ pack_unpack(str, fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
|
||||
|
||||
case 'G':
|
||||
PACK_LENGTH_ADJUST(double,sizeof(double));
|
||||
while (len-- > 0) {
|
||||
|
@ -1717,7 +1717,7 @@ pack_unpack(str, fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
|
||||
|
||||
case 'U':
|
||||
if (len > send - s) len = send - s;
|
||||
while (len > 0 && s < send) {
|
||||
|
@ -1779,7 +1779,7 @@ pack_unpack(str, fmt)
|
|||
else if (s < send && (s+1 == send || s[1] == '\n'))
|
||||
s += 2; /* possible checksum byte */
|
||||
}
|
||||
|
||||
|
||||
RSTRING(buf)->ptr[total] = '\0';
|
||||
RSTRING(buf)->len = total;
|
||||
rb_ary_push(ary, buf);
|
||||
|
|
2
parse.y
2
parse.y
|
@ -5016,7 +5016,7 @@ new_args(m, o, r, p, b)
|
|||
}
|
||||
return block_append(NEW_ARGS(m, o, r), b);
|
||||
}
|
||||
|
||||
|
||||
static NODE *
|
||||
evstr2dstr(node)
|
||||
NODE *node;
|
||||
|
|
8
prec.c
8
prec.c
|
@ -22,7 +22,7 @@ static ID prc_pr, prc_if;
|
|||
* num.prec(klass) => a_klass
|
||||
*
|
||||
* Converts _self_ into an instance of _klass_. By default,
|
||||
* +prec+ invokes
|
||||
* +prec+ invokes
|
||||
*
|
||||
* klass.induced_from(num)
|
||||
*
|
||||
|
@ -42,7 +42,7 @@ prec_prec(x, klass)
|
|||
* call-seq:
|
||||
* num.prec_i => Integer
|
||||
*
|
||||
* Returns an +Integer+ converted from _num_. It is equivalent
|
||||
* Returns an +Integer+ converted from _num_. It is equivalent
|
||||
* to <code>prec(Integer)</code>.
|
||||
*/
|
||||
|
||||
|
@ -59,7 +59,7 @@ prec_prec_i(x)
|
|||
* call-seq:
|
||||
* num.prec_f => Float
|
||||
*
|
||||
* Returns a +Float+ converted from _num_. It is equivalent
|
||||
* Returns a +Float+ converted from _num_. It is equivalent
|
||||
* to <code>prec(Float)</code>.
|
||||
*/
|
||||
|
||||
|
@ -75,7 +75,7 @@ prec_prec_f(x)
|
|||
/*
|
||||
* call-seq:
|
||||
* Mod.induced_from(number) => a_mod
|
||||
*
|
||||
*
|
||||
* Creates an instance of mod from. This method is overridden
|
||||
* by concrete +Numeric+ classes, so that (for example)
|
||||
*
|
||||
|
|
40
random.c
40
random.c
|
@ -10,7 +10,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>.
|
||||
|
||||
|
@ -21,11 +21,11 @@ The original copyright notice follows.
|
|||
This is a faster version by taking Shawn Cokus's optimization,
|
||||
Matthe Bellew's simplification, Isaku Wada's real version.
|
||||
|
||||
Before using, initialize the state by using init_genrand(seed)
|
||||
Before using, initialize the state by using init_genrand(seed)
|
||||
or init_by_array(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
|
||||
|
@ -38,8 +38,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
|
||||
|
@ -60,7 +60,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 */
|
||||
|
@ -82,7 +82,7 @@ init_genrand(s)
|
|||
int j;
|
||||
state[0]= s & 0xffffffffUL;
|
||||
for (j=1; j<N; j++) {
|
||||
state[j] = (1812433253UL * (state[j-1] ^ (state[j-1] >> 30)) + j);
|
||||
state[j] = (1812433253UL * (state[j-1] ^ (state[j-1] >> 30)) + j);
|
||||
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
|
||||
/* In the previous versions, MSBs of the seed affect */
|
||||
/* only MSBs of the array state[]. */
|
||||
|
@ -119,7 +119,7 @@ init_by_array(unsigned long init_key[], int key_length)
|
|||
if (i>=N) { state[0] = state[N-1]; i=1; }
|
||||
}
|
||||
|
||||
state[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
|
||||
state[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
|
||||
left = 1; initf = 1;
|
||||
}
|
||||
|
||||
|
@ -135,11 +135,11 @@ next_state()
|
|||
|
||||
left = N;
|
||||
next = state;
|
||||
|
||||
for (j=N-M+1; --j; p++)
|
||||
|
||||
for (j=N-M+1; --j; p++)
|
||||
*p = p[M] ^ TWIST(p[0], p[1]);
|
||||
|
||||
for (j=M; --j; p++)
|
||||
for (j=M; --j; p++)
|
||||
*p = p[M-N] ^ TWIST(p[0], p[1]);
|
||||
|
||||
*p = p[M-N] ^ TWIST(p[0], state[0]);
|
||||
|
@ -165,11 +165,11 @@ rb_genrand_int32(void)
|
|||
|
||||
/* generates a random number on [0,1) with 53-bit resolution*/
|
||||
double
|
||||
rb_genrand_real(void)
|
||||
{
|
||||
unsigned long a=rb_genrand_int32()>>5, b=rb_genrand_int32()>>6;
|
||||
return(a*67108864.0+b)*(1.0/9007199254740992.0);
|
||||
}
|
||||
rb_genrand_real(void)
|
||||
{
|
||||
unsigned long a=rb_genrand_int32()>>5, b=rb_genrand_int32()>>6;
|
||||
return(a*67108864.0+b)*(1.0/9007199254740992.0);
|
||||
}
|
||||
/* These real versions are due to Isaku Wada, 2002/01/09 added */
|
||||
|
||||
#undef N
|
||||
|
@ -306,7 +306,7 @@ random_seed()
|
|||
/*
|
||||
* call-seq:
|
||||
* srand(number=0) => old_seed
|
||||
*
|
||||
*
|
||||
* Seeds the pseudorandom number generator to the value of
|
||||
* <i>number</i>.<code>to_i.abs</code>. If <i>number</i> is omitted,
|
||||
* seeds the generator using a combination of the time, the
|
||||
|
@ -334,7 +334,7 @@ rb_f_srand(argc, argv, obj)
|
|||
return old;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static unsigned long
|
||||
make_mask(unsigned long x)
|
||||
{
|
||||
x = x | x >> 1;
|
||||
|
@ -416,7 +416,7 @@ limited_big_rand(struct RBignum *limit)
|
|||
/*
|
||||
* 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
|
||||
|
@ -425,7 +425,7 @@ limited_big_rand(struct RBignum *limit)
|
|||
* 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]
|
||||
|
|
126
re.c
126
re.c
|
@ -222,7 +222,7 @@ rb_kcode_set_option(re)
|
|||
re_mbcinit(MBCTYPE_UTF8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_kcode_reset_option()
|
||||
|
@ -291,7 +291,7 @@ rb_reg_expr_str(str, s, len)
|
|||
rb_str_buf_cat(str, s, len);
|
||||
}
|
||||
else {
|
||||
p = s;
|
||||
p = s;
|
||||
while (p<pend) {
|
||||
if (*p == '\\') {
|
||||
int n = mbclen(p[1]) + 1;
|
||||
|
@ -344,7 +344,7 @@ rb_reg_desc(s, len, re)
|
|||
rb_str_buf_cat2(str, "i");
|
||||
if (RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED)
|
||||
rb_str_buf_cat2(str, "x");
|
||||
|
||||
|
||||
if (FL_TEST(re, KCODE_FIXED)) {
|
||||
switch ((RBASIC(re)->flags & KCODE_MASK)) {
|
||||
case KCODE_NONE:
|
||||
|
@ -370,9 +370,9 @@ rb_reg_desc(s, len, re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.source => str
|
||||
*
|
||||
*
|
||||
* Returns the original string of the pattern.
|
||||
*
|
||||
*
|
||||
* /ab+c/ix.source #=> "ab+c"
|
||||
*/
|
||||
|
||||
|
@ -411,7 +411,7 @@ rb_reg_inspect(re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.to_s => str
|
||||
*
|
||||
*
|
||||
* Returns a string containing the regular expression and its options (using the
|
||||
* <code>(?xxx:yyy)</code> notation. This string can be fed back in to
|
||||
* <code>Regexp::new</code> to a regular expression with the same semantics as
|
||||
|
@ -419,7 +419,7 @@ rb_reg_inspect(re)
|
|||
* comparing the two, as the source of the regular expression itself may
|
||||
* differ, as the example shows). <code>Regexp#inspect</code> produces a
|
||||
* generally more readable version of <i>rxp</i>.
|
||||
*
|
||||
*
|
||||
* r1 = /ab+c/ix #=> /ab+c/ix
|
||||
* s1 = r1.to_s #=> "(?ix-m:ab+c)"
|
||||
* r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/
|
||||
|
@ -538,7 +538,7 @@ rb_reg_raise(s, len, err, re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.casefold? => true or false
|
||||
*
|
||||
*
|
||||
* Returns the value of the case-insensitive flag.
|
||||
*/
|
||||
|
||||
|
@ -555,22 +555,22 @@ rb_reg_casefold_p(re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.options => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the set of bits corresponding to the options used when creating this
|
||||
* Regexp (see <code>Regexp::new</code> for details. Note that additional bits
|
||||
* may be set in the returned options: these are used internally by the regular
|
||||
* expression code. These extra bits are ignored if the options are passed to
|
||||
* <code>Regexp::new</code>.
|
||||
*
|
||||
*
|
||||
* Regexp::IGNORECASE #=> 1
|
||||
* Regexp::EXTENDED #=> 2
|
||||
* Regexp::MULTILINE #=> 4
|
||||
*
|
||||
*
|
||||
* /cat/.options #=> 128
|
||||
* /cat/ix.options #=> 131
|
||||
* Regexp.new('cat', true).options #=> 129
|
||||
* Regexp.new('cat', 0, 's').options #=> 384
|
||||
*
|
||||
*
|
||||
* r = /cat/ix
|
||||
* Regexp.new(r.source, r.options) #=> /cat/ix
|
||||
*/
|
||||
|
@ -587,7 +587,7 @@ rb_reg_options_m(re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.kcode => str
|
||||
*
|
||||
*
|
||||
* Returns the character set code for the regexp.
|
||||
*/
|
||||
|
||||
|
@ -715,9 +715,9 @@ match_init_copy(obj, orig)
|
|||
* call-seq:
|
||||
* mtch.length => integer
|
||||
* mtch.size => integer
|
||||
*
|
||||
*
|
||||
* Returns the number of elements in the match array.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.length #=> 5
|
||||
* m.size #=> 5
|
||||
|
@ -735,10 +735,10 @@ match_size(match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.offset(n) => array
|
||||
*
|
||||
*
|
||||
* Returns a two-element array containing the beginning and ending offsets of
|
||||
* the <em>n</em>th match.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.offset(0) #=> [1, 7]
|
||||
* m.offset(4) #=> [6, 7]
|
||||
|
@ -765,10 +765,10 @@ match_offset(match, n)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.begin(n) => integer
|
||||
*
|
||||
*
|
||||
* Returns the offset of the start of the <em>n</em>th element of the match
|
||||
* array in the string.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.begin(0) #=> 1
|
||||
* m.begin(2) #=> 2
|
||||
|
@ -794,10 +794,10 @@ match_begin(match, n)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.end(n) => integer
|
||||
*
|
||||
*
|
||||
* Returns the offset of the character immediately following the end of the
|
||||
* <em>n</em>th element of the match array in the string.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.end(0) #=> 7
|
||||
* m.end(2) #=> 3
|
||||
|
@ -951,7 +951,7 @@ rb_reg_search(re, str, pos, reverse)
|
|||
match = match_alloc(rb_cMatch);
|
||||
}
|
||||
else {
|
||||
if (rb_safe_level() >= 3)
|
||||
if (rb_safe_level() >= 3)
|
||||
OBJ_TAINT(match);
|
||||
else
|
||||
FL_UNSET(match, FL_TAINT);
|
||||
|
@ -1022,10 +1022,10 @@ rb_reg_last_match(match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.pre_match => str
|
||||
*
|
||||
*
|
||||
* Returns the portion of the original string before the current match.
|
||||
* Equivalent to the special variable <code>$`</code>.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.pre_match #=> "T"
|
||||
*/
|
||||
|
@ -1048,10 +1048,10 @@ rb_reg_match_pre(match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.post_match => str
|
||||
*
|
||||
*
|
||||
* Returns the portion of the original string after the current match.
|
||||
* Equivalent to the special variable <code>$'</code>.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
||||
* m.post_match #=> ": The Movie"
|
||||
*/
|
||||
|
@ -1150,18 +1150,18 @@ match_array(match, start)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.to_a => anArray
|
||||
*
|
||||
*
|
||||
* Returns the array of matches.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
||||
*
|
||||
*
|
||||
* Because <code>to_a</code> is called when expanding
|
||||
* <code>*</code><em>variable</em>, there's a useful assignment
|
||||
* shortcut for extracting matched fields. This is slightly slower than
|
||||
* accessing the fields directly (as an intermediate array is
|
||||
* generated).
|
||||
*
|
||||
*
|
||||
* all,f1,f2,f3 = *(/(.)(.)(\d+)(\d)/.match("THX1138."))
|
||||
* all #=> "HX1138"
|
||||
* f1 #=> "H"
|
||||
|
@ -1202,13 +1202,13 @@ match_captures(match)
|
|||
* mtch[i] => obj
|
||||
* mtch[start, length] => array
|
||||
* mtch[range] => array
|
||||
*
|
||||
*
|
||||
* Match Reference---<code>MatchData</code> acts as an array, and may be
|
||||
* accessed using the normal array indexing techniques. <i>mtch</i>[0] is
|
||||
* equivalent to the special variable <code>$&</code>, and returns the entire
|
||||
* matched string. <i>mtch</i>[1], <i>mtch</i>[2], and so on return the values
|
||||
* of the matched backreferences (portions of the pattern between parentheses).
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m[0] #=> "HX1138"
|
||||
* m[1, 2] #=> ["H", "X"]
|
||||
|
@ -1245,10 +1245,10 @@ match_entry(match, n)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.values_at([index]*) => array
|
||||
*
|
||||
*
|
||||
* Uses each <i>index</i> to access the matching values, returning an array of
|
||||
* the corresponding matches.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
||||
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
||||
* m.values_at(0, 2, -2) #=> ["HX1138", "X", "113"]
|
||||
|
@ -1268,10 +1268,10 @@ match_values_at(argc, argv, match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.select{|obj| block} => array
|
||||
*
|
||||
*
|
||||
* Returns an array containing match strings for which <em>block</em>
|
||||
* gives <code>true</code>. MatchData#select will be removed from Ruby 1.9.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
||||
* p m.select{|x| /X/ =~ x} #=> ["HX1138", "X"]
|
||||
*/
|
||||
|
@ -1312,9 +1312,9 @@ match_select(argc, argv, match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.to_s => str
|
||||
*
|
||||
*
|
||||
* Returns the entire matched string.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.to_s #=> "HX1138"
|
||||
*/
|
||||
|
@ -1335,9 +1335,9 @@ match_to_s(match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.string => str
|
||||
*
|
||||
*
|
||||
* Returns a frozen copy of the string passed in to <code>match</code>.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.string #=> "THX1138."
|
||||
*/
|
||||
|
@ -1545,7 +1545,7 @@ rb_reg_hash(re)
|
|||
hashval = hashval * 33 + *p++;
|
||||
}
|
||||
hashval = hashval + (hashval>>5);
|
||||
|
||||
|
||||
return INT2FIX(hashval);
|
||||
}
|
||||
|
||||
|
@ -1554,11 +1554,11 @@ rb_reg_hash(re)
|
|||
* call-seq:
|
||||
* rxp == other_rxp => true or false
|
||||
* rxp.eql?(other_rxp) => true or false
|
||||
*
|
||||
*
|
||||
* Equality---Two regexps are equal if their patterns are identical, they have
|
||||
* the same character set code, and their <code>casefold?</code> values are the
|
||||
* same.
|
||||
*
|
||||
*
|
||||
* /abc/ == /abc/x #=> false
|
||||
* /abc/ == /abc/i #=> false
|
||||
* /abc/u == /abc/n #=> false
|
||||
|
@ -1584,11 +1584,11 @@ rb_reg_equal(re1, re2)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.match(str) => matchdata or nil
|
||||
*
|
||||
*
|
||||
* Returns a <code>MatchData</code> object describing the match, or
|
||||
* <code>nil</code> if there was no match. This is equivalent to retrieving the
|
||||
* value of the special variable <code>$~</code> following a normal match.
|
||||
*
|
||||
*
|
||||
* /(.)(.)(.)/.match("abc")[2] #=> "b"
|
||||
*/
|
||||
|
||||
|
@ -1614,18 +1614,18 @@ rb_reg_match(re, str)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp === str => true or false
|
||||
*
|
||||
*
|
||||
* Case Equality---Synonym for <code>Regexp#=~</code> used in case statements.
|
||||
*
|
||||
*
|
||||
* a = "HELLO"
|
||||
* case a
|
||||
* when /^[a-z]*$/; print "Lower case\n"
|
||||
* when /^[A-Z]*$/; print "Upper case\n"
|
||||
* else; print "Mixed case\n"
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Upper case
|
||||
*/
|
||||
|
||||
|
@ -1654,10 +1654,10 @@ rb_reg_eqq(re, str)
|
|||
/*
|
||||
* call-seq:
|
||||
* ~ rxp => integer or nil
|
||||
*
|
||||
*
|
||||
* Match---Matches <i>rxp</i> against the contents of <code>$_</code>.
|
||||
* Equivalent to <code><i>rxp</i> =~ $_</code>.
|
||||
*
|
||||
*
|
||||
* $_ = "input data"
|
||||
* ~ /at/ #=> 7
|
||||
*/
|
||||
|
@ -1685,11 +1685,11 @@ rb_reg_match2(re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.match(str) => matchdata or nil
|
||||
*
|
||||
*
|
||||
* Returns a <code>MatchData</code> object describing the match, or
|
||||
* <code>nil</code> if there was no match. This is equivalent to retrieving the
|
||||
* value of the special variable <code>$~</code> following a normal match.
|
||||
*
|
||||
*
|
||||
* /(.)(.)(.)/.match("abc")[2] #=> "b"
|
||||
*/
|
||||
|
||||
|
@ -1717,7 +1717,7 @@ rb_reg_match_m(re, str)
|
|||
* Regexp.new(regexp) => regexp
|
||||
* Regexp.compile(string [, options [, lang]]) => regexp
|
||||
* Regexp.compile(regexp) => regexp
|
||||
*
|
||||
*
|
||||
* Constructs a new regular expression from <i>pattern</i>, which can be either
|
||||
* a <code>String</code> or a <code>Regexp</code> (in which case that regexp's
|
||||
* options are propagated, and new options may not be specified (a change as of
|
||||
|
@ -1728,7 +1728,7 @@ rb_reg_match_m(re, str)
|
|||
* <code>nil</code>, the regexp will be case insensitive. The <i>lang</i>
|
||||
* parameter enables multibyte support for the regexp: `n', `N' = none, `e',
|
||||
* `E' = EUC, `s', `S' = SJIS, `u', `U' = UTF-8.
|
||||
*
|
||||
*
|
||||
* r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/
|
||||
* r2 = Regexp.new('cat', true) #=> /cat/i
|
||||
* r3 = Regexp.new('dog', Regexp::EXTENDED) #=> /dog/x
|
||||
|
@ -1898,12 +1898,12 @@ rb_reg_quote(str)
|
|||
* call-seq:
|
||||
* Regexp.escape(str) => a_str
|
||||
* Regexp.quote(str) => a_str
|
||||
*
|
||||
*
|
||||
* Escapes any characters that would have special meaning in a regular
|
||||
* expression. Returns a new escaped string, or self if no characters are
|
||||
* escaped. For any string,
|
||||
* <code>Regexp.escape(<i>str</i>)=~<i>str</i></code> will be true.
|
||||
*
|
||||
*
|
||||
* Regexp.escape('\\*?{}.') #=> \\\\\*\?\{\}\.
|
||||
*/
|
||||
|
||||
|
@ -2090,12 +2090,12 @@ rb_reg_s_union(self, args0)
|
|||
* call-seq:
|
||||
* Regexp.union(pat1, pat2, ...) => new_regexp
|
||||
* Regexp.union(pats_ary) => new_regexp
|
||||
*
|
||||
*
|
||||
* Return a <code>Regexp</code> object that is the union of the given
|
||||
* <em>pattern</em>s, i.e., will match any of its parts. The <em>pattern</em>s
|
||||
* can be Regexp objects, in which case their options will be preserved, or
|
||||
* Strings. If no patterns are given, returns <code>/(?!)/</code>.
|
||||
*
|
||||
*
|
||||
* Regexp.union #=> /(?!)/
|
||||
* Regexp.union("penzance") #=> /penzance/
|
||||
* Regexp.union("a+b*c") #=> /a\+b\*c/
|
||||
|
@ -2320,7 +2320,7 @@ match_setter(val)
|
|||
* call-seq:
|
||||
* Regexp.last_match => matchdata
|
||||
* Regexp.last_match(fixnum) => str
|
||||
*
|
||||
*
|
||||
* The first form returns the <code>MatchData</code> object generated by the
|
||||
* last successful pattern match. Equivalent to reading the global variable
|
||||
* <code>$~</code>. The second form returns the nth field in this
|
||||
|
@ -2328,7 +2328,7 @@ match_setter(val)
|
|||
*
|
||||
* Note that the <code>last_match</code> is local to the scope
|
||||
* of the method that did the pattern match.
|
||||
*
|
||||
*
|
||||
* /c(.)t/ =~ 'cat' #=> 0
|
||||
* Regexp.last_match #=> #<MatchData:0x401b3d30>
|
||||
* Regexp.last_match(0) #=> "cat"
|
||||
|
@ -2352,9 +2352,9 @@ rb_reg_s_last_match(argc, argv)
|
|||
/*
|
||||
* call-seq:
|
||||
* str.ord => integer
|
||||
*
|
||||
*
|
||||
* Return the <code>Integer</code> ordinal of a one-character string.
|
||||
*
|
||||
*
|
||||
* "a".ord #=> 97
|
||||
*/
|
||||
|
||||
|
|
144
regex.c
144
regex.c
|
@ -222,12 +222,12 @@ init_syntax_once()
|
|||
memset(re_syntax_table, 0, sizeof re_syntax_table);
|
||||
|
||||
for (c=0; c<=0x7f; c++)
|
||||
if (isalnum(c))
|
||||
if (isalnum(c))
|
||||
re_syntax_table[c] = Sword;
|
||||
re_syntax_table['_'] = Sword;
|
||||
|
||||
for (c=0x80; c<=0xff; c++)
|
||||
if (isalnum(c))
|
||||
if (isalnum(c))
|
||||
re_syntax_table[c] = Sword2;
|
||||
done = 1;
|
||||
}
|
||||
|
@ -320,9 +320,9 @@ enum regexpcode
|
|||
begpos, /* Matches where last scan//gsub left off. */
|
||||
jump, /* Followed by two bytes giving relative address to jump to. */
|
||||
jump_past_alt,/* Same as jump, but marks the end of an alternative. */
|
||||
on_failure_jump, /* Followed by two bytes giving relative address of
|
||||
on_failure_jump, /* Followed by two bytes giving relative address of
|
||||
place to resume at in case of failure. */
|
||||
finalize_jump, /* Throw away latest failure point and then jump to
|
||||
finalize_jump, /* Throw away latest failure point and then jump to
|
||||
address. */
|
||||
maybe_finalize_jump, /* Like jump but finalize if safe to do so.
|
||||
This is used to jump back to the beginning
|
||||
|
@ -332,9 +332,9 @@ enum regexpcode
|
|||
we can be sure that there is no use backtracking
|
||||
out of repetitions already completed,
|
||||
then we finalize. */
|
||||
dummy_failure_jump, /* Jump, and push a dummy failure point. This
|
||||
failure point will be thrown away if an attempt
|
||||
is made to use it for a failure. A + construct
|
||||
dummy_failure_jump, /* Jump, and push a dummy failure point. This
|
||||
failure point will be thrown away if an attempt
|
||||
is made to use it for a failure. A + construct
|
||||
makes this before the first repeat. Also
|
||||
use it as an intermediary kind of jump when
|
||||
compiling an or construct. */
|
||||
|
@ -383,7 +383,7 @@ enum regexpcode
|
|||
pop_and_fail, /* Fail after popping nowidth entry from stack. */
|
||||
stop_backtrack, /* Restore backtrack stack at the point start_nowidth. */
|
||||
duplicate, /* Match a duplicate of something remembered.
|
||||
Followed by one byte containing the index of the memory
|
||||
Followed by one byte containing the index of the memory
|
||||
register. */
|
||||
wordchar, /* Matches any word-constituent character. */
|
||||
notwordchar, /* Matches any char that is not a word-constituent. */
|
||||
|
@ -448,7 +448,7 @@ re_set_syntax(syntax)
|
|||
|
||||
#define TRANSLATE_P() ((options&RE_OPTION_IGNORECASE) && translate)
|
||||
#define MAY_TRANSLATE() ((bufp->options&(RE_OPTION_IGNORECASE|RE_MAY_IGNORECASE)) && translate)
|
||||
/* Fetch the next character in the uncompiled pattern---translating it
|
||||
/* Fetch the next character in the uncompiled pattern---translating it
|
||||
if necessary. Also cast from a signed character in the constant
|
||||
string passed to us by the user to an unsigned char that we can use
|
||||
as an array index (in, e.g., `translate'). */
|
||||
|
@ -535,7 +535,7 @@ print_mbc(c)
|
|||
else if (c <= 0xffff)
|
||||
printf("%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 6) & 0x3f),
|
||||
(int)(c & 0x3f));
|
||||
else if (c <= 0x1fffff)
|
||||
else if (c <= 0x1fffff)
|
||||
printf("%c%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 12) & 0x3f),
|
||||
(int)((c >> 6) & 0x3f), (int)(c & 0x3f));
|
||||
else if (c <= 0x3ffffff)
|
||||
|
@ -732,7 +732,7 @@ is_in_list_sbc(c, b)
|
|||
size = *b++;
|
||||
return ((int)c / BYTEWIDTH < (int)size && b[c / BYTEWIDTH] & 1 << c % BYTEWIDTH);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
is_in_list_mbc(c, b)
|
||||
unsigned long c;
|
||||
|
@ -934,19 +934,19 @@ print_partial_compiled_pattern(start, end)
|
|||
printf("/jump//%d", mcnt);
|
||||
break;
|
||||
|
||||
case succeed_n:
|
||||
case succeed_n:
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt2, p);
|
||||
printf("/succeed_n//%d//%d", mcnt, mcnt2);
|
||||
break;
|
||||
|
||||
case jump_n:
|
||||
case jump_n:
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt2, p);
|
||||
printf("/jump_n//%d//%d", mcnt, mcnt2);
|
||||
break;
|
||||
|
||||
case set_number_at:
|
||||
case set_number_at:
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt2, p);
|
||||
printf("/set_number_at//%d//%d", mcnt, mcnt2);
|
||||
|
@ -986,7 +986,7 @@ print_partial_compiled_pattern(start, end)
|
|||
case wordchar:
|
||||
printf("/wordchar");
|
||||
break;
|
||||
|
||||
|
||||
case notwordchar:
|
||||
printf("/notwordchar");
|
||||
break;
|
||||
|
@ -1108,7 +1108,7 @@ calculate_must_string(start, end)
|
|||
break;
|
||||
|
||||
case dummy_failure_jump:
|
||||
case succeed_n:
|
||||
case succeed_n:
|
||||
case try_next:
|
||||
case jump:
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||
|
@ -1124,8 +1124,8 @@ calculate_must_string(start, end)
|
|||
p += 2;
|
||||
break;
|
||||
|
||||
case jump_n:
|
||||
case set_number_at:
|
||||
case jump_n:
|
||||
case set_number_at:
|
||||
case finalize_push_n:
|
||||
p += 4;
|
||||
break;
|
||||
|
@ -1363,8 +1363,8 @@ re_compile_pattern(pattern, size, bufp)
|
|||
case '*':
|
||||
/* If there is no previous pattern, char not special. */
|
||||
if (!laststart) {
|
||||
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
|
||||
"invalid regular expression; there's no previous pattern, to which '%c' would define cardinality at %ld",
|
||||
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
|
||||
"invalid regular expression; there's no previous pattern, to which '%c' would define cardinality at %ld",
|
||||
c, (long)(p-pattern));
|
||||
FREE_AND_RETURN(stackb, error_msg);
|
||||
}
|
||||
|
@ -1391,7 +1391,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
repeat:
|
||||
/* Star, etc. applied to an empty pattern is equivalent
|
||||
to an empty pattern. */
|
||||
if (!laststart)
|
||||
if (!laststart)
|
||||
break;
|
||||
|
||||
if (greedy && many_times_ok && *laststart == anychar && b - laststart <= 2) {
|
||||
|
@ -1455,7 +1455,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
|
||||
laststart = b;
|
||||
if (*p == '^') {
|
||||
BUFPUSH(charset_not);
|
||||
BUFPUSH(charset_not);
|
||||
p++;
|
||||
}
|
||||
else
|
||||
|
@ -1494,7 +1494,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
FREE_AND_RETURN(stackb, "invalid regular expression; empty character class");
|
||||
re_warning("character class has `]' without escape");
|
||||
}
|
||||
else
|
||||
else
|
||||
/* Stop if this isn't merely a ] inside a bracket
|
||||
expression, but rather the end of a bracket
|
||||
expression. */
|
||||
|
@ -1626,7 +1626,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
c1 = 0;
|
||||
|
||||
/* If pattern is `[[:'. */
|
||||
if (p == pend)
|
||||
if (p == pend)
|
||||
FREE_AND_RETURN(stackb, "invalid regular expression; re can't end '[[:'");
|
||||
|
||||
for (;;) {
|
||||
|
@ -1657,7 +1657,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
char is_xdigit = STREQ(str, "xdigit");
|
||||
|
||||
if (!IS_CHAR_CLASS(str)){
|
||||
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
|
||||
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
|
||||
"invalid regular expression; [:%s:] is not a character class", str);
|
||||
FREE_AND_RETURN(stackb, error_msg);
|
||||
}
|
||||
|
@ -1665,7 +1665,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
/* Throw away the ] at the end of the character class. */
|
||||
PATFETCH(c);
|
||||
|
||||
if (p == pend)
|
||||
if (p == pend)
|
||||
FREE_AND_RETURN(stackb, "invalid regular expression; range doesn't have ending ']' after a character class");
|
||||
|
||||
for (ch = 0; ch < 1 << BYTEWIDTH; ch++) {
|
||||
|
@ -1688,7 +1688,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
}
|
||||
else {
|
||||
c1 += 2;
|
||||
while (c1--)
|
||||
while (c1--)
|
||||
PATUNFETCH;
|
||||
re_warning("character class has `[' without escape");
|
||||
c = '[';
|
||||
|
@ -1703,11 +1703,11 @@ re_compile_pattern(pattern, size, bufp)
|
|||
range = 0;
|
||||
if (had_mbchar == 0) {
|
||||
if (TRANSLATE_P()) {
|
||||
for (;last<=c;last++)
|
||||
for (;last<=c;last++)
|
||||
SET_LIST_BIT(translate[last]);
|
||||
}
|
||||
else {
|
||||
for (;last<=c;last++)
|
||||
for (;last<=c;last++)
|
||||
SET_LIST_BIT(last);
|
||||
}
|
||||
}
|
||||
|
@ -1740,8 +1740,8 @@ re_compile_pattern(pattern, size, bufp)
|
|||
|
||||
/* Discard any character set/class bitmap bytes that are all
|
||||
0 at the end of the map. Decrement the map-length byte too. */
|
||||
while ((int)b[-1] > 0 && b[b[-1] - 1] == 0)
|
||||
b[-1]--;
|
||||
while ((int)b[-1] > 0 && b[b[-1] - 1] == 0)
|
||||
b[-1]--;
|
||||
if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH)
|
||||
memmove(&b[(unsigned char)b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH],
|
||||
2 + EXTRACT_UNSIGNED(&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8);
|
||||
|
@ -1857,7 +1857,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
/* Laststart should point to the start_memory that we are about
|
||||
to push (unless the pattern has RE_NREGS or more ('s). */
|
||||
/* obsolete: now RE_NREGS is just a default register size. */
|
||||
*stackp++ = b - bufp->buffer;
|
||||
*stackp++ = b - bufp->buffer;
|
||||
*stackp++ = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
|
||||
*stackp++ = begalt - bufp->buffer;
|
||||
switch (c) {
|
||||
|
@ -1911,7 +1911,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
break;
|
||||
|
||||
case ')':
|
||||
if (stackp == stackb)
|
||||
if (stackp == stackb)
|
||||
FREE_AND_RETURN(stackb, "unmatched )");
|
||||
|
||||
pending_exact = 0;
|
||||
|
@ -2000,10 +2000,10 @@ re_compile_pattern(pattern, size, bufp)
|
|||
jump (put in below, which in turn will jump to the next
|
||||
(if any) alternative's such jump, etc.). The last such
|
||||
jump jumps to the correct final destination. A picture:
|
||||
_____ _____
|
||||
| | | |
|
||||
| v | v
|
||||
a | b | c
|
||||
_____ _____
|
||||
| | | |
|
||||
| v | v
|
||||
a | b | c
|
||||
|
||||
If we are at `b', then fixup_alt_jump right now points to a
|
||||
three-byte space after `a'. We'll put in the jump, set
|
||||
|
@ -2027,8 +2027,8 @@ re_compile_pattern(pattern, size, bufp)
|
|||
case '{':
|
||||
/* If there is no previous pattern, this is an invalid pattern. */
|
||||
if (!laststart) {
|
||||
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
|
||||
"invalid regular expression; there's no previous pattern, to which '{' would define cardinality at %ld",
|
||||
snprintf(error_msg, ERROR_MSG_MAX_SIZE,
|
||||
"invalid regular expression; there's no previous pattern, to which '{' would define cardinality at %ld",
|
||||
(long)(p-pattern));
|
||||
FREE_AND_RETURN(stackb, error_msg);
|
||||
}
|
||||
|
@ -2089,7 +2089,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
}
|
||||
}
|
||||
|
||||
/* If upper_bound is zero, don't want to succeed at all;
|
||||
/* If upper_bound is zero, don't want to succeed at all;
|
||||
jump from laststart to b + 3, which will be the end of
|
||||
the buffer after this jump is inserted. */
|
||||
|
||||
|
@ -2157,11 +2157,11 @@ re_compile_pattern(pattern, size, bufp)
|
|||
attendant `set_number_at' (inserted next),
|
||||
because `re_compile_fastmap' needs to know.
|
||||
Jump to the `jump_n' we might insert below. */
|
||||
insert_jump_n(succeed_n, laststart, b + (nbytes/2),
|
||||
insert_jump_n(succeed_n, laststart, b + (nbytes/2),
|
||||
b, lower_bound);
|
||||
b += 5; /* Just increment for the succeed_n here. */
|
||||
|
||||
/* Code to initialize the lower bound. Insert
|
||||
/* Code to initialize the lower bound. Insert
|
||||
before the `succeed_n'. The `5' is the last two
|
||||
bytes of this `set_number_at', plus 3 bytes of
|
||||
the following `succeed_n'. */
|
||||
|
@ -2209,7 +2209,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
beg_interval = 0;
|
||||
|
||||
/* normal_char and normal_backslash need `c'. */
|
||||
PATFETCH(c);
|
||||
PATFETCH(c);
|
||||
goto normal_char;
|
||||
|
||||
case '\\':
|
||||
|
@ -2254,8 +2254,8 @@ re_compile_pattern(pattern, size, bufp)
|
|||
}
|
||||
}
|
||||
|
||||
while ((int)b[-1] > 0 && b[b[-1] - 1] == 0)
|
||||
b[-1]--;
|
||||
while ((int)b[-1] > 0 && b[b[-1] - 1] == 0)
|
||||
b[-1]--;
|
||||
if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH)
|
||||
memmove(&b[(unsigned char)b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH],
|
||||
2 + EXTRACT_UNSIGNED(&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8);
|
||||
|
@ -2537,7 +2537,7 @@ store_jump(from, opcode, to)
|
|||
|
||||
|
||||
/* Open up space before char FROM, and insert there a jump to TO.
|
||||
CURRENT_END gives the end of the storage not in use, so we know
|
||||
CURRENT_END gives the end of the storage not in use, so we know
|
||||
how much data to copy up. OP is the opcode of the jump to insert.
|
||||
|
||||
If you call this function, you must zero out pending_exact. */
|
||||
|
@ -2550,7 +2550,7 @@ insert_jump(op, from, to, current_end)
|
|||
register char *pfrom = current_end; /* Copy from here... */
|
||||
register char *pto = current_end + 3; /* ...to here. */
|
||||
|
||||
while (pfrom != from)
|
||||
while (pfrom != from)
|
||||
*--pto = *--pfrom;
|
||||
store_jump(from, op, to);
|
||||
}
|
||||
|
@ -2593,7 +2593,7 @@ insert_jump_n(op, from, to, current_end, n)
|
|||
register char *pfrom = current_end; /* Copy from here... */
|
||||
register char *pto = current_end + 5; /* ...to here. */
|
||||
|
||||
while (pfrom != from)
|
||||
while (pfrom != from)
|
||||
*--pto = *--pfrom;
|
||||
store_jump_n(from, op, to, n);
|
||||
}
|
||||
|
@ -2614,7 +2614,7 @@ insert_op(op, there, current_end)
|
|||
register char *pfrom = current_end; /* Copy from here... */
|
||||
register char *pto = current_end + 1; /* ...to here. */
|
||||
|
||||
while (pfrom != there)
|
||||
while (pfrom != there)
|
||||
*--pto = *--pfrom;
|
||||
|
||||
there[0] = (char)op;
|
||||
|
@ -2637,7 +2637,7 @@ insert_op_2(op, there, current_end, num_1, num_2)
|
|||
register char *pfrom = current_end; /* Copy from here... */
|
||||
register char *pto = current_end + 5; /* ...to here. */
|
||||
|
||||
while (pfrom != there)
|
||||
while (pfrom != there)
|
||||
*--pto = *--pfrom;
|
||||
|
||||
there[0] = (char)op;
|
||||
|
@ -2787,7 +2787,7 @@ bm_search(little, llen, big, blen, skip, translate)
|
|||
that matches the pattern. This fastmap is used by re_search to skip
|
||||
quickly over totally implausible text.
|
||||
|
||||
The caller must supply the address of a (1 << BYTEWIDTH)-byte data
|
||||
The caller must supply the address of a (1 << BYTEWIDTH)-byte data
|
||||
area as bufp->fastmap.
|
||||
The other components of bufp describe the pattern to be used. */
|
||||
static int
|
||||
|
@ -2802,7 +2802,7 @@ re_compile_fastmap0(bufp)
|
|||
register int j, k;
|
||||
unsigned is_a_succeed_n;
|
||||
|
||||
|
||||
|
||||
unsigned char *stacka[NFAILURES];
|
||||
unsigned char **stackb = stacka;
|
||||
unsigned char **stackp = stackb;
|
||||
|
@ -2885,7 +2885,7 @@ re_compile_fastmap0(bufp)
|
|||
case finalize_push:
|
||||
case finalize_push_n:
|
||||
EXTRACT_NUMBER_AND_INCR(j, p);
|
||||
p += j;
|
||||
p += j;
|
||||
if (j > 0)
|
||||
continue;
|
||||
/* Jump backward reached implies we just went through
|
||||
|
@ -2901,7 +2901,7 @@ re_compile_fastmap0(bufp)
|
|||
continue;
|
||||
p++;
|
||||
EXTRACT_NUMBER_AND_INCR(j, p);
|
||||
p += j;
|
||||
p += j;
|
||||
if (stackp != stackb && *stackp == p)
|
||||
stackp--; /* pop */
|
||||
continue;
|
||||
|
@ -3358,7 +3358,7 @@ re_search(bufp, string, size, startpos, range, regs)
|
|||
}
|
||||
|
||||
advance:
|
||||
if (!range)
|
||||
if (!range)
|
||||
break;
|
||||
else if (range > 0) {
|
||||
const char *d = string + startpos;
|
||||
|
@ -3378,7 +3378,7 @@ re_search(bufp, string, size, startpos, range, regs)
|
|||
|
||||
s = string; d = string + startpos;
|
||||
for (p = d; p-- > s && ismbchar(*p); )
|
||||
/* --p >= s would not work on 80[12]?86.
|
||||
/* --p >= s would not work on 80[12]?86.
|
||||
(when the offset of s equals 0 other than huge model.) */
|
||||
;
|
||||
if (!((d - p) & 1)) {
|
||||
|
@ -3640,7 +3640,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
register_info_type *reg_info = bufp->reg_info;
|
||||
|
||||
/* The following record the register info as found in the above
|
||||
variables when we find a match better than any we've seen before.
|
||||
variables when we find a match better than any we've seen before.
|
||||
This happens as we backtrack through the failure points, which in
|
||||
turn happens only if we have not yet matched the entire string. */
|
||||
|
||||
|
@ -3726,7 +3726,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
best_regend[mcnt] = regend[mcnt];
|
||||
}
|
||||
}
|
||||
goto fail;
|
||||
goto fail;
|
||||
}
|
||||
/* If no failure points, don't restore garbage. */
|
||||
else if (best_regs_set) {
|
||||
|
@ -3741,7 +3741,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
}
|
||||
}
|
||||
|
||||
/* If caller wants register contents data back, convert it
|
||||
/* If caller wants register contents data back, convert it
|
||||
to indices. */
|
||||
if (regs) {
|
||||
regs->beg[0] = pos;
|
||||
|
@ -3829,8 +3829,8 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
|
||||
/* Compare that many; failure if mismatch, else move
|
||||
past them. */
|
||||
if ((options & RE_OPTION_IGNORECASE)
|
||||
? memcmp_translate(d, d2, mcnt)
|
||||
if ((options & RE_OPTION_IGNORECASE)
|
||||
? memcmp_translate(d, d2, mcnt)
|
||||
: memcmp((char*)d, (char*)d2, mcnt))
|
||||
goto fail;
|
||||
d += mcnt, d2 += mcnt;
|
||||
|
@ -3986,7 +3986,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
tensioning the jumps is a hassle.) */
|
||||
|
||||
/* The start of a stupid repeat has an on_failure_jump that points
|
||||
past the end of the repeat text. This makes a failure point so
|
||||
past the end of the repeat text. This makes a failure point so
|
||||
that on failure to match a repetition, matching restarts past
|
||||
as many repetitions have been found with no way to fail and
|
||||
look for another one. */
|
||||
|
@ -4065,7 +4065,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
}
|
||||
p -= 2; /* Point at relative address again. */
|
||||
if (p[-1] != (unsigned char)finalize_jump) {
|
||||
p[-1] = (unsigned char)jump;
|
||||
p[-1] = (unsigned char)jump;
|
||||
goto nofinalize;
|
||||
}
|
||||
/* Note fall through. */
|
||||
|
@ -4074,7 +4074,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
start, where another failure point will be made which will
|
||||
point to after all the repetitions found so far. */
|
||||
|
||||
/* Take off failure points put on by matching on_failure_jump
|
||||
/* Take off failure points put on by matching on_failure_jump
|
||||
because didn't fail. Also remove the register information
|
||||
put on by the on_failure_jump. */
|
||||
case finalize_jump:
|
||||
|
@ -4083,7 +4083,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
POP_FAILURE_POINT();
|
||||
continue;
|
||||
}
|
||||
POP_FAILURE_POINT();
|
||||
POP_FAILURE_POINT();
|
||||
/* Note fall through. */
|
||||
|
||||
/* We need this opcode so we can detect where alternatives end
|
||||
|
@ -4137,7 +4137,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
|
||||
/* Have to succeed matching what follows at least n times. Then
|
||||
just handle like an on_failure_jump. */
|
||||
case succeed_n:
|
||||
case succeed_n:
|
||||
EXTRACT_NUMBER(mcnt, p + 2);
|
||||
/* Originally, this is how many times we HAVE to succeed. */
|
||||
if (mcnt != 0) {
|
||||
|
@ -4163,8 +4163,8 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
any failure points. */
|
||||
}
|
||||
/* If don't have to jump any more, skip over the rest of command. */
|
||||
else
|
||||
p += 4;
|
||||
else
|
||||
p += 4;
|
||||
continue;
|
||||
|
||||
case set_number_at:
|
||||
|
@ -4193,7 +4193,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
continue;
|
||||
|
||||
case finalize_push_n:
|
||||
EXTRACT_NUMBER(mcnt, p + 2);
|
||||
EXTRACT_NUMBER(mcnt, p + 2);
|
||||
/* Originally, this is how many times we CAN jump. */
|
||||
if (mcnt) {
|
||||
int pos, i;
|
||||
|
@ -4210,8 +4210,8 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
p += 2; /* skip n */
|
||||
}
|
||||
/* If don't have to push any more, skip over the rest of command. */
|
||||
else
|
||||
p += 4;
|
||||
else
|
||||
p += 4;
|
||||
continue;
|
||||
|
||||
/* Ignore these. Used to ignore the n of succeed_n's which
|
||||
|
@ -4301,7 +4301,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
|||
|
||||
PREFETCH;
|
||||
if (*p == 0xff) {
|
||||
p++;
|
||||
p++;
|
||||
if (!--mcnt
|
||||
|| AT_STRINGS_END(d)
|
||||
|| (unsigned char)*d++ != (unsigned char)*p++)
|
||||
|
|
2
regex.h
2
regex.h
|
@ -55,7 +55,7 @@
|
|||
|
||||
/* Maximum number of duplicates an interval can allow. */
|
||||
#ifndef RE_DUP_MAX
|
||||
#define RE_DUP_MAX ((1 << 15) - 1)
|
||||
#define RE_DUP_MAX ((1 << 15) - 1)
|
||||
#endif
|
||||
|
||||
|
||||
|
|
10
signal.c
10
signal.c
|
@ -298,14 +298,14 @@ ruby_default_signal(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 ...
|
||||
|
@ -313,9 +313,9 @@ ruby_default_signal(sig)
|
|||
* # ...
|
||||
* Process.kill("HUP", pid)
|
||||
* Process.wait
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Ouch!
|
||||
*/
|
||||
|
||||
|
@ -965,7 +965,7 @@ install_sighandler(signum, handler)
|
|||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
/*
|
||||
* If you write a handler which works on any native thread
|
||||
* (even if the thread is NOT a ruby's one), please enable
|
||||
* this function and use it to install the handler, instead
|
||||
|
|
20
sprintf.c
20
sprintf.c
|
@ -29,7 +29,7 @@ remove_sign_bits(str, base)
|
|||
int base;
|
||||
{
|
||||
char *s, *t;
|
||||
|
||||
|
||||
s = t = str;
|
||||
|
||||
if (base == 16) {
|
||||
|
@ -144,7 +144,7 @@ sign_bits(base, p)
|
|||
* 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. A format
|
||||
|
@ -157,7 +157,7 @@ sign_bits(base, p)
|
|||
*
|
||||
* Flag | Applies to | Meaning
|
||||
* ---------+--------------+-----------------------------------------
|
||||
* space | bdeEfgGiouxX | Leave a space at the start of
|
||||
* space | bdeEfgGiouxX | Leave a space at the start of
|
||||
* | | positive numbers.
|
||||
* ---------+--------------+-----------------------------------------
|
||||
* (digit)$ | all | Specifies the absolute argument number
|
||||
|
@ -166,7 +166,7 @@ sign_bits(base, p)
|
|||
* | | sprintf string.
|
||||
* ---------+--------------+-----------------------------------------
|
||||
* # | beEfgGoxX | Use an alternative format. For the
|
||||
* | | conversions `o', `x', `X', and `b',
|
||||
* | | conversions `o', `x', `X', and `b',
|
||||
* | | prefix the result with ``0'', ``0x'', ``0X'',
|
||||
* | | and ``0b'', respectively. For `e',
|
||||
* | | `E', `f', `g', and 'G', force a decimal
|
||||
|
@ -179,12 +179,12 @@ sign_bits(base, p)
|
|||
* ---------+--------------+-----------------------------------------
|
||||
* 0 (zero) | bdeEfgGiouxX | Pad with zeros, not spaces.
|
||||
* ---------+--------------+-----------------------------------------
|
||||
* * | 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.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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. For
|
||||
|
@ -203,10 +203,10 @@ sign_bits(base, p)
|
|||
* d | Convert argument as a decimal number.
|
||||
* E | Equivalent to `e', but uses an uppercase E to indicate
|
||||
* | the exponent.
|
||||
* e | Convert floating point argument into exponential notation
|
||||
* e | Convert floating point argument into exponential notation
|
||||
* | with one digit before the decimal point. The precision
|
||||
* | determines the number of fractional digits (defaulting to six).
|
||||
* f | Convert floating point argument as [-]ddd.ddd,
|
||||
* f | Convert floating point argument as [-]ddd.ddd,
|
||||
* | where the precision determines the number of digits after
|
||||
* | the decimal point.
|
||||
* G | Equivalent to `g', but use an uppercase `E' in exponent form.
|
||||
|
@ -233,7 +233,7 @@ sign_bits(base, p)
|
|||
* | Negative numbers will be displayed with two
|
||||
* | leading periods (representing an infinite string of
|
||||
* | leading 'ff's.
|
||||
*
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* sprintf("%d %04x", 123, 123) #=> "123 007b"
|
||||
|
|
70
struct.c
70
struct.c
|
@ -83,10 +83,10 @@ rb_struct_s_members_m(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"]
|
||||
|
@ -277,7 +277,7 @@ rb_struct_define(name, va_alist)
|
|||
* <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
|
||||
|
@ -286,12 +286,12 @@ rb_struct_define(name, va_alist)
|
|||
* 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::Customer name="Dave", address="123 Main">
|
||||
*
|
||||
*
|
||||
* # Create a structure named by its constant
|
||||
* Customer = Struct.new(:name, :address) #=> Customer
|
||||
* Customer.new("Dave", "123 Main") #=> #<Customer name="Dave", address="123 Main">
|
||||
|
@ -413,16 +413,16 @@ rb_struct_new(klass, va_alist)
|
|||
/*
|
||||
* 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
|
||||
|
@ -444,16 +444,16 @@ rb_struct_each(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
|
||||
|
@ -540,9 +540,9 @@ rb_struct_inspect(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"
|
||||
|
@ -595,17 +595,17 @@ rb_struct_aref_id(s, 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"
|
||||
|
@ -660,19 +660,19 @@ rb_struct_aset_id(s, id, 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"
|
||||
*/
|
||||
|
@ -710,15 +710,15 @@ struct_entry(s, 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)
|
||||
|
@ -738,12 +738,12 @@ rb_struct_values_at(argc, argv, 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]
|
||||
|
@ -774,12 +774,12 @@ rb_struct_select(argc, argv, 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)
|
||||
|
@ -861,9 +861,9 @@ rb_struct_eql(s, 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
|
||||
|
@ -880,13 +880,13 @@ rb_struct_size(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>).
|
||||
|
|
134
time.c
134
time.c
|
@ -92,18 +92,18 @@ time_modify(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 #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* b = Time.new #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* a == b #=> false
|
||||
* "%.6f" % a.to_f #=> "1049896563.230740"
|
||||
* "%.6f" % b.to_f #=> "1049896563.231466"
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -263,12 +263,12 @@ rb_time_timeval(time)
|
|||
* call-seq:
|
||||
* Time.at( aTime ) => time
|
||||
* Time.at( seconds [, microseconds] ) => time
|
||||
*
|
||||
*
|
||||
* Creates a new time object with the value given by <i>aTime</i>, or
|
||||
* the given number of <i>seconds</i> (and optional
|
||||
* <i>microseconds</i>) from epoch. A non-portable feature allows the
|
||||
* offset to be negative on some systems.
|
||||
*
|
||||
*
|
||||
* Time.at(0) #=> Wed Dec 31 18:00:00 CST 1969
|
||||
* Time.at(946702800) #=> Fri Dec 31 23:00:00 CST 1999
|
||||
* Time.at(-284061600) #=> Sat Dec 31 00:00:00 CST 1960
|
||||
|
@ -592,7 +592,7 @@ search_time_t(tptr, 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
|
||||
|
@ -651,7 +651,7 @@ search_time_t(tptr, 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;
|
||||
|
@ -837,7 +837,7 @@ time_utc_or_local(argc, argv, utc_p, klass)
|
|||
* Time.gm( year [, month, day, hour, min, sec, usec] ) => 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
|
||||
|
@ -865,10 +865,10 @@ time_s_mkutc(argc, argv, klass)
|
|||
* Time.local( sec, min, hour, day, month, year, wday, yday, isdst,
|
||||
* tz ) => time
|
||||
* Time.mktime( year, month, day, hour, min, sec, usec ) => time
|
||||
*
|
||||
*
|
||||
* Same as <code>Time::gm</code>, but interprets the values in the
|
||||
* local time zone.
|
||||
*
|
||||
*
|
||||
* Time.local(2000,"jan",1,20,15,1) #=> Sat Jan 01 20:15:01 CST 2000
|
||||
*/
|
||||
|
||||
|
@ -885,10 +885,10 @@ time_s_mktime(argc, argv, 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 epoch.
|
||||
*
|
||||
*
|
||||
* t = Time.now
|
||||
* "%10.5f" % t.to_f #=> "1049896564.17839"
|
||||
* t.to_i #=> 1049896564
|
||||
|
@ -907,10 +907,10 @@ time_to_i(time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.to_f => float
|
||||
*
|
||||
*
|
||||
* Returns the value of <i>time</i> as a floating point number of
|
||||
* seconds since epoch.
|
||||
*
|
||||
*
|
||||
* t = Time.now
|
||||
* "%10.5f" % t.to_f #=> "1049896564.13654"
|
||||
* t.to_i #=> 1049896564
|
||||
|
@ -930,9 +930,9 @@ time_to_f(time)
|
|||
* call-seq:
|
||||
* time.usec => int
|
||||
* time.tv_usec => int
|
||||
*
|
||||
*
|
||||
* Returns just the number of microseconds for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003
|
||||
* "%10.6f" % t.to_f #=> "1049896564.259970"
|
||||
* t.usec #=> 259970
|
||||
|
@ -950,13 +950,13 @@ time_usec(time)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* time <=> other_time => -1, 0, +1
|
||||
* time <=> other_time => -1, 0, +1
|
||||
* time <=> numeric => -1, 0, +1
|
||||
*
|
||||
*
|
||||
* Comparison---Compares <i>time</i> with <i>other_time</i> or with
|
||||
* <i>numeric</i>, which is the number of seconds (possibly
|
||||
* fractional) since epoch.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* t2 = t + 2592000 #=> Fri May 09 08:56:03 CDT 2003
|
||||
* t <=> t2 #=> -1
|
||||
|
@ -1014,10 +1014,10 @@ time_eql(time1, 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 #=> Wed Apr 09 08:56:04 CDT 2003
|
||||
* t.utc? #=> false
|
||||
* t = Time.gm(2000,"jan",1,20,15,1) #=> Sat Jan 01 20:15:01 UTC 2000
|
||||
|
@ -1090,10 +1090,10 @@ time_dup(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)
|
||||
* t.gmt? #=> true
|
||||
* t.localtime #=> Sat Jan 01 14:15:01 CST 2000
|
||||
|
@ -1130,9 +1130,9 @@ time_localtime(time)
|
|||
* call-seq:
|
||||
* time.gmtime => time
|
||||
* time.utc => time
|
||||
*
|
||||
*
|
||||
* Converts <i>time</i> to UTC (GMT), modifying the receiver.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* t.gmt? #=> false
|
||||
* t.gmtime #=> Wed Apr 09 13:56:03 UTC 2003
|
||||
|
@ -1173,10 +1173,10 @@ time_gmtime(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) #=> Sat Jan 01 20:15:01 UTC 2000
|
||||
* t.gmt? #=> true
|
||||
* l = t.getlocal #=> Sat Jan 01 14:15:01 CST 2000
|
||||
|
@ -1195,10 +1195,10 @@ time_getlocaltime(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) #=> Sat Jan 01 20:15:01 CST 2000
|
||||
* t.gmt? #=> false
|
||||
* y = t.getgm #=> Sun Jan 02 02:15:01 UTC 2000
|
||||
|
@ -1226,9 +1226,9 @@ time_get_tm(time, 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"
|
||||
*/
|
||||
|
||||
|
@ -1253,12 +1253,12 @@ time_asctime(time)
|
|||
* 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>%a</code>
|
||||
* <code>%b</code> <code>%d</code> <code>%H:%M:%S</code>
|
||||
* <code>%Z</code> <code>%Y</code>''.
|
||||
*
|
||||
*
|
||||
* Time.now.to_s #=> "Wed Apr 09 08:56:04 CDT 2003"
|
||||
*/
|
||||
|
||||
|
@ -1344,10 +1344,10 @@ time_add(tobj, offset, 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 #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* t + (60 * 60 * 24) #=> Thu Apr 10 08:56:03 CDT 2003
|
||||
*/
|
||||
|
@ -1369,11 +1369,11 @@ time_plus(time1, 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 #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* t2 = t + 2592000 #=> Fri May 09 08:56:03 CDT 2003
|
||||
* t2 - t #=> 2592000.0
|
||||
|
@ -1426,12 +1426,12 @@ time_succ(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 #=> Wed Apr 09 08:56:04 CDT 2003
|
||||
* t.sec #=> 4
|
||||
*/
|
||||
|
@ -1452,9 +1452,9 @@ time_sec(time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.min => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the minute of the hour (0..59) for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* t.min #=> 56
|
||||
*/
|
||||
|
@ -1475,9 +1475,9 @@ time_min(time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.hour => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the hour of the day (0..23) for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* t.hour #=> 8
|
||||
*/
|
||||
|
@ -1499,9 +1499,9 @@ time_hour(time)
|
|||
* call-seq:
|
||||
* time.day => fixnum
|
||||
* time.mday => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the day of the month (1..n) for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* t.day #=> 9
|
||||
* t.mday #=> 9
|
||||
|
@ -1524,9 +1524,9 @@ time_mday(time)
|
|||
* call-seq:
|
||||
* time.mon => fixnum
|
||||
* time.month => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the month of the year (1..12) for <i>time</i>.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:03 CDT 2003
|
||||
* t.mon #=> 4
|
||||
* t.month #=> 4
|
||||
|
@ -1548,9 +1548,9 @@ time_mon(time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.year => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the year for <i>time</i> (including the century).
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003
|
||||
* t.year #=> 2003
|
||||
*/
|
||||
|
@ -1571,10 +1571,10 @@ time_year(time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.wday => fixnum
|
||||
*
|
||||
*
|
||||
* Returns an integer representing the day of the week, 0..6, with
|
||||
* Sunday == 0.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003
|
||||
* t.wday #=> 3
|
||||
*/
|
||||
|
@ -1595,9 +1595,9 @@ time_wday(time)
|
|||
/*
|
||||
* call-seq:
|
||||
* time.yday => fixnum
|
||||
*
|
||||
*
|
||||
* Returns an integer representing the day of the year, 1..366.
|
||||
*
|
||||
*
|
||||
* t = Time.now #=> Wed Apr 09 08:56:04 CDT 2003
|
||||
* t.yday #=> 99
|
||||
*/
|
||||
|
@ -1619,10 +1619,10 @@ time_yday(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.
|
||||
*
|
||||
*
|
||||
* Time.local(2000, 7, 1).isdst #=> true
|
||||
* Time.local(2000, 1, 1).isdst #=> false
|
||||
* Time.local(2000, 7, 1).dst? #=> true
|
||||
|
@ -1645,10 +1645,10 @@ time_isdst(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)
|
||||
|
@ -1664,7 +1664,7 @@ time_zone(time)
|
|||
char buf[64];
|
||||
int len;
|
||||
#endif
|
||||
|
||||
|
||||
GetTimeval(time, tobj);
|
||||
if (tobj->tm_got == 0) {
|
||||
time_get_tm(time, tobj->gmt);
|
||||
|
@ -1688,10 +1688,10 @@ time_zone(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) #=> Sat Jan 01 20:15:01 UTC 2000
|
||||
* t.gmt_offset #=> 0
|
||||
* l = t.getlocal #=> Sat Jan 01 14:15:01 CST 2000
|
||||
|
@ -1743,14 +1743,14 @@ time_utc_offset(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>.
|
||||
*
|
||||
*
|
||||
* now = Time.now #=> Wed Apr 09 08:56:04 CDT 2003
|
||||
* t = now.to_a #=> [4, 56, 8, 9, 4, 2003, 3, 99, true, "CDT"]
|
||||
*/
|
||||
|
@ -1815,7 +1815,7 @@ rb_strftime(buf, format, time)
|
|||
/*
|
||||
* 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.
|
||||
|
@ -1847,7 +1847,7 @@ rb_strftime(buf, format, time)
|
|||
* %Y - Year with century
|
||||
* %Z - Time zone name
|
||||
* %% - Literal ``%'' character
|
||||
*
|
||||
*
|
||||
* t = Time.now
|
||||
* t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
|
||||
* t.strftime("at %I:%M%p") #=> "at 08:56AM"
|
||||
|
@ -1903,7 +1903,7 @@ time_strftime(time, format)
|
|||
/*
|
||||
* call-seq:
|
||||
* Time.times => struct_tms
|
||||
*
|
||||
*
|
||||
* Deprecated in favor of <code>Process::times</code>
|
||||
*/
|
||||
|
||||
|
@ -1976,7 +1976,7 @@ time_dump(argc, argv, time)
|
|||
VALUE str;
|
||||
|
||||
rb_scan_args(argc, argv, "01", 0);
|
||||
str = time_mdump(time);
|
||||
str = time_mdump(time);
|
||||
if (FL_TEST(time, FL_EXIVAR)) {
|
||||
rb_copy_generic_ivar(str, time);
|
||||
FL_SET(str, FL_EXIVAR);
|
||||
|
@ -2077,7 +2077,7 @@ time_load(klass, 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 microseconds. Be aware of
|
||||
* this fact when comparing times with each other---times that are
|
||||
* apparently equal when displayed may be different when compared.
|
||||
|
|
14
util.c
14
util.c
|
@ -106,11 +106,11 @@ scan_hex(start, len, retlen)
|
|||
* 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.
|
||||
*
|
||||
|
@ -146,7 +146,7 @@ scan_hex(start, len, retlen)
|
|||
* longname.fil => longname.fi~
|
||||
* longname.fi~ => longnam~.fi~
|
||||
* longnam~.fi~ => longnam~.$$$
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
@ -206,7 +206,7 @@ ruby_add_suffix(str, suffix)
|
|||
strcpy(p, suffix);
|
||||
}
|
||||
else if (suffix[1] == '\0') { /* Style 2 */
|
||||
if (extlen < 4) {
|
||||
if (extlen < 4) {
|
||||
ext[extlen] = *suffix;
|
||||
ext[++extlen] = '\0';
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ extern int _close(int);
|
|||
extern int _unlink(const char *);
|
||||
#endif
|
||||
|
||||
static int
|
||||
static int
|
||||
valid_filename(char *s)
|
||||
{
|
||||
int fd;
|
||||
|
|
44
variable.c
44
variable.c
|
@ -171,7 +171,7 @@ classname(klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.name => string
|
||||
*
|
||||
*
|
||||
* Returns the name of the module <i>mod</i>.
|
||||
*/
|
||||
|
||||
|
@ -556,7 +556,7 @@ rb_trace_eval(cmd, val)
|
|||
* call-seq:
|
||||
* trace_var(symbol, cmd ) => nil
|
||||
* trace_var(symbol) {|val| block } => nil
|
||||
*
|
||||
*
|
||||
* Controls tracing of assignments to global variables. The parameter
|
||||
* +symbol_ identifies the variable (as either a string name or a
|
||||
* symbol identifier). _cmd_ (which may be a string or a
|
||||
|
@ -564,13 +564,13 @@ rb_trace_eval(cmd, val)
|
|||
* is assigned. The block or +Proc+ object receives the
|
||||
* variable's new value as a parameter. Also see
|
||||
* <code>Kernel::untrace_var</code>.
|
||||
*
|
||||
*
|
||||
* trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
|
||||
* $_ = "hello"
|
||||
* $_ = ' there'
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* $_ is now 'hello'
|
||||
* $_ is now ' there'
|
||||
*/
|
||||
|
@ -631,7 +631,7 @@ remove_trace(var)
|
|||
/*
|
||||
* call-seq:
|
||||
* untrace_var(symbol [, cmd] ) => array or nil
|
||||
*
|
||||
*
|
||||
* Removes tracing for the specified command on the given global
|
||||
* variable and returns +nil+. If no command is specified,
|
||||
* removes all tracing for that variable and returns an array
|
||||
|
@ -781,9 +781,9 @@ gvar_i(key, entry, ary)
|
|||
/*
|
||||
* call-seq:
|
||||
* global_variables => array
|
||||
*
|
||||
*
|
||||
* Returns an array of the names of global variables.
|
||||
*
|
||||
*
|
||||
* global_variables.grep /std/ #=> ["$stderr", "$stdout", "$stdin"]
|
||||
*/
|
||||
|
||||
|
@ -1118,11 +1118,11 @@ ivar_i(key, entry, ary)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.instance_variables => array
|
||||
*
|
||||
*
|
||||
* Returns an array of instance variable names for the receiver. Note
|
||||
* that simply defining an accessor does not create the corresponding
|
||||
* instance variable.
|
||||
*
|
||||
*
|
||||
* class Fred
|
||||
* attr_accessor :a1
|
||||
* def initialize
|
||||
|
@ -1164,10 +1164,10 @@ rb_obj_instance_variables(obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.remove_instance_variable(symbol) => obj
|
||||
*
|
||||
*
|
||||
* Removes the named instance variable from <i>obj</i>, returning that
|
||||
* variable's value.
|
||||
*
|
||||
*
|
||||
* class Dummy
|
||||
* attr_reader :var
|
||||
* def initialize
|
||||
|
@ -1255,7 +1255,7 @@ const_missing(klass, id)
|
|||
* assumed to be in file <code>fred.rb</code>). If found, it returns the
|
||||
* value of the loaded class. It therefore implements a perverse
|
||||
* kind of autoload facility.
|
||||
*
|
||||
*
|
||||
* def Object.const_missing(name)
|
||||
* @looked_for ||= {}
|
||||
* str_name = name.to_s
|
||||
|
@ -1267,7 +1267,7 @@ const_missing(klass, id)
|
|||
* return klass if klass
|
||||
* raise "Class not found: #{name}"
|
||||
* end
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
VALUE
|
||||
|
@ -1468,7 +1468,7 @@ rb_const_get_at(klass, id)
|
|||
/*
|
||||
* call-seq:
|
||||
* remove_const(sym) => obj
|
||||
*
|
||||
*
|
||||
* Removes the definition of the given constant, returning that
|
||||
* constant's value. Predefined classes and singleton objects (such as
|
||||
* <i>true</i>) cannot be removed.
|
||||
|
@ -1577,7 +1577,7 @@ rb_const_list(data)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.constants => array
|
||||
*
|
||||
*
|
||||
* Returns an array of the names of the constants accessible in
|
||||
* <i>mod</i>. This includes the names of constants in any included
|
||||
* modules (example at start of section).
|
||||
|
@ -1876,10 +1876,10 @@ cv_i(key, value, ary)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.class_variables => array
|
||||
*
|
||||
*
|
||||
* Returns an array of the names of class variables in <i>mod</i> and
|
||||
* the ancestors of <i>mod</i>.
|
||||
*
|
||||
*
|
||||
* class One
|
||||
* @@var1 = 1
|
||||
* end
|
||||
|
@ -1909,19 +1909,19 @@ rb_mod_class_variables(obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* remove_class_variable(sym) => obj
|
||||
*
|
||||
*
|
||||
* Removes the definition of the <i>sym</i>, returning that
|
||||
* constant's value.
|
||||
*
|
||||
*
|
||||
* class Dummy
|
||||
* @@var = 99
|
||||
* puts @@var
|
||||
* remove_class_variable(:@@var)
|
||||
* puts(defined? @@var)
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* 99
|
||||
* nil
|
||||
*/
|
||||
|
|
|
@ -60,7 +60,7 @@ Init_version()
|
|||
RUBY_BIRTH_YEAR, RUBY_RELEASE_YEAR,
|
||||
RUBY_AUTHOR);
|
||||
#endif
|
||||
|
||||
|
||||
rb_define_global_const("RUBY_VERSION", v);
|
||||
rb_define_global_const("RUBY_RELEASE_DATE", d);
|
||||
rb_define_global_const("RUBY_PLATFORM", p);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#define RUBY_VERSION "1.8.8"
|
||||
#define RUBY_RELEASE_DATE "2009-10-21"
|
||||
#define RUBY_RELEASE_DATE "2009-10-22"
|
||||
#define RUBY_VERSION_CODE 188
|
||||
#define RUBY_RELEASE_CODE 20091021
|
||||
#define RUBY_RELEASE_CODE 20091022
|
||||
#define RUBY_PATCHLEVEL -1
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define RUBY_VERSION_TEENY 8
|
||||
#define RUBY_RELEASE_YEAR 2009
|
||||
#define RUBY_RELEASE_MONTH 10
|
||||
#define RUBY_RELEASE_DAY 21
|
||||
#define RUBY_RELEASE_DAY 22
|
||||
|
||||
#ifdef RUBY_EXTERN
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
|
|
|
@ -1192,7 +1192,7 @@ cmdglob(NtCmdLineElement *patt, NtCmdLineElement **tail)
|
|||
return tail;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Check a command string to determine if it has I/O redirection
|
||||
// characters that require it to be executed by a command interpreter
|
||||
//
|
||||
|
@ -1246,7 +1246,7 @@ skipspace(char *ptr)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_cmdvector(const char *cmd, char ***vec)
|
||||
{
|
||||
int globbing, len;
|
||||
|
@ -1274,9 +1274,9 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
|
|||
//
|
||||
// Ok, parse the command line, building a list of CmdLineElements.
|
||||
// When we've finished, and it's an input command (meaning that it's
|
||||
// the processes argv), we'll do globing and then build the argument
|
||||
// the processes argv), we'll do globing and then build the argument
|
||||
// vector.
|
||||
// The outer loop does one interation for each element seen.
|
||||
// The outer loop does one interation for each element seen.
|
||||
// The inner loop does one interation for each character in the element.
|
||||
//
|
||||
|
||||
|
@ -1313,7 +1313,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
|
|||
case '?':
|
||||
case '[':
|
||||
case '{':
|
||||
//
|
||||
//
|
||||
// record the fact that this element has a wildcard character
|
||||
// N.B. Don't glob if inside a single quoted string
|
||||
//
|
||||
|
@ -1327,7 +1327,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
|
|||
case '\"':
|
||||
//
|
||||
// if we're already in a string, see if this is the
|
||||
// terminating close-quote. If it is, we're finished with
|
||||
// terminating close-quote. If it is, we're finished with
|
||||
// the string, but not neccessarily with the element.
|
||||
// If we're not already in a string, start one.
|
||||
//
|
||||
|
@ -1363,7 +1363,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
|
|||
if (done) --len;
|
||||
|
||||
//
|
||||
// if it's an input vector element and it's enclosed by quotes,
|
||||
// if it's an input vector element and it's enclosed by quotes,
|
||||
// we can remove them.
|
||||
//
|
||||
|
||||
|
@ -1425,10 +1425,10 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
|
|||
}
|
||||
|
||||
//
|
||||
// Almost done!
|
||||
// Almost done!
|
||||
// Count up the elements, then allocate space for a vector of pointers
|
||||
// (argv) and a string table for the elements.
|
||||
//
|
||||
//
|
||||
|
||||
for (elements = 0, strsz = 0, curr = cmdhead; curr; curr = curr->next) {
|
||||
elements++;
|
||||
|
@ -1448,7 +1448,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
|
|||
for (vptr = *vec; *vptr; ++vptr);
|
||||
return vptr - *vec;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// make vptr point to the start of the buffer
|
||||
// and ptr point to the area we'll consider the string table.
|
||||
|
@ -1490,7 +1490,7 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
|
|||
//
|
||||
// The idea here is to read all the directory names into a string table
|
||||
// (separated by nulls) and when one of the other dir functions is called
|
||||
// return the pointer to the current file name.
|
||||
// return the pointer to the current file name.
|
||||
//
|
||||
|
||||
#define GetBit(bits, i) ((bits)[(i) / CHAR_BIT] & (1 << (i) % CHAR_BIT))
|
||||
|
@ -1601,7 +1601,7 @@ rb_w32_opendir(const char *filename)
|
|||
|
||||
//
|
||||
// bump the string table size by enough for the
|
||||
// new name and it's null terminator
|
||||
// new name and it's null terminator
|
||||
//
|
||||
|
||||
newpath = (char *)realloc(p->start, idx + len);
|
||||
|
@ -1926,7 +1926,7 @@ is_socket(SOCKET fd)
|
|||
}
|
||||
|
||||
//
|
||||
// Since the errors returned by the socket error function
|
||||
// Since the errors returned by the socket error function
|
||||
// WSAGetLastError() are not known by the library routine strerror
|
||||
// we have to roll our own.
|
||||
//
|
||||
|
@ -2010,7 +2010,7 @@ getegid(void)
|
|||
|
||||
int
|
||||
setuid(rb_uid_t uid)
|
||||
{
|
||||
{
|
||||
return (uid == ROOT_UID ? 0 : -1);
|
||||
}
|
||||
|
||||
|
@ -2092,7 +2092,7 @@ rb_w32_fdisset(int fd, fd_set *set)
|
|||
|
||||
//
|
||||
// Networking trampolines
|
||||
// These are used to avoid socket startup/shutdown overhead in case
|
||||
// These are used to avoid socket startup/shutdown overhead in case
|
||||
// the socket routines aren't used.
|
||||
//
|
||||
|
||||
|
@ -2120,7 +2120,7 @@ extract_fd(fd_set *dst, fd_set *src, int (*func)(SOCKET))
|
|||
}
|
||||
memmove(
|
||||
&src->fd_array[s],
|
||||
&src->fd_array[s+1],
|
||||
&src->fd_array[s+1],
|
||||
sizeof(src->fd_array[0]) * (--src->fd_count - s));
|
||||
}
|
||||
else s++;
|
||||
|
@ -2261,7 +2261,7 @@ compare(const struct timeval *t1, const struct timeval *t2)
|
|||
}
|
||||
|
||||
#undef Sleep
|
||||
long
|
||||
long
|
||||
rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
|
||||
struct timeval *timeout)
|
||||
{
|
||||
|
@ -2468,7 +2468,7 @@ rb_w32_accept(int s, struct sockaddr *addr, int *addrlen)
|
|||
|
||||
#undef bind
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_bind(int s, struct sockaddr *addr, int addrlen)
|
||||
{
|
||||
int r;
|
||||
|
@ -2486,7 +2486,7 @@ rb_w32_bind(int s, struct sockaddr *addr, int addrlen)
|
|||
|
||||
#undef connect
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_connect(int s, struct sockaddr *addr, int addrlen)
|
||||
{
|
||||
int r;
|
||||
|
@ -2509,7 +2509,7 @@ rb_w32_connect(int s, struct sockaddr *addr, int addrlen)
|
|||
|
||||
#undef getpeername
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_getpeername(int s, struct sockaddr *addr, int *addrlen)
|
||||
{
|
||||
int r;
|
||||
|
@ -2526,7 +2526,7 @@ rb_w32_getpeername(int s, struct sockaddr *addr, int *addrlen)
|
|||
|
||||
#undef getsockname
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_getsockname(int s, struct sockaddr *addr, int *addrlen)
|
||||
{
|
||||
int r;
|
||||
|
@ -2541,7 +2541,7 @@ rb_w32_getsockname(int s, struct sockaddr *addr, int *addrlen)
|
|||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_getsockopt(int s, int level, int optname, char *optval, int *optlen)
|
||||
{
|
||||
int r;
|
||||
|
@ -2558,7 +2558,7 @@ rb_w32_getsockopt(int s, int level, int optname, char *optval, int *optlen)
|
|||
|
||||
#undef ioctlsocket
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_ioctlsocket(int s, long cmd, u_long *argp)
|
||||
{
|
||||
int r;
|
||||
|
@ -2575,7 +2575,7 @@ rb_w32_ioctlsocket(int s, long cmd, u_long *argp)
|
|||
|
||||
#undef listen
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_listen(int s, int backlog)
|
||||
{
|
||||
int r;
|
||||
|
@ -2592,7 +2592,7 @@ rb_w32_listen(int s, int backlog)
|
|||
|
||||
#undef recv
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_recv(int s, char *buf, int len, int flags)
|
||||
{
|
||||
int r;
|
||||
|
@ -2609,8 +2609,8 @@ rb_w32_recv(int s, char *buf, int len, int flags)
|
|||
|
||||
#undef recvfrom
|
||||
|
||||
int
|
||||
rb_w32_recvfrom(int s, char *buf, int len, int flags,
|
||||
int
|
||||
rb_w32_recvfrom(int s, char *buf, int len, int flags,
|
||||
struct sockaddr *from, int *fromlen)
|
||||
{
|
||||
int r;
|
||||
|
@ -2627,7 +2627,7 @@ rb_w32_recvfrom(int s, char *buf, int len, int flags,
|
|||
|
||||
#undef send
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_send(int s, const char *buf, int len, int flags)
|
||||
{
|
||||
int r;
|
||||
|
@ -2644,8 +2644,8 @@ rb_w32_send(int s, const char *buf, int len, int flags)
|
|||
|
||||
#undef sendto
|
||||
|
||||
int
|
||||
rb_w32_sendto(int s, const char *buf, int len, int flags,
|
||||
int
|
||||
rb_w32_sendto(int s, const char *buf, int len, int flags,
|
||||
struct sockaddr *to, int tolen)
|
||||
{
|
||||
int r;
|
||||
|
@ -2662,7 +2662,7 @@ rb_w32_sendto(int s, const char *buf, int len, int flags,
|
|||
|
||||
#undef setsockopt
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_setsockopt(int s, int level, int optname, char *optval, int optlen)
|
||||
{
|
||||
int r;
|
||||
|
@ -2676,10 +2676,10 @@ rb_w32_setsockopt(int s, int level, int optname, char *optval, int optlen)
|
|||
});
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
#undef shutdown
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_shutdown(int s, int how)
|
||||
{
|
||||
int r;
|
||||
|
@ -2749,7 +2749,7 @@ open_ifs_socket(int af, int type, int protocol)
|
|||
#define open_socket(a, t, p) socket(a, t, p)
|
||||
#endif
|
||||
|
||||
int
|
||||
int
|
||||
rb_w32_socket(int af, int type, int protocol)
|
||||
{
|
||||
SOCKET s;
|
||||
|
@ -3761,7 +3761,7 @@ rb_w32_getc(FILE* stream)
|
|||
c = (unsigned char)*stream->FILE_READPTR++;
|
||||
rb_trap_immediate = trap_immediate;
|
||||
}
|
||||
else
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = _filbuf(stream);
|
||||
|
@ -3786,7 +3786,7 @@ rb_w32_putc(int c, FILE* stream)
|
|||
c = (unsigned char)(*stream->FILE_READPTR++ = (char)c);
|
||||
rb_trap_immediate = trap_immediate;
|
||||
}
|
||||
else
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = _flsbuf(c, stream);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue