*** empty log message ***
authorroot <root>
Thu, 12 Jan 2006 01:30:53 +0000 (01:30 +0000)
committerroot <root>
Thu, 12 Jan 2006 01:30:53 +0000 (01:30 +0000)
src/init.C
src/main.C
src/perl/mark-urls
src/rxvt.h
src/rxvtperl.h
src/rxvtperl.xs
src/urxvt.pm

index 3d810ffe566bd3295613781d77104479bf7221a9..896e3d6f4123b5a9616ff445e9d23719a844a377 100644 (file)
@@ -341,19 +341,16 @@ rxvt_term::init_resources (int argc, const char *const *argv)
   /*
    * Open display, get options/resources and create the window
    */
-  {
-    TEMP_ENV;
 
-    if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL)
-      rs[Rs_display_name] = ":0";
+  if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL)
+    rs[Rs_display_name] = ":0";
 
-    get_options (r_argc, r_argv);
+  get_options (r_argc, r_argv);
 
-    if (!(display = displays.get (rs[Rs_display_name])))
-      rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
+  if (!(display = displays.get (rs[Rs_display_name])))
+    rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
 
-    extract_resources ();
-  }
+  extract_resources ();
 
   free (r_argv);
 
@@ -583,7 +580,7 @@ rxvt_term::init_env ()
 void
 rxvt_term::set_locale (const char *locale)
 {
-  TEMP_ENV;
+  set_environ (envv);
 
 #if HAVE_XSETLOCALE || HAVE_SETLOCALE
   free (this->locale);
@@ -624,7 +621,7 @@ rxvt_term::set_locale (const char *locale)
 void
 rxvt_term::init_xlocale ()
 {
-  TEMP_ENV;
+  set_environ (envv);
 
 #ifdef USE_XIM
   if (!locale)
@@ -1415,8 +1412,6 @@ rxvt_get_ttymode (ttymode_t *tio, int erase)
 void
 rxvt_term::run_command (const char *const *argv)
 {
-  TEMP_ENV; // not very temporary...
-
 #if ENABLE_FRILLS
   if (rs[Rs_pty_fd])
     {
index 20cdd58fc7464203451cf13fae959d079dfe9ff4..e91fb83909e160f1a41123e302ada0c24d9b7b2d 100644 (file)
@@ -480,7 +480,7 @@ bool
 rxvt_term::init (int argc, const char *const *argv)
 {
   SET_R (this);
-  TEMP_ENV; // few things in X do not call setlocale :(
+  set_environ (envv); // few things in X do not call setlocale :(
 
   set_locale ("");
 
@@ -525,7 +525,7 @@ rxvt_term::init (int argc, const char *const *argv)
         }
 #endif
       rxvt_perl.init ();
-      setlocale (LC_CTYPE, curlocale); // perl init destroys this info
+      setlocale (LC_CTYPE, curlocale); // perl init destroys current locale
       HOOK_INVOKE ((this, HOOK_INIT, DT_END));
     }
 #endif
@@ -1453,7 +1453,7 @@ rxvt_term::IM_get_IC (const char *modifiers)
   char **s;
   XIMStyles *xim_styles;
 
-  TEMP_ENV;
+  set_environ (envv);
 
   if (! ((p = XSetLocaleModifiers (modifiers)) && *p))
     return false;
index 83cb99c38901ce3416e39ffe90fad93fc5839e4b..5fa83972c5617fbb9319f36098db686aacaca490 100644 (file)
@@ -35,7 +35,7 @@ sub on_line_update {
    ()
 }
 
-sub on_button_press {
+sub on_button_release {
     my ($self, $event) = @_;
     my $row = $event->{row};
     my $col = $event->{col};
@@ -43,12 +43,15 @@ sub on_button_press {
     my $line = $self->line ($row);
     my $text = $line->t;
 
-    while($text =~ /$url/g) {
-        if ($-[0] <= $col && $+[0] >= $col) {
-            system "$self->{browser} \Q$1\E &";
-            return 1;
-        }
+    if ($event->{button} == 2) {
+       while ($text =~ /$url/g) {
+           if ($-[0] <= $col && $+[0] >= $col) {
+               system "$self->{browser} \Q$1\E &";
+               return 1;
+           }
+       }
     }
+
     ()
 }
 
index 5c2be75163101a89f5481a2782f12e20df4756e3..c0242c350dd78c51b1b4b11c30fbf55502aa179e 100644 (file)
@@ -121,31 +121,17 @@ void             rxvt_usleep                      (int usecs);
 extern char **environ;
 extern char **rxvt_environ; // the original environ pointer
 
-struct temp_environ
+inline void set_environ (stringvec *envv)
 {
-  char **prev;
+  if (envv)
+    environ = (char **)envv->begin ();
+}
 
-  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)
+inline void set_environ (char **envv)
+{
+  if (envv)
+    environ = envv;
+}
 
 /*
  *****************************************************************************
index bf69305d952a231e8800f005155b5a3dede23b05..7c401e5f0d85ec441d3f211be4741c4abc993338 100644 (file)
@@ -36,6 +36,8 @@ struct rxvt_perl_term
 
 struct rxvt_perl_interp
 {
+  char **perl_environ;
+
   rxvt_perl_interp ();
   ~rxvt_perl_interp ();
 
index f0c13e751c8ba774756fd00dce90873b26cf146d..dc7526d61a16662e5c0e443da50149fa24699d29 100644 (file)
@@ -413,7 +413,8 @@ rxvt_perl_interp::init ()
 {
   if (!perl)
     {
-      temp_environ temp_environ(rxvt_environ);
+      perl_environ = rxvt_environ;
+      swap (perl_environ, environ);
 
       char *argv[] = {
         "",
@@ -433,6 +434,8 @@ rxvt_perl_interp::init ()
           perl_free (perl);
           perl = 0;
         }
+
+      swap (perl_environ, environ);
     }
 }
 
@@ -484,145 +487,154 @@ rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
         return false;
     }
 
-  temp_environ temp_environ(rxvt_environ);
-
-  dSP;
-  va_list ap;
-
-  va_start (ap, htype);
-
-  ENTER;
-  SAVETMPS;
-
-  PUSHMARK (SP);
-
-  XPUSHs (sv_2mortal (newSVterm (term)));
-  XPUSHs (sv_2mortal (newSViv (htype)));
-
-  for (;;) {
-    data_type dt = (data_type)va_arg (ap, int);
+  swap (perl_environ, environ);
 
-    switch (dt)
-      {
-        case DT_INT:
-          XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
-          break;
+  try
+    {
+      dSP;
+      va_list ap;
 
-        case DT_LONG:
-          XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
-          break;
+      va_start (ap, htype);
 
-        case DT_STR:
-          XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0))));
-          break;
+      ENTER;
+      SAVETMPS;
 
-        case DT_STR_LEN:
-          {
-            char *str = va_arg (ap, char *);
-            int len = va_arg (ap, int);
+      PUSHMARK (SP);
 
-            XPUSHs (taint (sv_2mortal (newSVpvn (str, len))));
-          }
-          break;
-
-        case DT_WCS_LEN:
-          {
-            wchar_t *wstr = va_arg (ap, wchar_t *);
-            int wlen = va_arg (ap, int);
+      XPUSHs (sv_2mortal (newSVterm (term)));
+      XPUSHs (sv_2mortal (newSViv (htype)));
 
-            XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen))));
-          }
-         break;
+      for (;;) {
+        data_type dt = (data_type)va_arg (ap, int);
 
-        case DT_XEVENT:
+        switch (dt)
           {
-            XEvent *xe = va_arg (ap, XEvent *);
-            HV *hv = newHV ();
+            case DT_INT:
+              XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
+              break;
 
-#           define set(name, sv) hv_store (hv, # name,  sizeof (# name) - 1, sv, 0)
-#           define setiv(name, val) hv_store (hv, # name,  sizeof (# name) - 1, newSViv (val), 0)
-#           undef set
+            case DT_LONG:
+              XPUSHs (sv_2mortal (newSViv (va_arg (ap, long))));
+              break;
 
-            setiv (type,       xe->type);
-            setiv (send_event, xe->xany.send_event);
-            setiv (serial,     xe->xany.serial);
+            case DT_STR:
+              XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0))));
+              break;
 
-            switch (xe->type)
+            case DT_STR_LEN:
               {
-                case KeyPress:
-                case KeyRelease:
-                case ButtonPress:
-                case ButtonRelease:
-                case MotionNotify:
-                  setiv (time,   xe->xmotion.time);
-                  setiv (x,      xe->xmotion.x);
-                  setiv (y,      xe->xmotion.y);
-                  setiv (row,    xe->xmotion.y / term->fheight);
-                  setiv (col,    xe->xmotion.x / term->fwidth);
-                  setiv (x_root, xe->xmotion.x_root);
-                  setiv (y_root, xe->xmotion.y_root);
-                  setiv (state,  xe->xmotion.state);
-                  break;
+                char *str = va_arg (ap, char *);
+                int len = va_arg (ap, int);
+
+                XPUSHs (taint (sv_2mortal (newSVpvn (str, len))));
               }
+              break;
 
-            switch (xe->type)
+            case DT_WCS_LEN:
               {
-                case KeyPress:
-                case KeyRelease:
-                  setiv (keycode, xe->xkey.keycode);
-                  break;
+                wchar_t *wstr = va_arg (ap, wchar_t *);
+                int wlen = va_arg (ap, int);
 
-                case ButtonPress:
-                case ButtonRelease:
-                  setiv (button,  xe->xbutton.button);
-                  break;
-
-                case MotionNotify:
-                  setiv (is_hint, xe->xmotion.is_hint);
-                  break;
+                XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen))));
               }
+             break;
 
-            XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
-          }
-          break;
-
-        case DT_END:
-          {
-            va_end (ap);
-
-            PUTBACK;
-            int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
-            SPAGAIN;
-
-            if (count)
+            case DT_XEVENT:
               {
-                SV *status = POPs;
-                count = SvTRUE (status);
-              }
+                XEvent *xe = va_arg (ap, XEvent *);
+                HV *hv = newHV ();
 
-            PUTBACK;
-            FREETMPS;
-            LEAVE;
+#           define set(name, sv) hv_store (hv, # name,  sizeof (# name) - 1, sv, 0)
+#           define setiv(name, val) hv_store (hv, # name,  sizeof (# name) - 1, newSViv (val), 0)
+#           undef set
 
-            if (SvTRUE (ERRSV))
-              {
-                rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
-                ungrab (term); // better lose the grab than the session
+                setiv (type,       xe->type);
+                setiv (send_event, xe->xany.send_event);
+                setiv (serial,     xe->xany.serial);
+
+                switch (xe->type)
+                  {
+                    case KeyPress:
+                    case KeyRelease:
+                    case ButtonPress:
+                    case ButtonRelease:
+                    case MotionNotify:
+                      setiv (time,   xe->xmotion.time);
+                      setiv (x,      xe->xmotion.x);
+                      setiv (y,      xe->xmotion.y);
+                      setiv (row,    xe->xmotion.y / term->fheight);
+                      setiv (col,    xe->xmotion.x / term->fwidth);
+                      setiv (x_root, xe->xmotion.x_root);
+                      setiv (y_root, xe->xmotion.y_root);
+                      setiv (state,  xe->xmotion.state);
+                      break;
+                  }
+
+                switch (xe->type)
+                  {
+                    case KeyPress:
+                    case KeyRelease:
+                      setiv (keycode, xe->xkey.keycode);
+                      break;
+
+                    case ButtonPress:
+                    case ButtonRelease:
+                      setiv (button,  xe->xbutton.button);
+                      break;
+
+                    case MotionNotify:
+                      setiv (is_hint, xe->xmotion.is_hint);
+                      break;
+                  }
+
+                XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
               }
+              break;
 
-            if (htype == HOOK_DESTROY)
+            case DT_END:
               {
-                clearSVptr ((SV *)term->perl.self);
-                SvREFCNT_dec ((SV *)term->perl.self);
+                va_end (ap);
+
+                PUTBACK;
+                int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL);
+                SPAGAIN;
+
+                if (count)
+                  {
+                    SV *status = POPs;
+                    count = SvTRUE (status);
+                  }
+
+                PUTBACK;
+                FREETMPS;
+                LEAVE;
+
+                if (SvTRUE (ERRSV))
+                  {
+                    rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
+                    ungrab (term); // better lose the grab than the session
+                  }
+
+                if (htype == HOOK_DESTROY)
+                  {
+                    clearSVptr ((SV *)term->perl.self);
+                    SvREFCNT_dec ((SV *)term->perl.self);
+                  }
+
+                swap (perl_environ, environ);
+                return count;
               }
 
-            return count;
+            default:
+              rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
           }
-
-        default:
-          rxvt_fatal ("FATAL: unable to pass data type %d\n", dt);
       }
-  }
+    }
+  catch (...)
+    {
+      swap (perl_environ, environ);
+      throw;
+    }
 }
 
 /////////////////////////////////////////////////////////////////////////////
index be262b13a53f7e032634a8ecfcd16dee71f168bf..dbb02a1ce74ecc6cae8e93d83351d58b98f9ae06 100644 (file)
@@ -498,10 +498,11 @@ BEGIN {
       urxvt::warn ($msg);
    };
 
-#   delete $ENV{IFS};
-#   delete $ENV{CDPATH};
-#   delete $ENV{BASH_ENV};
-#   $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin";
+   # %ENV is the original startup environment
+   delete $ENV{IFS};
+   delete $ENV{CDPATH};
+   delete $ENV{BASH_ENV};
+   $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin";
 }
 
 my @hook_count;