*** empty log message ***
authorroot <root>
Thu, 12 Jan 2006 00:35:39 +0000 (00:35 +0000)
committerroot <root>
Thu, 12 Jan 2006 00:35:39 +0000 (00:35 +0000)
src/main.C
src/rxvt.h
src/rxvtperl.xs
src/rxvtutil.h

index fda5445b2678196fb35280692a973ee815bb3533..20cdd58fc7464203451cf13fae959d079dfe9ff4 100644 (file)
@@ -480,33 +480,28 @@ bool
 rxvt_term::init (int argc, const char *const *argv)
 {
   SET_R (this);
+  TEMP_ENV; // few things in X do not call setlocale :(
 
-  const char **cmd_argv;
-  
-  {
-    TEMP_ENV; // few things in X do not call setlocale :(
-
-    set_locale ("");
+  set_locale ("");
 
-    if (!init_vars ())
-      return false;
+  if (!init_vars ())
+    return false;
 
-    init_secondary ();
+  init_secondary ();
 
-    cmd_argv = init_resources (argc, argv);
+  const char **cmd_argv = init_resources (argc, argv);
 
 #ifdef KEYSYM_RESOURCE
-    keyboard->register_done ();
+  keyboard->register_done ();
 #endif
 
 #if MENUBAR_MAX
-    menubar_read (rs[Rs_menu]);
+  menubar_read (rs[Rs_menu]);
 #endif
 #ifdef HAVE_SCROLLBARS
-    if (OPTION (Opt_scrollBar))
-      scrollBar.setIdle ();    /* set existence for size calculations */
+  if (OPTION (Opt_scrollBar))
+    scrollBar.setIdle ();    /* set existence for size calculations */
 #endif
-  }
 
 #if ENABLE_PERL
   if (!rs[Rs_perl_ext_1])
@@ -530,59 +525,55 @@ rxvt_term::init (int argc, const char *const *argv)
         }
 #endif
       rxvt_perl.init ();
-      setlocale (LC_CTYPE, curlocale); // perl destroys this info
+      setlocale (LC_CTYPE, curlocale); // perl init destroys this info
       HOOK_INVOKE ((this, HOOK_INIT, DT_END));
     }
 #endif
 
-  {
-    TEMP_ENV;
-
-    create_windows (argc, argv);
+  create_windows (argc, argv);
 
-    dDisp;
+  dDisp;
 
-    init_xlocale ();
+  init_xlocale ();
 
-    scr_reset (); // initialize screen
+  scr_reset (); // initialize screen
 
 #if 0
-    XSynchronize (disp, True);
+  XSynchronize (disp, True);
 #endif
 
 #ifdef HAVE_SCROLLBARS
-    if (OPTION (Opt_scrollBar))
-      resize_scrollbar ();      /* create and map scrollbar */
+  if (OPTION (Opt_scrollBar))
+    resize_scrollbar ();      /* create and map scrollbar */
 #endif
 #if (MENUBAR_MAX)
-    if (menubar_visible ())
-      XMapWindow (disp, menuBar.win);
+  if (menubar_visible ())
+    XMapWindow (disp, menuBar.win);
 #endif
 #ifdef TRANSPARENT
-    if (OPTION (Opt_transparent))
-      {
-        XSelectInput (disp, display->root, PropertyChangeMask);
-        check_our_parents ();
-        rootwin_ev.start (display, display->root);
-      }
+  if (OPTION (Opt_transparent))
+    {
+      XSelectInput (disp, display->root, PropertyChangeMask);
+      check_our_parents ();
+      rootwin_ev.start (display, display->root);
+    }
 #endif
 
-    XMapWindow (disp, vt);
-    XMapWindow (disp, parent[0]);
+  XMapWindow (disp, vt);
+  XMapWindow (disp, parent[0]);
 
-    set_colorfgbg ();
+  set_colorfgbg ();
 
-    init_command (cmd_argv);
+  init_command (cmd_argv);
 
-    free (cmd_argv);
+  free (cmd_argv);
 
-    if (pty.pty >= 0)
-      pty_ev.start (pty.pty, EVENT_READ);
+  if (pty.pty >= 0)
+    pty_ev.start (pty.pty, EVENT_READ);
 
-    check_ev.start ();
+  check_ev.start ();
 
-    HOOK_INVOKE ((this, HOOK_START, DT_END));
-  }
+  HOOK_INVOKE ((this, HOOK_START, DT_END));
 
   return true;
 }
@@ -627,9 +618,13 @@ static struct sig_handlers
   }
 } sig_handlers;
 
+char **rxvt_environ; // startup environment
+
 void
 rxvt_init ()
 {
+  rxvt_environ = environ;
+
   /*
    * Save and then give up any super-user privileges
    * If we need privileges in any area then we must specifically request it.
index 18c02c445fc1827f1c6cc521c3e4ae883e5d669d..5c2be75163101a89f5481a2782f12e20df4756e3 100644 (file)
@@ -115,6 +115,38 @@ void             rxvt_Draw_Shadow                 (Display *display, Window win,
 void             rxvt_Draw_Triangle               (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type);
 void             rxvt_usleep                      (int usecs);
 
+/////////////////////////////////////////////////////////////////////////////
+
+// temporarily replace the process environment
+extern char **environ;
+extern char **rxvt_environ; // the original environ pointer
+
+struct temp_environ
+{
+  char **prev;
+
+  temp_environ (const stringvec *envv)
+  : prev(environ)
+  {
+    if (envv)
+      environ = (char **)envv->begin ();
+  }
+
+  temp_environ (char **env)
+  : prev(environ)
+  {
+    if (env)
+      environ = env;
+  }
+
+  ~temp_environ ()
+  {
+    environ = prev;
+  }
+};
+
+#define TEMP_ENV               temp_environ temp_environ (envv)
+
 /*
  *****************************************************************************
  * STRUCTURES AND TYPEDEFS
@@ -700,8 +732,6 @@ enum {
 #define Width2Pixel(n)          ((int32_t)(n) * (int32_t)fwidth)
 #define Height2Pixel(n)         ((int32_t)(n) * (int32_t)fheight)
 
-#define TEMP_ENV               temp_environ temp_environ (envv)
-
 #define OPTION(opt)            (options & (opt))
 #define DEFAULT_OPTIONS                (Opt_scrollBar | Opt_scrollTtyOutput \
                                 | Opt_jumpScroll | Opt_secondaryScreen \
index ddc6538127f2a5fc24098eb1edd665780c698998..f0c13e751c8ba774756fd00dce90873b26cf146d 100644 (file)
@@ -413,6 +413,8 @@ rxvt_perl_interp::init ()
 {
   if (!perl)
     {
+      temp_environ temp_environ(rxvt_environ);
+
       char *argv[] = {
         "",
         "-T",
@@ -482,6 +484,8 @@ rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
         return false;
     }
 
+  temp_environ temp_environ(rxvt_environ);
+
   dSP;
   va_list ap;
 
index 2e9164cf27492a95eaa0007960d393d1aafe5218..8b6e7dab25a0e61d38171b6e7888e8b21a2c5547 100644 (file)
@@ -397,25 +397,5 @@ struct stringvec : simplevec<char *>
   }
 };
 
-// temporarily replace the process environment
-extern char **environ;
-
-struct temp_environ
-{
-  char **prev;
-
-  temp_environ (const stringvec *envv)
-  : prev (environ)
-  {
-    if (envv)
-      environ = (char **)envv->begin ();
-  }
-
-  ~temp_environ ()
-  {
-    environ = prev;
-  }
-};
-
 #endif