ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtperl.xs
(Generate patch)

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.42 by root, Sun Jan 8 08:43:11 2006 UTC vs.
Revision 1.48 by root, Mon Jan 9 05:08:02 2006 UTC

406 perl_free (perl); 406 perl_free (perl);
407 } 407 }
408} 408}
409 409
410void 410void
411rxvt_perl_interp::init (bool tainted) 411rxvt_perl_interp::init ()
412{ 412{
413 if (!perl) 413 if (!perl)
414 { 414 {
415 char *argv[] = { 415 char *argv[] = {
416 "", 416 "",
417 "-T",
417 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", 418 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1",
418 "-T",
419 }; 419 };
420 420
421 perl = perl_alloc (); 421 perl = perl_alloc ();
422 perl_construct (perl); 422 perl_construct (perl);
423 423
424 if (perl_parse (perl, xs_init, 2 + !!tainted, argv, (char **)NULL) 424 if (perl_parse (perl, xs_init, 3, argv, (char **)NULL)
425 || perl_run (perl)) 425 || perl_run (perl))
426 { 426 {
427 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); 427 rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n");
428 428
429 perl_destruct (perl); 429 perl_destruct (perl);
430 perl_free (perl); 430 perl_free (perl);
431 perl = 0; 431 perl = 0;
432 } 432 }
433 }
434}
435
436static void
437ungrab (rxvt_term *THIS)
438{
439 if (THIS->perl.grabtime)
440 {
441 XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime);
442 XUngrabPointer (THIS->display->display, THIS->perl.grabtime);
443 THIS->perl.grabtime = 0;
433 } 444 }
434} 445}
435 446
436bool 447bool
437rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) 448rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
582 PUTBACK; 593 PUTBACK;
583 FREETMPS; 594 FREETMPS;
584 LEAVE; 595 LEAVE;
585 596
586 if (SvTRUE (ERRSV)) 597 if (SvTRUE (ERRSV))
598 {
587 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 599 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
600 ungrab (term); // better lose the grab than the session
601 }
588 602
589 if (htype == HOOK_DESTROY) 603 if (htype == HOOK_DESTROY)
590 { 604 {
591 clearSVptr ((SV *)term->perl.self); 605 clearSVptr ((SV *)term->perl.self);
592 SvREFCNT_dec ((SV *)term->perl.self); 606 SvREFCNT_dec ((SV *)term->perl.self);
693void 707void
694fatal (const char *msg) 708fatal (const char *msg)
695 CODE: 709 CODE:
696 rxvt_fatal ("%s", msg); 710 rxvt_fatal ("%s", msg);
697 711
712SV *
713untaint (SV *sv)
714 CODE:
715 RETVAL = newSVsv (sv);
716 SvTAINTED_off (RETVAL);
717 OUTPUT:
718 RETVAL
719
720bool
721safe ()
722 CODE:
723 RETVAL = !rxvt_tainted ();
724 OUTPUT:
725 RETVAL
726
698NV 727NV
699NOW () 728NOW ()
700 CODE: 729 CODE:
701 RETVAL = NOW; 730 RETVAL = NOW;
702 OUTPUT: 731 OUTPUT:
782} 811}
783 OUTPUT: 812 OUTPUT:
784 RETVAL 813 RETVAL
785 814
786void 815void
787rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) 816rxvt_term::allow_events_async ()
788 CODE: 817 CODE:
789 XAllowEvents (THIS->display->display, AsyncBoth, eventtime); 818 XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime);
790 819
791void 820void
792rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) 821rxvt_term::allow_events_sync ()
793 CODE: 822 CODE:
794 XAllowEvents (THIS->display->display, SyncBoth, eventtime); 823 XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime);
795 824
796void 825void
797rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) 826rxvt_term::allow_events_replay ()
798 CODE: 827 CODE:
799 XAllowEvents (THIS->display->display, ReplayPointer, eventtime); 828 XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime);
800 XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); 829 XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime);
801 830
802void 831void
803rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) 832rxvt_term::ungrab ()
804 CODE: 833 CODE:
805 THIS->perl.grabtime = 0; 834 ungrab (THIS);
806 XUngrabKeyboard (THIS->display->display, eventtime);
807 XUngrabPointer (THIS->display->display, eventtime);
808 835
809int 836int
810rxvt_term::strwidth (SV *str) 837rxvt_term::strwidth (SV *str)
811 CODE: 838 CODE:
812{ 839{
905 case 2: RETVAL = THIS->ModNumLockMask; break; 932 case 2: RETVAL = THIS->ModNumLockMask; break;
906 } 933 }
907 OUTPUT: 934 OUTPUT:
908 RETVAL 935 RETVAL
909 936
937char *
938rxvt_term::display_id ()
939 CODE:
940 RETVAL = THIS->display->id;
941 OUTPUT:
942 RETVAL
943
910U32 944U32
911rxvt_term::parent () 945rxvt_term::parent ()
912 CODE: 946 CODE:
913 RETVAL = (U32)THIS->parent [0]; 947 RETVAL = (U32)THIS->parent [0];
914 OUTPUT: 948 OUTPUT:
1216} 1250}
1217 OUTPUT: 1251 OUTPUT:
1218 RETVAL 1252 RETVAL
1219 1253
1220void 1254void
1221rxvt_term::cur (...) 1255rxvt_term::screen_cur (...)
1222 PROTOTYPE: $;$$ 1256 PROTOTYPE: $;$$
1223 ALIAS: 1257 ALIAS:
1224 screen_cur = 0 1258 screen_cur = 0
1225 selection_beg = 1 1259 selection_beg = 1
1226 selection_end = 2 1260 selection_end = 2
1255void 1289void
1256rxvt_term::selection (SV *newtext = 0) 1290rxvt_term::selection (SV *newtext = 0)
1257 PPCODE: 1291 PPCODE:
1258{ 1292{
1259 if (GIMME_V != G_VOID) 1293 if (GIMME_V != G_VOID)
1294 XPUSHs (THIS->selection.text
1260 XPUSHs (taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)))); 1295 ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)))
1296 : &PL_sv_undef);
1261 1297
1262 if (newtext) 1298 if (newtext)
1263 { 1299 {
1264 free (THIS->selection.text); 1300 free (THIS->selection.text);
1265 1301

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines