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

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.108 by root, Wed Aug 25 05:03:33 2004 UTC vs.
Revision 1.128 by root, Mon Jan 17 00:59:23 2005 UTC

32 32
33#include "../config.h" /* NECESSARY */ 33#include "../config.h" /* NECESSARY */
34#include "rxvt.h" /* NECESSARY */ 34#include "rxvt.h" /* NECESSARY */
35#include "main.intpro" /* PROTOS for internal routines */ 35#include "main.intpro" /* PROTOS for internal routines */
36 36
37#include <signal.h> 37#include <csignal>
38#include <cstring>
38 39
39#ifdef TTY_GID_SUPPORT 40#ifdef TTY_GID_SUPPORT
40# include <grp.h> 41# include <grp.h>
41#endif 42#endif
42 43
43#ifdef HAVE_TERMIOS_H 44#ifdef HAVE_TERMIOS_H
44# include <termios.h> 45# include <termios.h>
45#endif 46#endif
46 47
47#include <cstring> 48#ifdef KEYSYM_RESOURCE
49# include "keyboard.h"
50#endif
48 51
49vector<rxvt_term *> rxvt_term::termlist; 52vector<rxvt_term *> rxvt_term::termlist;
50 53
51static char curlocale[128]; 54static char curlocale[128];
52 55
155 pointer_ev (this, &rxvt_term::pointer_cb), 158 pointer_ev (this, &rxvt_term::pointer_cb),
156#endif 159#endif
157#ifdef USE_XIM 160#ifdef USE_XIM
158 im_ev (this, &rxvt_term::im_cb), 161 im_ev (this, &rxvt_term::im_cb),
159#endif 162#endif
163 sw_term (this, &rxvt_term::sig_term),
164 sw_chld (this, &rxvt_term::sig_chld),
160 termwin_ev (this, &rxvt_term::x_cb), 165 termwin_ev (this, &rxvt_term::x_cb),
161 vt_ev (this, &rxvt_term::x_cb), 166 vt_ev (this, &rxvt_term::x_cb),
162 check_ev (this, &rxvt_term::check_cb), 167 check_ev (this, &rxvt_term::check_cb),
163 flush_ev (this, &rxvt_term::flush_cb), 168 flush_ev (this, &rxvt_term::flush_cb),
164 destroy_ev (this, &rxvt_term::destroy_cb), 169 destroy_ev (this, &rxvt_term::destroy_cb),
166 incr_ev (this, &rxvt_term::incr_cb) 171 incr_ev (this, &rxvt_term::incr_cb)
167{ 172{
168 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 173 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
169 174
170 termlist.push_back (this); 175 termlist.push_back (this);
176
177#ifdef KEYSYM_RESOURCE
178 keyboard = new keyboard_manager;
179
180 if (!keyboard)
181 rxvt_fatal ("out of memory, aborting.\n");
182#endif
171} 183}
172 184
173rxvt_term::~rxvt_term () 185rxvt_term::~rxvt_term ()
174{ 186{
175 termlist.erase (find (termlist.begin (), termlist.end(), this)); 187 termlist.erase (find (termlist.begin (), termlist.end(), this));
257 free (env_windowid); 269 free (env_windowid);
258 free (env_display); 270 free (env_display);
259 free (env_term); 271 free (env_term);
260 free (env_colorfgbg); 272 free (env_colorfgbg);
261 free (locale); 273 free (locale);
262#if 0 274 free (v_buffer);
263 free (codeset); 275 free (incr_buf);
264#endif
265 276
266 delete envv; 277 delete envv;
267 delete argv; 278 delete argv;
279
280#ifdef KEYSYM_RESOURCE
281 delete keyboard;
282#endif
268} 283}
269 284
270void 285void
271rxvt_term::destroy () 286rxvt_term::destroy ()
272{ 287{
330bool 345bool
331rxvt_term::init (int argc, const char *const *argv) 346rxvt_term::init (int argc, const char *const *argv)
332{ 347{
333 SET_R (this); 348 SET_R (this);
334 349
350 set_locale ("");
351
335 if (!init_vars ()) 352 if (!init_vars ())
336 return false; 353 return false;
337 354
338 init_secondary (); 355 init_secondary ();
339 356
340 const char **cmd_argv = init_resources (argc, argv); 357 const char **cmd_argv = init_resources (argc, argv);
341 358
342 set_locale (""); 359#ifdef KEYSYM_RESOURCE
360 keyboard->register_done ();
361#endif
343 362
344#if MENUBAR_MAX 363#if MENUBAR_MAX
345 menubar_read (rs[Rs_menu]); 364 menubar_read (rs[Rs_menu]);
346#endif 365#endif
347#ifdef HAVE_SCROLLBARS 366#ifdef HAVE_SCROLLBARS
381 400
382 set_colorfgbg (); 401 set_colorfgbg ();
383 402
384 init_command (cmd_argv); 403 init_command (cmd_argv);
385 404
405 free (cmd_argv);
406
386 pty_ev.start (pty.pty, EVENT_READ); 407 pty_ev.start (pty.pty, EVENT_READ);
387 408
388 check_ev.start (); 409 check_ev.start ();
389 410
390 return true; 411 return true;
393static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); 414static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
394 415
395void 416void
396rxvt_init () 417rxvt_init ()
397{ 418{
398 /* install exit handler for cleanup */
399#if 0
400#ifdef HAVE_ATEXIT
401 atexit (rxvt_clean_exit);
402#else
403#endif
404#endif
405 /* 419 /*
406 * Save and then give up any super-user privileges 420 * Save and then give up any super-user privileges
407 * If we need privileges in any area then we must specifically request it. 421 * If we need privileges in any area then we must specifically request it.
408 * We should only need to be root in these cases: 422 * We should only need to be root in these cases:
409 * 1. write utmp entries on some systems 423 * 1. write utmp entries on some systems
410 * 2. chown tty on some systems 424 * 2. chown tty on some systems
411 */ 425 */
412 rxvt_privileges (SAVE); 426 rxvt_privileges (SAVE);
413 rxvt_privileges (IGNORE); 427 rxvt_privileges (IGNORE);
414 428
415 struct sigaction sa; 429 signal (SIGHUP, SIG_IGN);
416 430 signal (SIGPIPE, SIG_IGN);
417 sigfillset (&sa.sa_mask);
418 sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
419 sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0);
420 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
421 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0);
422 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0);
423 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0);
424 sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0);
425 431
426 /* need to trap SIGURG for SVR4 (Unixware) rlogin */ 432 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
427 /* signal (SIGURG, SIG_DFL); */ 433 /* signal (SIGURG, SIG_DFL); */
428 434
429 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 435 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
436 // TODO: handle this with exceptions and tolerate the memory loss
430 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); 437 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler);
431} 438}
432 439
433/* ------------------------------------------------------------------------- * 440/* ------------------------------------------------------------------------- *
434 * SIGNAL HANDLING & EXIT HANDLER * 441 * SIGNAL HANDLING & EXIT HANDLER *
435 * ------------------------------------------------------------------------- */ 442 * ------------------------------------------------------------------------- */
436/* 443/*
437 * Catch a SIGCHLD signal and exit if the direct child has died 444 * Catch a SIGCHLD signal and exit if the direct child has died
438 */ 445 */
439 446
440void rxvt_term::child_exited (int pid) 447void
448rxvt_term::sig_chld (sig_watcher &w)
441{ 449{
442 for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) 450 // we are being called for every SIGCHLD, not just ours
443 if (pid == (*t)->cmd_pid) 451 int pid;
444 {
445 (*t)->destroy ();
446 break;
447 }
448}
449
450/* ARGSUSED */
451/* INTPROTO */
452RETSIGTYPE
453rxvt_Child_signal (int sig __attribute__ ((unused)))
454{
455 int pid, save_errno = errno;
456 452
457 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) 453 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
458 rxvt_term::child_exited (pid); 454 for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++)
459 455 if (pid == (*t)->cmd_pid)
460 errno = save_errno; 456 {
461} 457 (*t)->destroy ();
462 458 break;
463/* 459 }
464 * Catch a fatal signal and tidy up before quitting
465 */
466/* INTPROTO */
467RETSIGTYPE
468rxvt_Exit_signal (int sig)
469{
470 signal (sig, SIG_DFL);
471#ifdef DEBUG_CMD
472 rxvt_warn ("caught signal %d, exiting.\n", sig);
473#endif
474 rxvt_clean_exit ();
475 kill (getpid (), sig);
476}
477
478/* INTPROTO */
479int
480rxvt_xerror_handler (Display *display, XErrorEvent *event)
481{
482 if (GET_R->allowedxerror == -1)
483 GET_R->allowedxerror = event->error_code;
484 else
485 {
486 old_xerror_handler (display, event);
487 GET_R->destroy ();
488 }
489
490 return 0;
491} 460}
492 461
493/*----------------------------------------------------------------------*/ 462/*----------------------------------------------------------------------*/
494/* 463/*
495 * Exit gracefully, clearing the utmp entry and restoring tty attributes 464 * Exit gracefully, clearing the utmp entry and restoring tty attributes
496 * TODO: if debugging, this should free up any known resources if we can 465 * TODO: if debugging, this should free up any known resources if we can
497 */ 466 */
467void
468rxvt_destroy_all ()
469{
470 // TODO: rxvtd should clean up all ressources
471 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
472 (*t)->destroy ();
473}
474
475/*
476 * Catch a fatal signal and tidy up before quitting
477 */
478void
479rxvt_term::sig_term (sig_watcher &w)
480{
481#ifdef DEBUG_CMD
482 rxvt_warn ("caught signal %d, exiting.\n", w.signum);
483#endif
484 rxvt_destroy_all ();
485 signal (w.signum, SIG_DFL);
486 kill (getpid (), w.signum);
487}
488
498/* INTPROTO */ 489/* INTPROTO */
499void 490int
500rxvt_clean_exit () 491rxvt_xerror_handler (Display *display, XErrorEvent *event)
501{ 492{
502 // TODO: rxvtd should clean up all ressources 493 if (GET_R->allowedxerror == -1)
503 if (GET_R) 494 GET_R->allowedxerror = event->error_code;
495 else
496 {
497 old_xerror_handler (display, event);
504 GET_R->destroy (); 498 GET_R->destroy ();
499 }
500
501 return 0;
505} 502}
506 503
507/* ------------------------------------------------------------------------- * 504/* ------------------------------------------------------------------------- *
508 * MEMORY ALLOCATION WRAPPERS * 505 * MEMORY ALLOCATION WRAPPERS *
509 * ------------------------------------------------------------------------- */ 506 * ------------------------------------------------------------------------- */
510/* INTPROTO */ 507void *
511void *
512rxvt_malloc (size_t size) 508rxvt_malloc (size_t size)
513{ 509{
514 void *p;
515
516 p = malloc (size); 510 void *p = malloc (size);
511
517 if (p) 512 if (!p)
518 return p;
519
520 rxvt_fatal ("memory allocation failure. aborting.\n"); 513 rxvt_fatal ("memory allocation failure. aborting.\n");
521 /* NOTREACHED */ 514
515 return p;
522} 516}
523 517
524/* INTPROTO */ 518/* INTPROTO */
525void * 519void *
526rxvt_calloc (size_t number, size_t size) 520rxvt_calloc (size_t number, size_t size)
527{ 521{
528 void *p;
529
530 p = calloc (number, size); 522 void *p = calloc (number, size);
523
531 if (p) 524 if (!p)
532 return p;
533
534 rxvt_fatal ("memory allocation failure. aborting.\n"); 525 rxvt_fatal ("memory allocation failure. aborting.\n");
535 /* NOTREACHED */ 526
527 return p;
536} 528}
537 529
538/* INTPROTO */ 530/* INTPROTO */
539void * 531void *
540rxvt_realloc (void *ptr, size_t size) 532rxvt_realloc (void *ptr, size_t size)
541{ 533{
542 void *p;
543
544 if (ptr)
545 p = realloc (ptr, size); 534 void *p = realloc (ptr, size);
546 else
547 p = malloc (size);
548 535
549 if (p) 536 if (!p)
550 return p;
551
552 rxvt_fatal ("memory allocation failure. aborting.\n"); 537 rxvt_fatal ("memory allocation failure. aborting.\n");
553 /* NOTREACHED */ 538
539 return p;
554} 540}
555 541
556/* ------------------------------------------------------------------------- * 542/* ------------------------------------------------------------------------- *
557 * PRIVILEGED OPERATIONS * 543 * PRIVILEGED OPERATIONS *
558 * ------------------------------------------------------------------------- */ 544 * ------------------------------------------------------------------------- */
798rxvt_term::set_fonts () 784rxvt_term::set_fonts ()
799{ 785{
800 rxvt_fontset *fs = new rxvt_fontset (this); 786 rxvt_fontset *fs = new rxvt_fontset (this);
801 rxvt_fontprop prop; 787 rxvt_fontprop prop;
802 788
803 prop.width = prop.height = prop.weight = prop.slant
804 = rxvt_fontprop::unset;
805
806 if (!fs 789 if (!fs
807 || !fs->populate (rs[Rs_font] ? rs[Rs_font] : "fixed", prop) 790 || !fs->populate (rs[Rs_font] ? rs[Rs_font] : "fixed")
808 || !fs->realize_font (1)) 791 || !fs->realize_font (1))
809 { 792 {
810 delete fs; 793 delete fs;
811 return false; 794 return false;
812 } 795 }
818#endif 801#endif
819 802
820 delete TermWin.fontset[0]; 803 delete TermWin.fontset[0];
821 TermWin.fontset[0] = fs; 804 TermWin.fontset[0] = fs;
822 805
823 fs->prop = prop = (*fs)[1]->properties (); 806 prop = (*fs)[1]->properties ();
807 prop.height += TermWin.lineSpace;
808 fs->set_prop (prop);
824 809
825 TermWin.fwidth = prop.width; 810 TermWin.fwidth = prop.width;
826 TermWin.fheight = prop.height; 811 TermWin.fheight = prop.height;
827 TermWin.fweight = prop.weight; 812 TermWin.fweight = prop.weight;
828 TermWin.fslant = prop.slant; 813 TermWin.fslant = prop.slant;
848 833
849 if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold; 834 if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold;
850 if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic; 835 if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic;
851 } 836 }
852 837
853 fs->populate (res, prop2); 838 fs->populate (res);
839 fs->set_prop (prop2);
854 } 840 }
855#else 841#else
856 TermWin.fontset[style] = TermWin.fontset[0]; 842 TermWin.fontset[style] = TermWin.fontset[0];
857#endif 843#endif
858 } 844 }
865 } 851 }
866 852
867 return true; 853 return true;
868} 854}
869 855
856void rxvt_term::set_string_property (Atom prop, const char *str, int len)
857{
858 // TODO: SMART_WINDOW_TITLE
859 XChangeProperty (display->display, TermWin.parent[0],
860 prop, XA_STRING, 8, PropModeReplace,
861 (const unsigned char *)str, len >= 0 ? len : strlen (str));
862}
863
864void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
865{
866 // TODO: SMART_WINDOW_TITLE
867 wchar_t *ws = rxvt_mbstowcs (str, len);
868 char *s = rxvt_wcstoutf8 (ws);
869
870 XChangeProperty (display->display, TermWin.parent[0],
871 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,
872 (const unsigned char *)s, strlen (s));
873
874 free (s);
875 free (ws);
876}
877
870/*----------------------------------------------------------------------*/ 878/*----------------------------------------------------------------------*/
871/*----------------------------------------------------------------------*/ 879/*----------------------------------------------------------------------*/
872/* xterm sequences - title, iconName, color (exptl) */ 880/* xterm sequences - title, iconName, color (exptl) */
873void 881void
874rxvt_term::set_title (const char *str) 882rxvt_term::set_title (const char *str)
875{ 883{
876#ifdef SMART_WINDOW_TITLE 884 set_string_property (XA_WM_NAME, str);
877 char *name; 885#if ENABLE_FRILLS
878 886 set_utf8_property (xa[XA_NET_WM_NAME], str);
879 if (!XFetchName (display->display, TermWin.parent[0], &name))
880 name = NULL;
881
882 if (name == NULL || strcmp (name, str))
883#endif
884 XStoreName (display->display, TermWin.parent[0], str);
885
886#ifdef SMART_WINDOW_TITLE
887 if (name)
888 XFree (name);
889#endif 887#endif
890} 888}
891 889
892void 890void
893rxvt_term::set_icon_name (const char *str) 891rxvt_term::set_icon_name (const char *str)
894{ 892{
895#ifdef SMART_WINDOW_TITLE 893 set_string_property (XA_WM_ICON_NAME, str);
896 char *name; 894#if ENABLE_FRILLS
897 895 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str);
898 if (!XGetIconName (display->display, TermWin.parent[0], &name))
899 name = NULL;
900
901 if (name == NULL || strcmp (name, str))
902#endif
903 XSetIconName (display->display, TermWin.parent[0], str);
904
905#ifdef SMART_WINDOW_TITLE
906 if (name)
907 XFree (name);
908#endif 896#endif
909} 897}
910 898
911#ifdef XTERM_COLOR_CHANGE 899#ifdef XTERM_COLOR_CHANGE
912void 900void
1031 1019
1032 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); 1020 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
1033} 1021}
1034 1022
1035/*----------------------------------------------------------------------*/ 1023/*----------------------------------------------------------------------*/
1036/*
1037 * Colour determination for low colour displays, routine from
1038 * Hans de Goede <hans@highrise.nl>
1039 */
1040 1024
1041int 1025int
1042rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1026rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
1043{ 1027{
1044 if (!screen_in_out->set (display, colour)) 1028 if (!screen_in_out->set (display, colour))
1263} 1247}
1264 1248
1265void 1249void
1266rxvt_term::IMSendSpot () 1250rxvt_term::IMSendSpot ()
1267{ 1251{
1268 XPoint spot; 1252 XPoint nspot;
1269 XVaNestedList preedit_attr; 1253 XVaNestedList preedit_attr;
1270 1254
1271 if (!Input_Context 1255 if (!Input_Context
1272 || !TermWin.focus 1256 || !TermWin.focus
1273 || !(input_style & XIMPreeditPosition) 1257 || !(input_style & XIMPreeditPosition))
1274#if 0
1275 || !(event_type == KeyPress
1276 || event_type == Expose
1277 || event_type == NoExpose
1278 || event_type == SelectionNotify
1279 || event_type == ButtonRelease || event_type == FocusIn)
1280#endif
1281 || !IMisRunning ())
1282 return; 1258 return;
1283 1259
1284 im_set_position (spot); 1260 im_set_position (nspot);
1261
1262 if (nspot.x == spot.x && nspot.y == spot.y)
1263 return;
1264
1265 spot = nspot;
1285 1266
1286 preedit_attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL); 1267 preedit_attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
1287 XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL); 1268 XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL);
1288 XFree (preedit_attr); 1269 XFree (preedit_attr);
1289} 1270}
1290 1271
1291void 1272void
1292rxvt_term::im_destroy () 1273rxvt_term::im_destroy ()
1293{ 1274{
1294 if (Input_Context)
1295 {
1296 XDestroyIC (Input_Context);
1297 Input_Context = 0;
1298 }
1299
1300 if (input_method) 1275 if (input_method)
1301 { 1276 {
1277 if (Input_Context && input_method->xim)
1278 XDestroyIC (Input_Context);
1279
1302 display->put_xim (input_method); 1280 display->put_xim (input_method);
1303 input_method = 0; 1281 input_method = 0;
1304 } 1282 }
1283
1284 Input_Context = 0;
1305} 1285}
1306 1286
1307/* 1287/*
1308 * Try to open a XIM with the current modifiers, then see if we can 1288 * Try to open a XIM with the current modifiers, then see if we can
1309 * open a suitable preedit type 1289 * open a suitable preedit type
1327 input_method = display->get_xim (locale, modifiers); 1307 input_method = display->get_xim (locale, modifiers);
1328 if (input_method == NULL) 1308 if (input_method == NULL)
1329 return false; 1309 return false;
1330 1310
1331 xim = input_method->xim; 1311 xim = input_method->xim;
1312 spot.x = spot.y = -1;
1332 1313
1333 xim_styles = NULL; 1314 xim_styles = NULL;
1334 if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL) 1315 if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL)
1335 || !xim_styles || !xim_styles->count_styles) 1316 || !xim_styles || !xim_styles->count_styles)
1336 { 1317 {
1337 im_destroy (); 1318 im_destroy ();
1338 return false; 1319 return false;
1339 } 1320 }
1340 1321
1341 p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root"; 1322 const char *pet[] = { rs[Rs_preeditType], "OverTheSpot,OffTheSpot,Root,None" };
1323
1324 for (int pi = 0; pi < 2; pi++)
1325 {
1326 p = pet[pi];
1327
1328 if (!p)
1329 continue;
1330
1342 s = rxvt_splitcommastring (p); 1331 s = rxvt_splitcommastring (p);
1343 1332
1344 for (i = found = 0; !found && s[i]; i++) 1333 for (i = found = 0; !found && s[i]; i++)
1345 { 1334 {
1346 if (!strcmp (s[i], "OverTheSpot")) 1335 if (!strcmp (s[i], "OverTheSpot"))
1347 input_style = (XIMPreeditPosition | XIMStatusNothing); 1336 input_style = (XIMPreeditPosition | XIMStatusNothing);
1348 else if (!strcmp (s[i], "OffTheSpot")) 1337 else if (!strcmp (s[i], "OffTheSpot"))
1349 input_style = (XIMPreeditArea | XIMStatusArea); 1338 input_style = (XIMPreeditArea | XIMStatusArea);
1350 else if (!strcmp (s[i], "Root")) 1339 else if (!strcmp (s[i], "Root"))
1351 input_style = (XIMPreeditNothing | XIMStatusNothing); 1340 input_style = (XIMPreeditNothing | XIMStatusNothing);
1341 else if (!strcmp (s[i], "None"))
1342 input_style = (XIMPreeditNone | XIMStatusNone);
1352 1343
1353 for (j = 0; j < xim_styles->count_styles; j++) 1344 for (j = 0; j < xim_styles->count_styles; j++)
1354 if (input_style == xim_styles->supported_styles[j]) 1345 if (input_style == xim_styles->supported_styles[j])
1355 { 1346 {
1347 rxvt_freecommastring (s);
1348
1356 found = 1; 1349 found = 1;
1357 break; 1350 goto foundpet;
1351 }
1352
1358 } 1353 }
1359 }
1360 1354
1361 for (i = 0; s[i]; i++) 1355 rxvt_freecommastring (s);
1362 free (s[i]); 1356 }
1363 1357
1364 free (s); 1358foundpet:
1359
1365 XFree (xim_styles); 1360 XFree (xim_styles);
1366 1361
1367 if (!found) 1362 if (!found)
1368 { 1363 {
1369 im_destroy (); 1364 im_destroy ();
1494 if (p && *p) 1489 if (p && *p)
1495 { 1490 {
1496 bool found = false; 1491 bool found = false;
1497 1492
1498 s = rxvt_splitcommastring (p); 1493 s = rxvt_splitcommastring (p);
1494
1499 for (i = 0; s[i]; i++) 1495 for (i = 0; s[i]; i++)
1500 { 1496 {
1501 if (*s[i]) 1497 if (*s[i])
1502 { 1498 {
1503 strcpy (buf, "@im="); 1499 strcpy (buf, "@im=");
1507 found = true; 1503 found = true;
1508 break; 1504 break;
1509 } 1505 }
1510 } 1506 }
1511 } 1507 }
1512 for (i = 0; s[i]; i++) 1508
1513 free (s[i]); 1509 rxvt_freecommastring (s);
1514 free (s);
1515 1510
1516 if (found) 1511 if (found)
1517 goto done; 1512 goto done;
1518 } 1513 }
1519 1514

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines