--- rxvt-unicode/src/rxvtperl.xs 2006/01/17 09:34:21 1.70 +++ rxvt-unicode/src/rxvtperl.xs 2006/01/18 10:31:37 1.74 @@ -56,22 +56,6 @@ ///////////////////////////////////////////////////////////////////////////// -static SV * -taint (SV *sv) -{ - SvTAINT (sv); - return sv; -} - -static SV * -taint_if (SV *sv, SV *src) -{ - if (SvTAINTED (src)) - SvTAINT (sv); - - return sv; -} - static wchar_t * sv2wcs (SV *sv) { @@ -420,14 +404,19 @@ char *argv[] = { "", - "-T", - "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", + "-e" + "BEGIN {" + " urxvt->bootstrap;" + " unshift @INC, '" LIBDIR "';" + "}" + "" + "use urxvt;" }; perl = perl_alloc (); perl_construct (perl); - if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) + if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) { rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); @@ -520,7 +509,7 @@ break; case DT_STR: - XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); + XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); break; case DT_STR_LEN: @@ -528,7 +517,7 @@ char *str = va_arg (ap, char *); int len = va_arg (ap, int); - XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); + XPUSHs (sv_2mortal (newSVpvn (str, len))); } break; @@ -537,7 +526,7 @@ wchar_t *wstr = va_arg (ap, wchar_t *); int wlen = va_arg (ap, int); - XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); + XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); } break; @@ -548,6 +537,7 @@ # 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) +# define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) # undef set setiv (type, xe->type); @@ -561,31 +551,54 @@ 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; - } + setuv (window, xe->xmotion.window); + setuv (root, xe->xmotion.root); + setuv (subwindow, xe->xmotion.subwindow); + setuv (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); + setuv (state, xe->xmotion.state); + + switch (xe->type) + { + case KeyPress: + case KeyRelease: + setuv (keycode, xe->xkey.keycode); + break; + + case ButtonPress: + case ButtonRelease: + setuv (button, xe->xbutton.button); + break; + + case MotionNotify: + setiv (is_hint, xe->xmotion.is_hint); + 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 MapNotify: + case UnmapNotify: + case ConfigureNotify: + setuv (event, xe->xconfigure.event); + setuv (window, xe->xconfigure.window); + + switch (xe->type) + { + case ConfigureNotify: + setiv (x, xe->xconfigure.x); + setiv (y, xe->xconfigure.y); + setiv (width, xe->xconfigure.width); + setiv (height, xe->xconfigure.height); + setuv (above, xe->xconfigure.above); + break; + } - case MotionNotify: - setiv (is_hint, xe->xmotion.is_hint); break; } @@ -784,24 +797,9 @@ CODE: rxvt_fatal ("%s", msg); -SV * -untaint (SV *sv) - CODE: - RETVAL = newSVsv (sv); - SvTAINTED_off (RETVAL); - OUTPUT: - RETVAL - void _exit (int status) -bool -safe () - CODE: - RETVAL = !rxvt_tainted (); - OUTPUT: - RETVAL - NV NOW () CODE: @@ -1076,7 +1074,7 @@ free (wstr); - RETVAL = taint_if (newSVpv (mbstr, 0), str); + RETVAL = newSVpv (mbstr, 0); free (mbstr); } OUTPUT: @@ -1093,7 +1091,7 @@ wchar_t *wstr = rxvt_mbstowcs (data, len); rxvt_pop_locale (); - RETVAL = taint_if (wcs2sv (wstr), octets); + RETVAL = wcs2sv (wstr); free (wstr); } OUTPUT: @@ -1255,7 +1253,7 @@ for (int col = 0; col < THIS->ncol; col++) wstr [col] = l.t [col]; - XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); + XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); delete [] wstr; } @@ -1386,7 +1384,7 @@ rxvt_pop_locale (); - RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); + RETVAL = wcs2sv (rstr, r - rstr); delete [] rstr; } @@ -1422,7 +1420,7 @@ else *r++ = *s; - RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); + RETVAL = wcs2sv (rstr, r - rstr); delete [] rstr; } @@ -1454,7 +1452,7 @@ croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); if (GIMME_V != G_VOID) - XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef); + XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); if (newval) { @@ -1471,8 +1469,6 @@ const char * rxvt_term::x_resource (const char *name) - CLEANUP: - SvTAINTED_on (ST (0)); bool rxvt_term::option (U32 optval, int set = -1) @@ -1542,8 +1538,17 @@ if (items == 3) { - rc.row = clamp (SvIV (ST (1)), THIS->top_row, THIS->nrow - 1); - rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); + rc.row = SvIV (ST (1)); + rc.col = SvIV (ST (2)); + + if (ix == 2 && rc.col == 0) + { + rc.row--; + rc.col = THIS->ncol; + } + + clamp_it (rc.col, 0, THIS->ncol); + clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); if (ix) THIS->want_refresh = 1; @@ -1576,7 +1581,7 @@ { if (GIMME_V != G_VOID) XPUSHs (THIS->selection.text - ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) + ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) : &PL_sv_undef); if (newtext)