[#4745] Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...>

Having taken upon me the task to provide a Windows build for

24 messages 2005/04/20
[#4746] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Austin Ziegler <halostatue@...> 2005/04/20

On 4/20/05, Erik Huelsmann <ehuels@gmail.com> wrote:

[#4747] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...> 2005/04/20

Hi Austin,

[#4762] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — nobu.nokada@... 2005/04/24

Hi,

[#4783] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...> 2005/04/25

On 4/24/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:

[#4787] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — nobu.nokada@... 2005/04/25

Hi,

[#4794] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...> 2005/04/25

> > > Ruby is just using AC_TYPE_UID_T. So, using typedef for them,

[#4751] Illegal regexp causes segfault — Andrew Walrond <andrew@...>

irb(main):058:0> a = /\[([^]]*)\]/

13 messages 2005/04/22

[PATCH] enhanced $0 modification

From: Evan Webb <evanwebb@...>
Date: 2005-04-24 23:34:07 UTC
List: ruby-core #4774
The attached patch allows for ruby to use more of the available stack
space when altering argv[0]. This allows for much more flexible usage
of setting $0 as the new value is not constrained only be the current
size of argv, but by the size of argv plus the size of the
environment.

Initial tests show that even though the new $0 consumes space formally
occupied by the envp array, it has no ill effects on usage of the
environment.

Evan Webb // evan@fallingsnow.net

Attachments (1)

enhanced-proctitle.diff (4.21 KB, text/x-diff)
diff -u ruby-1.8.2.orig/eval.c ruby-1.8.2/eval.c
--- ruby-1.8.2.orig/eval.c	2004-12-17 18:07:29.000000000 -0800
+++ ruby-1.8.2/eval.c	2005-04-24 00:21:38.000000000 -0700
@@ -1369,9 +1369,9 @@
 }
 
 void
-ruby_options(argc, argv)
+ruby_options(argc, argv, env)
     int argc;
-    char **argv;
+    char **argv, **env;
 {
     int state;
 
@@ -1382,7 +1382,7 @@
     Init_stack((void*)&state);
     PUSH_TAG(PROT_NONE);
     if ((state = EXEC_TAG()) == 0) {
-	ruby_process_options(argc, argv);
+	ruby_process_options(argc, argv, env);
     }
     else {
 	trace_func = 0;
diff -u ruby-1.8.2.orig/intern.h ruby-1.8.2/intern.h
--- ruby-1.8.2.orig/intern.h	2004-12-02 19:25:49.000000000 -0800
+++ ruby-1.8.2/intern.h	2005-04-24 00:36:26.000000000 -0700
@@ -372,7 +372,7 @@
 void ruby_script _((const char*));
 void ruby_prog_init _((void));
 void ruby_set_argv _((int, char**));
-void ruby_process_options _((int, char**));
+void ruby_process_options _((int, char**, char**));
 void ruby_load_script _((void));
 void ruby_init_loadpath _((void));
 void ruby_incpush _((const char*));
diff -u ruby-1.8.2.orig/main.c ruby-1.8.2/main.c
--- ruby-1.8.2.orig/main.c	2004-10-31 08:06:57.000000000 -0800
+++ ruby-1.8.2/main.c	2005-04-24 00:38:27.000000000 -0700
@@ -42,7 +42,7 @@
 #endif
 
     ruby_init();
-    ruby_options(argc, argv);
+    ruby_options(argc, argv,envp);
     ruby_run();
     return 0;
 }
diff -u ruby-1.8.2.orig/ruby.c ruby-1.8.2/ruby.c
--- ruby-1.8.2.orig/ruby.c	2004-07-23 00:52:38.000000000 -0700
+++ ruby-1.8.2/ruby.c	2005-04-24 01:17:19.000000000 -0700
@@ -66,6 +66,7 @@
 
 static int origargc;
 static char **origargv;
+static char *lastargv = NULL;
 
 static void
 usage(name)
@@ -967,21 +968,25 @@
     rb_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;
-	    }
-	}
-	len = s - origargv[0];
+        if(lastargv) {
+            len = (lastargv - origargv[0]) - 2;
+        } else {
+            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;
+                }
+            }
+            len = s - origargv[0];
+        }
     }
 
     if (i >= len) {
@@ -1104,11 +1109,46 @@
     }
 }
 
+extern char **environ;
+
+/*
+ * Adapted enhanced usage of env space for program title
+ * from ProFTPD init_set_proc_title.
+ * Copyright (c) 1997, 1998 Public Flood Software
+ * Copyright (c) 1999, 2000 MacGyver, aka Habeeb J. Dihu <macgyver@tos.net>
+ */
+
 void
-ruby_process_options(argc, argv)
+ruby_process_options(argc, argv, envp)
     int argc;
-    char **argv;
+    char **argv, **envp;
 {
+    int i, envpsize;
+    char **p;
+
+    for(i = envpsize = 0; envp[i] != NULL;i++) {
+        envpsize += strlen(envp[i]) + 1;
+    }
+
+    p = (char **) malloc((i + 1) * sizeof(char *));
+    if(p != NULL) {
+        environ = p;
+        for(i = 0; envp[i] != NULL; i++) {
+            environ[i] = strdup(envp[i]);
+        }
+
+        for( i = 0; i < argc; i++) {
+            if(!i || (lastargv + 1 == argv[i]))
+                lastargv = argv[i] + strlen(argv[i]);
+        }
+
+        for(i = 0; envp[i] != NULL; i++) {
+            if((lastargv + 1) == envp[i]) {
+                lastargv = envp[i] + strlen(envp[i]);
+            }
+        }
+    }
+        
     origargc = argc; origargv = argv;
 
     ruby_script(argv[0]);	/* for the time being */
diff -u ruby-1.8.2.orig/ruby.h ruby-1.8.2/ruby.h
--- ruby-1.8.2.orig/ruby.h	2004-03-30 19:04:09.000000000 -0800
+++ ruby-1.8.2/ruby.h	2005-04-24 00:37:19.000000000 -0700
@@ -553,7 +553,7 @@
 VALUE rb_require _((const char*));
 
 void ruby_init _((void));
-void ruby_options _((int, char**));
+void ruby_options _((int, char**, char**));
 NORETURN(void ruby_run _((void)));
 
 RUBY_EXTERN VALUE rb_mKernel;

In This Thread

Prev Next