[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

[Patch] Re: Running WML from WML?



On Thu, 6 May 1999, Denis Barbier wrote:

> Below is a quick workaround

Here is a new version. Not perfect yet, but it seems to work.

Denis

--- wml_backend/p3_eperl/eperl_sys.c.orig	1999/01/12 14:24:14	1.2
+++ wml_backend/p3_eperl/eperl_sys.c	1999/05/06 20:33:16
@@ -58,15 +58,19 @@
     /*  create the key=val string  */
     va_start(ap, str);
     vsprintf(ca, str, ap);
+    va_end(ap);
     sprintf(ca2, "%s=%s", var, ca);
     cp = strdup(ca2);
 
     /*  now duplicate the old structure  */
     for (i = 0; env[i] != NULL; i++)
         ;
-    envN = (char **)malloc(sizeof(char *) * (i+2));
+
+    if ((envN = (char **)malloc(sizeof(char *) * (i+2))) == NULL)
+        return environ;
+
     for (i = 0; env[i] != NULL; i++) {
-        if (strncmp(env[i], var, strlen(var)) == 0) {
+        if (!replaced && (strncmp(env[i], var, strlen(var)) == 0)) {
             envN[i] = cp;
             replaced = TRUE;
         }
@@ -77,8 +81,8 @@
     /*  add the new entry if not replaced */
     if (!replaced) {
         envN[i++] = cp;
-        envN[i++] = NULL;
     }
+    envN[i] = NULL;
 
     /*  set the libc/exec variable which Perl uses */
     if (stillcalled) 
@@ -86,7 +90,6 @@
     stillcalled = TRUE;
     environ = envN;
 
-    va_end(ap);
     return envN;
 }
 

______________________________________________________________________
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com