[Pkg-mono-svn-commits] rev 428 - mono/trunk/debian

Eduard Bloch blade@haydn.debian.org
Mon, 15 Mar 2004 17:46:40 -0700


Author: blade
Date: 2004-03-15 17:46:37 -0700 (Mon, 15 Mar 2004)
New Revision: 428

Modified:
   mono/trunk/debian/cli-wrapper.c
Log:
Fixed cli-wrapper, exporting mono_path and not segfaulting in corner
cases


Modified: mono/trunk/debian/cli-wrapper.c
===================================================================
--- mono/trunk/debian/cli-wrapper.c	2004-03-15 20:18:38 UTC (rev 427)
+++ mono/trunk/debian/cli-wrapper.c	2004-03-16 00:46:37 UTC (rev 428)
@@ -25,37 +25,43 @@
    struct stat si;
    char **runpaths=NULL;
    char *monopath=NULL;
+   char *foo;
    
    memcpy(args+sizeof(char), argv, sizeof(char *) * argc);
    args[argc+1]=NULL;
    args[0]=argv[0];
    exName = strrchr(argv[0], '/');
-   if(!exName) exName=argv[0]; else exName++;
+   if(!exName) exName = argv[0]; else exName++;
    cmd = (char *) calloc( 512, sizeof(char));
    /* Done. exName has the binary name, look for it and write result to cmd */
 
    monopath = getenv ("MONO_PATH");
    /* only split to runpaths when found */
-   runpaths = g_strsplit (monopath ?
-         g_strjoin(G_SEARCHPATH_SEPARATOR_S, monopath, mypaths) :
-         mypaths,
-         G_SEARCHPATH_SEPARATOR_S, 1000);
+   foo = monopath ? 
+      g_strjoin(G_SEARCHPATH_SEPARATOR_S, monopath, mypaths, NULL) :
+      mypaths;
 
+   //printf("bla, %s\n", foo);
+
+   runpaths = g_strsplit (foo, G_SEARCHPATH_SEPARATOR_S, 1000);
+
    while(*runpaths) {
-      snprintf(cmd, 512, "%s/%s.exe", *runpaths, exName);
+      snprintf(cmd, 511, "%s/%s.exe", *runpaths, exName);
       if(NAME_ISREG(cmd)) {
-         setenv("MONO_PATH", g_strjoin(G_SEARCHPATH_SEPARATOR_S, monopath, *runpaths, usdl), 1);
+         if(monopath) setenv("MONO_PATH", g_strjoin(G_SEARCHPATH_SEPARATOR_S, monopath, *runpaths, usdl, NULL), 1);
+         else setenv("MONO_PATH", g_strjoin(G_SEARCHPATH_SEPARATOR_S, *runpaths, usdl, NULL), 1);
          return execve("/usr/bin/cli",args,environ);
       }
-      snprintf(cmd, 512, "%s/%s/%s.exe", *runpaths, exName, exName);
+      snprintf(cmd, 511, "%s/%s/%s.exe", *runpaths, exName, exName);
       if(NAME_ISREG(cmd)) {
-         setenv("MONO_PATH", g_strjoin(G_SEARCHPATH_SEPARATOR_S, monopath, g_strjoin("/", *runpaths, exName), usdl), 1);
+         if(monopath) setenv("MONO_PATH", g_strjoin(G_SEARCHPATH_SEPARATOR_S, monopath, g_strjoin("/", *runpaths, exName, NULL), usdl, NULL), 1);
+         else setenv("MONO_PATH", g_strjoin(G_SEARCHPATH_SEPARATOR_S, g_strjoin("/", *runpaths, exName, NULL), usdl, NULL), 1);
          return execve("/usr/bin/cli",args,environ);
       }
       runpaths++;
    }
-
+   
    /* should never be reached */
    errno = ENOENT;
    return(-1);
-} 
+}