summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-29 18:26:55 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-29 18:26:55 +0000
commitfe13785cc699692cefbdf94908fcaa7c99672f0f (patch)
tree5f73958731220fb1eaba3f52421a97d0bb88ce42 /ruby.c
parent7d1de7464b31bdd5b4e61897ef9b37e3e8d5389a (diff)
* 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
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/ruby.c b/ruby.c
index 0437b5b..21cdba1 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);