mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* marshal.c (w_object): if object responds to 'marshal_dump',
Marshal.dump uses it to dump object. unlike '_dump', marshal_dump returns any kind of object. * marshal.c (r_object0): restore instance by calling 'marshal_load' method. unlike '_load', it's an instance method, to handle cyclic reference. * marshal.c (marshal_load): all objects read from file should be tainted. [ruby-core:01325] * lib/timeout.rb (Timeout::timeout): execute immediately if sec is zero. * ext/socket/socket.c (socks_init): typo fixed. [ruby-talk:77232] * ext/socket/extconf.rb: the default value for --enable-socks is taken from ENV["SOCKS_SERVER"]. [ruby-talk:77232] * ruby.c (proc_options): add -W option. -W0 to shut up all warning messages. [ruby-talk:77227] * error.c (rb_warn): no message will be printed if the value of $VERBOSE is "nil", i.e. perfect silence. * ruby.c (verbose_setter): $VERBOSE value is either true, false, or nil. * io.c (Init_IO): no "read" check for $stdin. in addition some function names has been changed. * regex.c (re_match_exec): incorrect multibyte match. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7d1de7464b
commit
fe13785cc6
9 changed files with 130 additions and 36 deletions
43
ChangeLog
43
ChangeLog
|
@ -1,3 +1,46 @@
|
||||||
|
Wed Jul 30 02:37:12 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* marshal.c (w_object): if object responds to 'marshal_dump',
|
||||||
|
Marshal.dump uses it to dump object. unlike '_dump',
|
||||||
|
marshal_dump returns any kind of object.
|
||||||
|
|
||||||
|
* marshal.c (r_object0): restore instance by calling
|
||||||
|
'marshal_load' method. unlike '_load', it's an instance
|
||||||
|
method, to handle cyclic reference.
|
||||||
|
|
||||||
|
* marshal.c (marshal_load): all objects read from file should be
|
||||||
|
tainted. [ruby-core:01325]
|
||||||
|
|
||||||
|
Wed Jul 30 01:47:51 2003 Hugh Sasse <hgs@dmu.ac.uk>
|
||||||
|
|
||||||
|
* lib/timeout.rb (Timeout::timeout): execute immediately if sec is
|
||||||
|
zero.
|
||||||
|
|
||||||
|
Wed Jul 30 01:36:18 2003 Aron Griffis <ruby-talk@griffis1.net>
|
||||||
|
|
||||||
|
* ext/socket/socket.c (socks_init): typo fixed. [ruby-talk:77232]
|
||||||
|
|
||||||
|
Wed Jul 30 00:48:43 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/socket/extconf.rb: the default value for --enable-socks is
|
||||||
|
taken from ENV["SOCKS_SERVER"]. [ruby-talk:77232]
|
||||||
|
|
||||||
|
* ruby.c (proc_options): add -W option. -W0 to shut up all warning
|
||||||
|
messages. [ruby-talk:77227]
|
||||||
|
|
||||||
|
* error.c (rb_warn): no message will be printed if the value of
|
||||||
|
$VERBOSE is "nil", i.e. perfect silence.
|
||||||
|
|
||||||
|
* ruby.c (verbose_setter): $VERBOSE value is either true, false,
|
||||||
|
or nil.
|
||||||
|
|
||||||
|
* io.c (Init_IO): no "read" check for $stdin. in addition some
|
||||||
|
function names has been changed.
|
||||||
|
|
||||||
|
Tue Jul 29 23:10:19 2003 Yoshida Masato <yoshidam@yoshidam.net>
|
||||||
|
|
||||||
|
* regex.c (re_match_exec): incorrect multibyte match.
|
||||||
|
|
||||||
Tue Jul 29 22:36:50 2003 Minero Aoki <aamine@loveruby.net>
|
Tue Jul 29 22:36:50 2003 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* lib/net/smtp.rb (send0): do taint check only when $SAFE > 0
|
* lib/net/smtp.rb (send0): do taint check only when $SAFE > 0
|
||||||
|
|
2
error.c
2
error.c
|
@ -129,6 +129,8 @@ rb_warn(fmt, va_alist)
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
|
if (NIL_P(ruby_verbose)) return;
|
||||||
|
|
||||||
snprintf(buf, BUFSIZ, "warning: %s", fmt);
|
snprintf(buf, BUFSIZ, "warning: %s", fmt);
|
||||||
|
|
||||||
va_init_list(args, fmt);
|
va_init_list(args, fmt);
|
||||||
|
|
|
@ -359,7 +359,7 @@ if have_func(test_func)
|
||||||
unless have_func("gethostname")
|
unless have_func("gethostname")
|
||||||
have_func("uname")
|
have_func("uname")
|
||||||
end
|
end
|
||||||
if ENV["SOCKS_SERVER"] or enable_config("socks", false)
|
if enable_config("socks", ENV["SOCKS_SERVER"])
|
||||||
if have_library("socks5", "SOCKSinit")
|
if have_library("socks5", "SOCKSinit")
|
||||||
$CFLAGS+=" -DSOCKS5 -DSOCKS"
|
$CFLAGS+=" -DSOCKS5 -DSOCKS"
|
||||||
elsif have_library("socks", "Rconnect")
|
elsif have_library("socks", "Rconnect")
|
||||||
|
|
|
@ -1013,7 +1013,7 @@ socks_init(sock, host, serv)
|
||||||
init = 1;
|
init = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return init_inetsock(class, host, serv, Qnil, Qnil, INET_SOCKS);
|
return init_inetsock(sock, host, serv, Qnil, Qnil, INET_SOCKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SOCKS5
|
#ifdef SOCKS5
|
||||||
|
|
36
io.c
36
io.c
|
@ -94,7 +94,7 @@ VALUE rb_cIO;
|
||||||
VALUE rb_eEOFError;
|
VALUE rb_eEOFError;
|
||||||
VALUE rb_eIOError;
|
VALUE rb_eIOError;
|
||||||
|
|
||||||
VALUE rb_stdin, rb_stdout, rb_stderr, rb_defout;
|
VALUE rb_stdin, rb_stdout, rb_stderr;
|
||||||
static VALUE orig_stdout, orig_stderr;
|
static VALUE orig_stdout, orig_stderr;
|
||||||
|
|
||||||
VALUE rb_output_fs;
|
VALUE rb_output_fs;
|
||||||
|
@ -2779,17 +2779,7 @@ must_respond_to(mid, val, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_input_var(val, id, variable)
|
stdout_setter(val, id, variable)
|
||||||
VALUE val;
|
|
||||||
ID id;
|
|
||||||
VALUE *variable;
|
|
||||||
{
|
|
||||||
must_respond_to(id_read, val, id);
|
|
||||||
*variable = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
set_output_var(val, id, variable)
|
|
||||||
VALUE val;
|
VALUE val;
|
||||||
ID id;
|
ID id;
|
||||||
VALUE *variable;
|
VALUE *variable;
|
||||||
|
@ -2799,22 +2789,22 @@ set_output_var(val, id, variable)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_defout_var(val, id, variable)
|
defout_setter(val, id, variable)
|
||||||
VALUE val;
|
VALUE val;
|
||||||
ID id;
|
ID id;
|
||||||
VALUE *variable;
|
VALUE *variable;
|
||||||
{
|
{
|
||||||
set_output_var(val, id, variable);
|
stdout_setter(val, id, variable);
|
||||||
rb_warn("$defout is obslete; use $stdout instead");
|
rb_warn("$defout is obslete; use $stdout instead");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_deferr_var(val, id, variable)
|
deferr_setter(val, id, variable)
|
||||||
VALUE val;
|
VALUE val;
|
||||||
ID id;
|
ID id;
|
||||||
VALUE *variable;
|
VALUE *variable;
|
||||||
{
|
{
|
||||||
set_output_var(val, id, variable);
|
stdout_setter(val, id, variable);
|
||||||
rb_warn("$deferr is obslete; use $stderr instead");
|
rb_warn("$deferr is obslete; use $stderr instead");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4131,18 +4121,18 @@ Init_IO()
|
||||||
rb_define_method(rb_cIO, "inspect", rb_io_inspect, 0);
|
rb_define_method(rb_cIO, "inspect", rb_io_inspect, 0);
|
||||||
|
|
||||||
rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO);
|
rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO);
|
||||||
rb_define_hooked_variable("$stdin", &rb_stdin, 0, set_input_var);
|
rb_define_variable("$stdin", &rb_stdin);
|
||||||
rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO);
|
rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO);
|
||||||
rb_define_hooked_variable("$stdout", &rb_stdout, 0, set_output_var);
|
rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);
|
||||||
rb_stderr = prep_stdio(stderr, FMODE_WRITABLE, rb_cIO);
|
rb_stderr = prep_stdio(stderr, FMODE_WRITABLE, rb_cIO);
|
||||||
rb_define_hooked_variable("$stderr", &rb_stderr, 0, set_output_var);
|
rb_define_hooked_variable("$stderr", &rb_stderr, 0, stdout_setter);
|
||||||
rb_define_hooked_variable("$>", &rb_stdout, 0, set_output_var);
|
rb_define_hooked_variable("$>", &rb_stdout, 0, stdout_setter);
|
||||||
rb_defout = orig_stdout = rb_stdout;
|
orig_stdout = rb_stdout;
|
||||||
orig_stderr = rb_stderr;
|
orig_stderr = rb_stderr;
|
||||||
|
|
||||||
/* variables to be removed in 1.8.1 */
|
/* variables to be removed in 1.8.1 */
|
||||||
rb_define_hooked_variable("$defout", &rb_stdout, 0, set_defout_var);
|
rb_define_hooked_variable("$defout", &rb_stdout, 0, defout_setter);
|
||||||
rb_define_hooked_variable("$deferr", &rb_stderr, 0, set_deferr_var);
|
rb_define_hooked_variable("$deferr", &rb_stderr, 0, deferr_setter);
|
||||||
|
|
||||||
/* constants to hold original stdin/stdout/stderr */
|
/* constants to hold original stdin/stdout/stderr */
|
||||||
rb_define_global_const("STDIN", rb_stdin);
|
rb_define_global_const("STDIN", rb_stdin);
|
||||||
|
|
|
@ -34,7 +34,7 @@ module Timeout
|
||||||
end
|
end
|
||||||
|
|
||||||
def timeout(sec, exception=Error)
|
def timeout(sec, exception=Error)
|
||||||
return yield if sec == nil
|
return yield if sec == nil or sec.zero?
|
||||||
begin
|
begin
|
||||||
x = Thread.current
|
x = Thread.current
|
||||||
y = Thread.start {
|
y = Thread.start {
|
||||||
|
@ -63,6 +63,12 @@ if __FILE__ == $0
|
||||||
p timeout(5, TimeoutError) {
|
p timeout(5, TimeoutError) {
|
||||||
45
|
45
|
||||||
}
|
}
|
||||||
|
p timeout(nil) {
|
||||||
|
54
|
||||||
|
}
|
||||||
|
p timeout(0) {
|
||||||
|
54
|
||||||
|
}
|
||||||
p timeout(5) {
|
p timeout(5) {
|
||||||
loop {
|
loop {
|
||||||
p 10
|
p 10
|
||||||
|
|
34
marshal.c
34
marshal.c
|
@ -77,7 +77,7 @@ shortlen(len, ds)
|
||||||
#define TYPE_IVAR 'I'
|
#define TYPE_IVAR 'I'
|
||||||
#define TYPE_LINK '@'
|
#define TYPE_LINK '@'
|
||||||
|
|
||||||
static ID s_dump, s_load;
|
static ID s_dump, s_load, s_mdump, s_mload;
|
||||||
static ID s_dump_data, s_load_data, s_alloc;
|
static ID s_dump_data, s_load_data, s_alloc;
|
||||||
static ID s_getc, s_read, s_write, s_binmode;
|
static ID s_getc, s_read, s_write, s_binmode;
|
||||||
|
|
||||||
|
@ -480,14 +480,20 @@ w_object(obj, arg, limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
st_add_direct(arg->data, obj, arg->data->num_entries);
|
st_add_direct(arg->data, obj, arg->data->num_entries);
|
||||||
|
if (rb_respond_to(obj, s_mdump)) {
|
||||||
|
VALUE v;
|
||||||
|
|
||||||
|
v = rb_funcall(obj, s_mdump, 1, INT2NUM(limit));
|
||||||
|
w_class(TYPE_USRMARSHAL, obj, arg);
|
||||||
|
w_object(v, arg, limit);
|
||||||
|
if (ivtbl) w_ivar(ivtbl, &c_arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (rb_respond_to(obj, s_dump)) {
|
if (rb_respond_to(obj, s_dump)) {
|
||||||
VALUE v;
|
VALUE v;
|
||||||
|
|
||||||
w_class(TYPE_USERDEF, obj, arg);
|
|
||||||
v = rb_funcall(obj, s_dump, 1, INT2NUM(limit));
|
v = rb_funcall(obj, s_dump, 1, INT2NUM(limit));
|
||||||
if (TYPE(v) != T_STRING) {
|
w_class(TYPE_USERDEF, obj, arg);
|
||||||
rb_raise(rb_eTypeError, "_dump() must return String");
|
|
||||||
}
|
|
||||||
w_bytes(RSTRING(v)->ptr, RSTRING(v)->len, arg);
|
w_bytes(RSTRING(v)->ptr, RSTRING(v)->len, arg);
|
||||||
if (ivtbl) w_ivar(ivtbl, &c_arg);
|
if (ivtbl) w_ivar(ivtbl, &c_arg);
|
||||||
return;
|
return;
|
||||||
|
@ -1169,6 +1175,20 @@ r_object0(arg, proc)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TYPE_USRMARSHAL:
|
||||||
|
{
|
||||||
|
VALUE klass = path2class(r_unique(arg));
|
||||||
|
|
||||||
|
v = rb_obj_alloc(klass);
|
||||||
|
if (!rb_respond_to(v, s_mload)) {
|
||||||
|
rb_raise(rb_eTypeError, "instance of %s needs to have method `marshal_load'",
|
||||||
|
rb_class2name(klass));
|
||||||
|
}
|
||||||
|
r_regist(v, arg);
|
||||||
|
rb_funcall(v, s_mload, 1, r_object(arg));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case TYPE_OBJECT:
|
case TYPE_OBJECT:
|
||||||
{
|
{
|
||||||
VALUE klass = path2class(r_unique(arg));
|
VALUE klass = path2class(r_unique(arg));
|
||||||
|
@ -1296,7 +1316,7 @@ marshal_load(argc, argv)
|
||||||
if (rb_respond_to(port, s_binmode)) {
|
if (rb_respond_to(port, s_binmode)) {
|
||||||
rb_funcall2(port, s_binmode, 0, 0);
|
rb_funcall2(port, s_binmode, 0, 0);
|
||||||
}
|
}
|
||||||
arg.taint = Qfalse;
|
arg.taint = Qtrue;
|
||||||
arg.ptr = (char *)port;
|
arg.ptr = (char *)port;
|
||||||
arg.end = 0;
|
arg.end = 0;
|
||||||
}
|
}
|
||||||
|
@ -1333,6 +1353,8 @@ Init_marshal()
|
||||||
|
|
||||||
s_dump = rb_intern("_dump");
|
s_dump = rb_intern("_dump");
|
||||||
s_load = rb_intern("_load");
|
s_load = rb_intern("_load");
|
||||||
|
s_mdump = rb_intern("marshal_dump");
|
||||||
|
s_mload = rb_intern("marshal_load");
|
||||||
s_dump_data = rb_intern("_dump_data");
|
s_dump_data = rb_intern("_dump_data");
|
||||||
s_load_data = rb_intern("_load_data");
|
s_load_data = rb_intern("_load_data");
|
||||||
s_alloc = rb_intern("_alloc");
|
s_alloc = rb_intern("_alloc");
|
||||||
|
|
2
regex.c
2
regex.c
|
@ -3854,7 +3854,7 @@ re_match_exec(bufp, string_arg, size, pos, beg, regs)
|
||||||
MBC2WC(c, d);
|
MBC2WC(c, d);
|
||||||
not = is_in_list_mbc(c, p);
|
not = is_in_list_mbc(c, p);
|
||||||
if (!not) {
|
if (!not) {
|
||||||
part = not = is_in_list(cc, p);
|
part = not = is_in_list_sbc(cc, p);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
not = is_in_list(c, p);
|
not = is_in_list(c, p);
|
||||||
|
|
37
ruby.c
37
ruby.c
|
@ -94,6 +94,7 @@ usage(name)
|
||||||
"-T[level] turn on tainting checks",
|
"-T[level] turn on tainting checks",
|
||||||
"-v print version number, then turn on verbose mode",
|
"-v print version number, then turn on verbose mode",
|
||||||
"-w turn warnings on for your script",
|
"-w turn warnings on for your script",
|
||||||
|
"-W[level] set warning level; 0=silence, 1=medium, 3=verbose (default)",
|
||||||
"-x[directory] strip off text before #!ruby line and perhaps cd to directory",
|
"-x[directory] strip off text before #!ruby line and perhaps cd to directory",
|
||||||
"--copyright print the copyright",
|
"--copyright print the copyright",
|
||||||
"--version print the version",
|
"--version print the version",
|
||||||
|
@ -480,6 +481,27 @@ proc_options(argc, argv)
|
||||||
s++;
|
s++;
|
||||||
goto reswitch;
|
goto reswitch;
|
||||||
|
|
||||||
|
case 'W':
|
||||||
|
{
|
||||||
|
int numlen;
|
||||||
|
int v = 2; /* -W as -W2 */
|
||||||
|
|
||||||
|
if (*++s) {
|
||||||
|
v = scan_oct(s, 1, &numlen);
|
||||||
|
if (numlen == 0) v = 1;
|
||||||
|
s += numlen;
|
||||||
|
}
|
||||||
|
switch (v) {
|
||||||
|
case 0:
|
||||||
|
ruby_verbose = Qnil; break;
|
||||||
|
case 1:
|
||||||
|
ruby_verbose = Qfalse; break;
|
||||||
|
default:
|
||||||
|
ruby_verbose = Qtrue; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
goto reswitch;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
do_check = Qtrue;
|
do_check = Qtrue;
|
||||||
s++;
|
s++;
|
||||||
|
@ -1014,15 +1036,24 @@ forbid_setid(s)
|
||||||
rb_raise(rb_eSecurityError, "No %s allowed in tainted mode", s);
|
rb_raise(rb_eSecurityError, "No %s allowed in tainted mode", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
verbose_setter(val, id, variable)
|
||||||
|
VALUE val;
|
||||||
|
ID id;
|
||||||
|
VALUE *variable;
|
||||||
|
{
|
||||||
|
ruby_verbose = RTEST(val) ? Qtrue : val;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ruby_prog_init()
|
ruby_prog_init()
|
||||||
{
|
{
|
||||||
init_ids();
|
init_ids();
|
||||||
|
|
||||||
ruby_sourcefile = rb_source_filename("ruby");
|
ruby_sourcefile = rb_source_filename("ruby");
|
||||||
rb_define_variable("$VERBOSE", &ruby_verbose);
|
rb_define_hooked_variable("$VERBOSE", &ruby_verbose, 0, verbose_setter);
|
||||||
rb_define_variable("$-v", &ruby_verbose);
|
rb_define_hooked_variable("$-v", &ruby_verbose, 0, verbose_setter);
|
||||||
rb_define_variable("$-w", &ruby_verbose);
|
rb_define_hooked_variable("$-w", &ruby_verbose, 0, verbose_setter);
|
||||||
rb_define_variable("$DEBUG", &ruby_debug);
|
rb_define_variable("$DEBUG", &ruby_debug);
|
||||||
rb_define_variable("$-d", &ruby_debug);
|
rb_define_variable("$-d", &ruby_debug);
|
||||||
rb_define_readonly_variable("$-p", &do_print);
|
rb_define_readonly_variable("$-p", &do_print);
|
||||||
|
|
Loading…
Add table
Reference in a new issue