From 24424d3991179ec50837cff97b21f646f7069447 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 29 Jul 2003 18:26:55 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@4220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 0437b5bb0..21cdba182 100644 --- a/ruby.c +++ b/ruby.c @@ -94,6 +94,7 @@ usage(name) "-T[level] turn on tainting checks", "-v print version number, then turn on verbose mode", "-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", "--copyright print the copyright", "--version print the version", @@ -480,6 +481,27 @@ proc_options(argc, argv) s++; 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': do_check = Qtrue; s++; @@ -1014,15 +1036,24 @@ forbid_setid(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 ruby_prog_init() { init_ids(); ruby_sourcefile = rb_source_filename("ruby"); - rb_define_variable("$VERBOSE", &ruby_verbose); - rb_define_variable("$-v", &ruby_verbose); - rb_define_variable("$-w", &ruby_verbose); + rb_define_hooked_variable("$VERBOSE", &ruby_verbose, 0, verbose_setter); + rb_define_hooked_variable("$-v", &ruby_verbose, 0, verbose_setter); + rb_define_hooked_variable("$-w", &ruby_verbose, 0, verbose_setter); rb_define_variable("$DEBUG", &ruby_debug); rb_define_variable("$-d", &ruby_debug); rb_define_readonly_variable("$-p", &do_print); -- cgit