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

ruby-changes:6480

From: shyouhei <ko1@a...>
Date: Thu, 10 Jul 2008 18:38:45 +0900 (JST)
Subject: [ruby-changes:6480] Ruby:r17996 (ruby_1_8_7): merge revision(s) 17849:

shyouhei	2008-07-10 18:38:35 +0900 (Thu, 10 Jul 2008)

  New Revision: 17996

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

  Log:
    merge revision(s) 17849:
    * ruby.c: Mac OS X needs origargc times of '\0' in
      origargv. [ruby-dev:35308]

  Modified files:
    branches/ruby_1_8_7/ChangeLog
    branches/ruby_1_8_7/ruby.c
    branches/ruby_1_8_7/version.h

Index: ruby_1_8_7/ChangeLog
===================================================================
--- ruby_1_8_7/ChangeLog	(revision 17995)
+++ ruby_1_8_7/ChangeLog	(revision 17996)
@@ -1,3 +1,8 @@
+Thu Jul 10 18:36:53 2008  Kazuhiro NISHIYAMA  <zn@m...>
+
+	* ruby.c: Mac OS X needs origargc times of '\0' in
+	  origargv. [ruby-dev:35308]
+
 Thu Jul 10 13:53:08 2008  Tanaka Akira  <akr@f...>
 
 	* include/ruby/ruby.h (POSFIXABLE): use FIXNUM_MAX+1 instead of
Index: ruby_1_8_7/version.h
===================================================================
--- ruby_1_8_7/version.h	(revision 17995)
+++ ruby_1_8_7/version.h	(revision 17996)
@@ -2,7 +2,7 @@
 #define RUBY_RELEASE_DATE "2008-07-10"
 #define RUBY_VERSION_CODE 187
 #define RUBY_RELEASE_CODE 20080710
-#define RUBY_PATCHLEVEL 51
+#define RUBY_PATCHLEVEL 52
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
Index: ruby_1_8_7/ruby.c
===================================================================
--- ruby_1_8_7/ruby.c	(revision 17995)
+++ ruby_1_8_7/ruby.c	(revision 17996)
@@ -1039,6 +1039,39 @@
 #define set_arg0space() ((void)0)
 #endif
 
+static int
+get_arglen(int argc, char **argv)
+{
+    char *s = argv[0];
+    int i;
+
+    if (!argc) return 0;
+    s += strlen(s);
+    /* See if all the arguments are contiguous in memory */
+    for (i = 1; i < argc; i++) {
+	if (argv[i] == s + 1) {
+	    s++;
+	    s += strlen(s);	/* this one is ok too */
+	}
+	else {
+	    break;
+	}
+    }
+#if defined(USE_ENVSPACE_FOR_ARG0)
+    if (environ && (s == environ[0])) {
+	s += strlen(s);
+	for (i = 1; environ[i]; i++) {
+	    if (environ[i] == s + 1) {
+		s++;
+		s += strlen(s);	/* this one is ok too */
+	    }
+	}
+	ruby_setenv("", NULL); /* duplicate environ vars */
+    }
+#endif
+    return s - argv[0];
+}
+
 static void
 set_arg0(val, id)
     VALUE val;
@@ -1047,8 +1080,9 @@
     VALUE progname;
     char *s;
     long i;
+    int j;
 #if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE)
-    static int len;
+    static int len = 0;
 #endif
 
     if (origargv == 0) rb_raise(rb_eRuntimeError, "$0 not initialized");
@@ -1075,27 +1109,7 @@
     progname = rb_tainted_str_new(s, i);
 #else
     if (len == 0) {
-	char *s = origargv[0];
-	int i;
-
-	s += strlen(s);
-	/* See if all the arguments are contiguous in memory */
-	for (i = 1; i < origargc; i++) {
-	    if (origargv[i] == s + 1) {
-		s++;
-		s += strlen(s);	/* this one is ok too */
-	    }
-	    else {
-		break;
-	    }
-	}
-#if defined(USE_ENVSPACE_FOR_ARG0)
-	if (s + 1 == envspace.begin) {
-	    s = envspace.end;
-	    ruby_setenv("", NULL); /* duplicate environ vars */
-	}
-#endif
-	len = s - origargv[0];
+	len = get_arglen(origargc, origargv);
     }
 
     if (i >= len) {
@@ -1105,8 +1119,10 @@
     s = origargv[0] + i;
     *s = '\0';
     if (++i < len) memset(s + 1, ' ', len - i);
-    for (i = 1; i < origargc; i++)
-	origargv[i] = s;
+    for (i = len-1, j = origargc-1; j > 0 && i >= 0; --i, --j) {
+	origargv[j] = origargv[0] + i;
+	*origargv[j] = '\0';
+    }
     progname = rb_tainted_str_new2(origargv[0]);
 #endif
     rb_progname = rb_obj_freeze(progname);

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

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