[前][次][番号順一覧][スレッド一覧]

ruby-changes:25766

From: nobu <ko1@a...>
Date: Sat, 24 Nov 2012 00:01:04 +0900 (JST)
Subject: [ruby-changes:25766] nobu:r37823 (trunk): ruby.c: argv check

nobu	2012-11-24 00:00:55 +0900 (Sat, 24 Nov 2012)

  New Revision: 37823

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37823

  Log:
    ruby.c: argv check
    
    * ruby.c (proc_options, process_options, ruby_process_options): take
      care of the case argc is 0, and check if argv has NULL.
      [ruby-core:49889] [Bug #7423]

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37822)
+++ ChangeLog	(revision 37823)
@@ -1,3 +1,9 @@
+Sat Nov 24 00:00:53 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.c (proc_options, process_options, ruby_process_options): take
+	  care of the case argc is 0, and check if argv has NULL.
+	  [ruby-core:49889] [Bug #7423]
+
 Sat Nov 24 00:00:10 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (--disable-dln): option to disable dynamic linking
Index: ruby.c
===================================================================
--- ruby.c	(revision 37822)
+++ ruby.c	(revision 37823)
@@ -775,7 +775,7 @@
 
     for (argc--, argv++; argc > 0; argc--, argv++) {
 	const char *const arg = argv[0];
-	if (arg[0] != '-' || !arg[1])
+	if (!arg || arg[0] != '-' || !arg[1])
 	    break;
 
 	s = arg + 1;
@@ -1358,7 +1358,7 @@
 	}
 	else {
 	    opt->script = argv[0];
-	    if (opt->script[0] == '\0') {
+	    if (!opt->script || opt->script[0] == '\0') {
 		opt->script = "-";
 	    }
 	    else if (opt->do_search) {
@@ -1896,8 +1896,9 @@
 {
     struct cmdline_options opt;
     VALUE iseq;
+    const char *script_name = (argc > 0 && argv[0]) ? argv[0] : "ruby";
 
-    ruby_script(argv[0]);  /* for the time being */
+    ruby_script(script_name);  /* for the time being */
     rb_argv0 = rb_str_new4(rb_progname);
     rb_gc_register_mark_object(rb_argv0);
     iseq = process_options(argc, argv, cmdline_options_init(&opt));

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]