emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/src/callproc.c,v


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/src/callproc.c,v
Date: Fri, 21 Sep 2007 06:58:52 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        07/09/21 06:58:51

Index: callproc.c
===================================================================
RCS file: /sources/emacs/emacs/src/callproc.c,v
retrieving revision 1.229
retrieving revision 1.230
diff -u -b -r1.229 -r1.230
--- callproc.c  20 Sep 2007 22:38:15 -0000      1.229
+++ callproc.c  21 Sep 2007 06:58:50 -0000      1.230
@@ -141,6 +141,8 @@
 /* Nonzero if this is termination due to exit.  */
 static int call_process_exited;
 
+EXFUN (Fgetenv_internal, 2);
+
 #ifndef VMS  /* VMS version is in vmsproc.c.  */
 
 static Lisp_Object
@@ -1326,29 +1328,36 @@
     register char **new_env;
     char **p, **q;
     register int new_length;
-    Lisp_Object local = selected_frame; /* get_frame_param (XFRAME 
(Fframe_with_environment (selected_frame)), */
-/*                                          Qenvironment); */
-
-    Lisp_Object display;
+    Lisp_Object display = Qnil;
     
     new_length = 0;
 
     for (tem = Vprocess_environment;
          CONSP (tem) && STRINGP (XCAR (tem));
          tem = XCDR (tem))
+      {
+       if (strncmp (SDATA (XCAR (tem)), "DISPLAY", 7) == 0
+           && (SDATA (XCAR (tem)) [7] == '\0'
+               || SDATA (XCAR (tem)) [7] == '='))
+         /* DISPLAY is specified in process-environment.  */
+         display = Qt;
       new_length++;
+      }
 
-#if 0    
-    for (tem = local;
-        CONSP (tem) && STRINGP (XCAR (tem));
-        tem = XCDR (tem))
-      new_length++;
-#endif
-
-    /* Add DISPLAY from the frame local values. */
-    display = get_frame_param (XFRAME (local), Qdisplay_environment_variable);
-    if (! NILP (display))
+    /* If not provided yet, use the frame's DISPLAY.  */
+    if (NILP (display))
+      {
+       Lisp_Object tmp = Fframe_parameter (selected_frame, Qdisplay);
+       if (!STRINGP (tmp) && CONSP (Vinitial_environment))
+         /* If still not found, Look for DISPLAY in Vinitial_environment.  */
+         tmp = Fgetenv_internal (build_string ("DISPLAY"),
+                                 Vinitial_environment);
+       if (STRINGP (tmp))
+         {
+           display = tmp;
       new_length++;
+         }
+      }
 
     /* new_length + 2 to include PWD and terminating 0.  */
     env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *));
@@ -1370,19 +1379,7 @@
     for (tem = Vprocess_environment;
         CONSP (tem) && STRINGP (XCAR (tem));
         tem = XCDR (tem))
-      {
-       if (strcmp (SDATA (XCAR (tem)), "DISPLAY") != 0)
          new_env = add_env (env, new_env, SDATA (XCAR (tem)));
-      }
-
-  
-#if 0    
-    /* Local part of environment.  */
-    for (tem = local;
-         CONSP (tem) && STRINGP (XCAR (tem));
-         tem = XCDR (tem))
-      new_env = add_env (env, new_env, SDATA (XCAR (tem)));
-#endif
     
     *new_env = 0;
 
@@ -1558,44 +1555,28 @@
      int *valuelen;
      Lisp_Object frame;
 {
-  Lisp_Object display;
-
-  /* FIXME: weird behavior.  */
-
-  if (NILP (frame))
-    {
       /* Try to find VAR in Vprocess_environment first.  */
       if (getenv_internal_1 (var, varlen, value, valuelen,
                             Vprocess_environment))
-       return value ? 1 : 0;
-      else
-       frame = selected_frame;
-    }
+    return *value ? 1 : 0;
 
-  /* For DISPLAY first try to get the values from the frame. */
-  display = get_frame_param (XFRAME (frame), Qdisplay_environment_variable);
+  /* For DISPLAY try to get the values from the frame or the initial env.  */
   if (strcmp (var, "DISPLAY") == 0)
-    if (! NILP (display))
+    {
+      Lisp_Object display
+       = Fframe_parameter (NILP (frame) ? selected_frame : frame, Qdisplay);
+      if (STRINGP (display))
       {
          *value    = (char *) SDATA (display);
          *valuelen = SBYTES (display);
          return 1;
       }
-
-  /* Try to find VAR in Vprocess_environment.  */
+      /* If still not found, Look for DISPLAY in Vinitial_environment.  */
   if (getenv_internal_1 (var, varlen, value, valuelen,
-                        Vprocess_environment))
-    return value ? 1 : 0;
-
-#if 0
-  /* Find the environment in which to search the variable. */
-  CHECK_FRAME (frame);
-  frame = Fframe_with_environment (frame);
+                            Vinitial_environment))
+       return *value ? 1 : 0;
+    }
 
-  if (getenv_internal_1 (var, varlen, value, valuelen,
-                        get_frame_param (XFRAME (frame), Qenvironment)))
-    return value ? 1 : 0;
-#endif
   return 0;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]