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.135 by root, Sun Feb 13 11:07:57 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_int (this, &rxvt_term::sig_term),
165 sw_chld (this, &rxvt_term::sig_chld),
160 termwin_ev (this, &rxvt_term::x_cb), 166 termwin_ev (this, &rxvt_term::x_cb),
161 vt_ev (this, &rxvt_term::x_cb), 167 vt_ev (this, &rxvt_term::x_cb),
162 check_ev (this, &rxvt_term::check_cb), 168 check_ev (this, &rxvt_term::check_cb),
163 flush_ev (this, &rxvt_term::flush_cb), 169 flush_ev (this, &rxvt_term::flush_cb),
164 destroy_ev (this, &rxvt_term::destroy_cb), 170 destroy_ev (this, &rxvt_term::destroy_cb),
166 incr_ev (this, &rxvt_term::incr_cb) 172 incr_ev (this, &rxvt_term::incr_cb)
167{ 173{
168 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 174 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
169 175
170 termlist.push_back (this); 176 termlist.push_back (this);
171}
172 177
173rxvt_term::~rxvt_term () 178#ifdef KEYSYM_RESOURCE
174{ 179 keyboard = new keyboard_manager;
175 termlist.erase (find (termlist.begin (), termlist.end(), this));
176 180
181 if (!keyboard)
182 rxvt_fatal ("out of memory, aborting.\n");
183#endif
184}
185
186// clean up the most important stuff, do *not* call x or free mem etc.
187// for use before an emergency exit
188void rxvt_term::emergency_cleanup ()
189{
177 if (cmd_pid) 190 if (cmd_pid)
178 kill (-cmd_pid, SIGHUP); 191 kill (-cmd_pid, SIGHUP);
179 192
180 pty.put ();
181
182#ifdef UTMP_SUPPORT 193#ifdef UTMP_SUPPORT
183 privileged_utmp (RESTORE); 194 privileged_utmp (RESTORE);
184#endif 195#endif
196
197 pty.put ();
198}
199
200rxvt_term::~rxvt_term ()
201{
202 termlist.erase (find (termlist.begin (), termlist.end(), this));
203
204 emergency_cleanup ();
185 205
186#if ENABLE_STYLES 206#if ENABLE_STYLES
187 for (int i = RS_styleCount; --i; ) 207 for (int i = RS_styleCount; --i; )
188 if (TermWin.fontset[i] != TermWin.fontset[0]) 208 if (TermWin.fontset[i] != TermWin.fontset[0])
189 delete TermWin.fontset[i]; 209 delete TermWin.fontset[i];
190#endif 210#endif
191 delete TermWin.fontset[0]; 211 delete TermWin.fontset[0];
192 212
193 if (display) 213 if (display)
194 { 214 {
215 dDisp;
216
195 selection_clear (); 217 selection_clear ();
196 218
197#ifdef USE_XIM 219#ifdef USE_XIM
198 im_destroy (); 220 im_destroy ();
199#endif 221#endif
200#ifdef MENUBAR 222#ifdef MENUBAR
201 if (menubarGC) XFreeGC (display->display, menubarGC); 223 if (menubarGC) XFreeGC (disp, menubarGC);
202#endif 224#endif
203#ifdef XTERM_SCROLLBAR 225#ifdef XTERM_SCROLLBAR
204 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); 226 if (xscrollbarGC) XFreeGC (disp, xscrollbarGC);
205 if (ShadowGC) XFreeGC (display->display, ShadowGC); 227 if (ShadowGC) XFreeGC (disp, ShadowGC);
206#endif 228#endif
207#ifdef PLAIN_SCROLLBAR 229#ifdef PLAIN_SCROLLBAR
208 if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC); 230 if (pscrollbarGC) XFreeGC (disp, pscrollbarGC);
209#endif 231#endif
210#ifdef NEXT_SCROLLBAR 232#ifdef NEXT_SCROLLBAR
211 if (blackGC) XFreeGC (display->display, blackGC); 233 if (blackGC) XFreeGC (disp, blackGC);
212 if (whiteGC) XFreeGC (display->display, whiteGC); 234 if (whiteGC) XFreeGC (disp, whiteGC);
213 if (grayGC) XFreeGC (display->display, grayGC); 235 if (grayGC) XFreeGC (disp, grayGC);
214 if (darkGC) XFreeGC (display->display, darkGC); 236 if (darkGC) XFreeGC (disp, darkGC);
215 if (stippleGC) XFreeGC (display->display, stippleGC); 237 if (stippleGC) XFreeGC (disp, stippleGC);
216 if (dimple) XFreePixmap (display->display, dimple); 238 if (dimple) XFreePixmap (disp, dimple);
217 if (upArrow) XFreePixmap (display->display, upArrow); 239 if (upArrow) XFreePixmap (disp, upArrow);
218 if (downArrow) XFreePixmap (display->display, downArrow); 240 if (downArrow) XFreePixmap (disp, downArrow);
219 if (upArrowHi) XFreePixmap (display->display, upArrowHi); 241 if (upArrowHi) XFreePixmap (disp, upArrowHi);
220 if (downArrowHi) XFreePixmap (display->display, downArrowHi); 242 if (downArrowHi) XFreePixmap (disp, downArrowHi);
221#endif 243#endif
222#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 244#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
223 if (topShadowGC) XFreeGC (display->display, topShadowGC); 245 if (topShadowGC) XFreeGC (disp, topShadowGC);
224 if (botShadowGC) XFreeGC (display->display, botShadowGC); 246 if (botShadowGC) XFreeGC (disp, botShadowGC);
225 if (scrollbarGC) XFreeGC (display->display, scrollbarGC); 247 if (scrollbarGC) XFreeGC (disp, scrollbarGC);
226#endif 248#endif
227 if (TermWin.gc) XFreeGC (display->display, TermWin.gc); 249 if (TermWin.gc) XFreeGC (disp, TermWin.gc);
228 250
229#if defined(MENUBAR) && (MENUBAR_MAX > 1) 251#if defined(MENUBAR) && (MENUBAR_MAX > 1)
230 delete menuBar.drawable; 252 delete menuBar.drawable;
231 //if (menuBar.win) 253 //if (menuBar.win)
232 // XDestroyWindow (display->display, menuBar.win); 254 // XDestroyWindow (disp, menuBar.win);
233#endif 255#endif
234 delete TermWin.drawable; 256 delete TermWin.drawable;
235 // destroy all windows 257 // destroy all windows
236 if (TermWin.parent[0]) 258 if (TermWin.parent[0])
237 XDestroyWindow (display->display, TermWin.parent[0]); 259 XDestroyWindow (disp, TermWin.parent[0]);
238 } 260 }
239 261
240 // TODO: free pixcolours, colours should become part of rxvt_display 262 // TODO: free pixcolours, colours should become part of rxvt_display
241 263
242 delete pix_colors_focused; 264 delete pix_colors_focused;
248 270
249 scr_release (); 271 scr_release ();
250 272
251 /* clear all resources */ 273 /* clear all resources */
252 for (int i = 0; i < allocated.size (); i++) 274 for (int i = 0; i < allocated.size (); i++)
253 free (allocated[i]); 275 free (allocated [i]);
254 276
255 free (selection.text); 277 free (selection.text);
256 // TODO: manage env vars in child only(!) 278 // TODO: manage env vars in child only(!)
257 free (env_windowid); 279 free (env_windowid);
258 free (env_display); 280 free (env_display);
259 free (env_term); 281 free (env_term);
260 free (env_colorfgbg); 282 free (env_colorfgbg);
261 free (locale); 283 free (locale);
262#if 0 284 free (v_buffer);
263 free (codeset); 285 free (incr_buf);
264#endif
265 286
266 delete envv; 287 delete envv;
267 delete argv; 288 delete argv;
289
290#ifdef KEYSYM_RESOURCE
291 delete keyboard;
292#endif
268} 293}
269 294
270void 295void
271rxvt_term::destroy () 296rxvt_term::destroy ()
272{ 297{
324 349
325 delete this; 350 delete this;
326} 351}
327 352
328/*----------------------------------------------------------------------*/ 353/*----------------------------------------------------------------------*/
354/*
355 * Exit gracefully, clearing the utmp entry and restoring tty attributes
356 * TODO: if debugging, this should free up any known resources if we can
357 */
358static XErrorHandler old_xerror_handler;
359
360static void
361rxvt_emergency_cleanup ()
362{
363 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
364 (*t)->emergency_cleanup ();
365}
366
367#if ENABLE_FRILLS
368static void
369print_x_error (Display *dpy, XErrorEvent *event)
370{
371 char buffer[BUFSIZ];
372 char mesg[BUFSIZ];
373 char number[32];
374 char *mtype = "XlibMessage";
375 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
376 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
377 rxvt_warn ("An X Error occured, trying to continue after report.\n");
378 rxvt_warn ("%s: %s\n", mesg, buffer);
379 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
380 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code);
381 sprintf(number, "%d", event->request_code);
382 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
383 rxvt_warn ("(which is %s)\n", buffer);
384 if (event->request_code >= 128) {
385 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
386 mesg, BUFSIZ);
387 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code);
388 }
389 if ((event->error_code == BadWindow) ||
390 (event->error_code == BadPixmap) ||
391 (event->error_code == BadCursor) ||
392 (event->error_code == BadFont) ||
393 (event->error_code == BadDrawable) ||
394 (event->error_code == BadColor) ||
395 (event->error_code == BadGC) ||
396 (event->error_code == BadIDChoice) ||
397 (event->error_code == BadValue) ||
398 (event->error_code == BadAtom)) {
399 if (event->error_code == BadValue)
400 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
401 mesg, BUFSIZ);
402 else if (event->error_code == BadAtom)
403 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
404 mesg, BUFSIZ);
405 else
406 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
407 mesg, BUFSIZ);
408 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid);
409 }
410 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
411 mesg, BUFSIZ);
412 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial);
413}
414#endif
415
416int
417rxvt_xerror_handler (Display *display, XErrorEvent *event)
418{
419 if (GET_R->allowedxerror == -1)
420 GET_R->allowedxerror = event->error_code;
421 else
422 {
423 //TODO: GET_R is most likely not the terminal which caused the error
424 //TODO: maybe just output the error and continue?
425#if ENABLE_FRILLS
426 print_x_error (display, event);
427#else
428 old_xerror_handler (display, event);
429#endif
430 }
431
432 return 0;
433}
434
435int
436rxvt_xioerror_handler (Display *display)
437{
438 rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n",
439 DisplayString (display));
440 rxvt_emergency_cleanup ();
441 _exit (EXIT_FAILURE);
442}
443
444/*
445 * Catch a fatal signal and tidy up before quitting
446 */
447void
448rxvt_term::sig_term (sig_watcher &w)
449{
450#ifdef DEBUG_CMD
451 rxvt_warn ("caught signal %d, exiting.\n", w.signum);
452#endif
453 rxvt_emergency_cleanup ();
454 signal (w.signum, SIG_DFL);
455 kill (getpid (), w.signum);
456}
457
458/*----------------------------------------------------------------------*/
329/* rxvt_init () */ 459/* rxvt_init () */
330bool 460bool
331rxvt_term::init (int argc, const char *const *argv) 461rxvt_term::init (int argc, const char *const *argv)
332{ 462{
333 SET_R (this); 463 SET_R (this);
334 464
465 set_locale ("");
466
335 if (!init_vars ()) 467 if (!init_vars ())
336 return false; 468 return false;
337 469
338 init_secondary (); 470 init_secondary ();
339 471
340 const char **cmd_argv = init_resources (argc, argv); 472 const char **cmd_argv = init_resources (argc, argv);
341 473
342 set_locale (""); 474#ifdef KEYSYM_RESOURCE
475 keyboard->register_done ();
476#endif
343 477
344#if MENUBAR_MAX 478#if MENUBAR_MAX
345 menubar_read (rs[Rs_menu]); 479 menubar_read (rs[Rs_menu]);
346#endif 480#endif
347#ifdef HAVE_SCROLLBARS 481#ifdef HAVE_SCROLLBARS
349 scrollBar.setIdle (); /* set existence for size calculations */ 483 scrollBar.setIdle (); /* set existence for size calculations */
350#endif 484#endif
351 485
352 create_windows (argc, argv); 486 create_windows (argc, argv);
353 487
488 dDisp;
489
354 init_xlocale (); 490 init_xlocale ();
355 491
356 scr_reset (); /* initialize screen */ 492 scr_reset (); /* initialize screen */
357 493
358#if 0 494#if 0
359 XSynchronize (display->display, True); 495 XSynchronize (disp, True);
360#endif 496#endif
361 497
362#ifdef HAVE_SCROLLBARS 498#ifdef HAVE_SCROLLBARS
363 if (options & Opt_scrollBar) 499 if (options & Opt_scrollBar)
364 resize_scrollbar (); /* create and map scrollbar */ 500 resize_scrollbar (); /* create and map scrollbar */
365#endif 501#endif
366#if (MENUBAR_MAX) 502#if (MENUBAR_MAX)
367 if (menubar_visible ()) 503 if (menubar_visible ())
368 XMapWindow (display->display, menuBar.win); 504 XMapWindow (disp, menuBar.win);
369#endif 505#endif
370#ifdef TRANSPARENT 506#ifdef TRANSPARENT
371 if (options & Opt_transparent) 507 if (options & Opt_transparent)
372 { 508 {
373 XSelectInput (display->display, display->root, PropertyChangeMask); 509 XSelectInput (disp, display->root, PropertyChangeMask);
374 check_our_parents (); 510 check_our_parents ();
375 rootwin_ev.start (display, display->root); 511 rootwin_ev.start (display, display->root);
376 } 512 }
377#endif 513#endif
378 514
379 XMapWindow (display->display, TermWin.vt); 515 XMapWindow (disp, TermWin.vt);
380 XMapWindow (display->display, TermWin.parent[0]); 516 XMapWindow (disp, TermWin.parent[0]);
381 517
382 set_colorfgbg (); 518 set_colorfgbg ();
383 519
384 init_command (cmd_argv); 520 init_command (cmd_argv);
385 521
522 free (cmd_argv);
523
386 pty_ev.start (pty.pty, EVENT_READ); 524 pty_ev.start (pty.pty, EVENT_READ);
387 525
388 check_ev.start (); 526 check_ev.start ();
389 527
390 return true; 528 return true;
391} 529}
392 530
393static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
394
395void 531void
396rxvt_init () 532rxvt_init ()
397{ 533{
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 /* 534 /*
406 * Save and then give up any super-user privileges 535 * Save and then give up any super-user privileges
407 * If we need privileges in any area then we must specifically request it. 536 * If we need privileges in any area then we must specifically request it.
408 * We should only need to be root in these cases: 537 * We should only need to be root in these cases:
409 * 1. write utmp entries on some systems 538 * 1. write utmp entries on some systems
410 * 2. chown tty on some systems 539 * 2. chown tty on some systems
411 */ 540 */
412 rxvt_privileges (SAVE); 541 rxvt_privileges (SAVE);
413 rxvt_privileges (IGNORE); 542 rxvt_privileges (IGNORE);
414 543
415 struct sigaction sa; 544 signal (SIGHUP, SIG_IGN);
416 545 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 546
426 /* need to trap SIGURG for SVR4 (Unixware) rlogin */ 547 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
427 /* signal (SIGURG, SIG_DFL); */ 548 /* signal (SIGURG, SIG_DFL); */
428 549
429 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 550 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
551 // TODO: handle this with exceptions and tolerate the memory loss
430 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); 552 XSetIOErrorHandler (rxvt_xioerror_handler);
431} 553}
432 554
433/* ------------------------------------------------------------------------- * 555/* ------------------------------------------------------------------------- *
434 * SIGNAL HANDLING & EXIT HANDLER * 556 * SIGNAL HANDLING & EXIT HANDLER *
435 * ------------------------------------------------------------------------- */ 557 * ------------------------------------------------------------------------- */
436/* 558/*
437 * Catch a SIGCHLD signal and exit if the direct child has died 559 * Catch a SIGCHLD signal and exit if the direct child has died
438 */ 560 */
439 561
440void rxvt_term::child_exited (int pid) 562void
563rxvt_term::sig_chld (sig_watcher &w)
441{ 564{
442 for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) 565 // we are being called for every SIGCHLD, not just ours
443 if (pid == (*t)->cmd_pid) 566 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 567
457 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) 568 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
458 rxvt_term::child_exited (pid); 569 for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++)
459 570 if (pid == (*t)->cmd_pid)
460 errno = save_errno; 571 {
461} 572 (*t)->destroy ();
462 573 break;
463/* 574 }
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}
492
493/*----------------------------------------------------------------------*/
494/*
495 * Exit gracefully, clearing the utmp entry and restoring tty attributes
496 * TODO: if debugging, this should free up any known resources if we can
497 */
498/* INTPROTO */
499void
500rxvt_clean_exit ()
501{
502 // TODO: rxvtd should clean up all ressources
503 if (GET_R)
504 GET_R->destroy ();
505} 575}
506 576
507/* ------------------------------------------------------------------------- * 577/* ------------------------------------------------------------------------- *
508 * MEMORY ALLOCATION WRAPPERS * 578 * MEMORY ALLOCATION WRAPPERS *
509 * ------------------------------------------------------------------------- */ 579 * ------------------------------------------------------------------------- */
510/* INTPROTO */ 580void *
511void *
512rxvt_malloc (size_t size) 581rxvt_malloc (size_t size)
513{ 582{
514 void *p;
515
516 p = malloc (size); 583 void *p = malloc (size);
584
517 if (p) 585 if (!p)
518 return p;
519
520 rxvt_fatal ("memory allocation failure. aborting.\n"); 586 rxvt_fatal ("memory allocation failure. aborting.\n");
521 /* NOTREACHED */ 587
588 return p;
522} 589}
523 590
524/* INTPROTO */ 591/* INTPROTO */
525void * 592void *
526rxvt_calloc (size_t number, size_t size) 593rxvt_calloc (size_t number, size_t size)
527{ 594{
528 void *p;
529
530 p = calloc (number, size); 595 void *p = calloc (number, size);
596
531 if (p) 597 if (!p)
532 return p;
533
534 rxvt_fatal ("memory allocation failure. aborting.\n"); 598 rxvt_fatal ("memory allocation failure. aborting.\n");
535 /* NOTREACHED */ 599
600 return p;
536} 601}
537 602
538/* INTPROTO */ 603/* INTPROTO */
539void * 604void *
540rxvt_realloc (void *ptr, size_t size) 605rxvt_realloc (void *ptr, size_t size)
541{ 606{
542 void *p;
543
544 if (ptr)
545 p = realloc (ptr, size); 607 void *p = realloc (ptr, size);
546 else
547 p = malloc (size);
548 608
549 if (p) 609 if (!p)
550 return p;
551
552 rxvt_fatal ("memory allocation failure. aborting.\n"); 610 rxvt_fatal ("memory allocation failure. aborting.\n");
553 /* NOTREACHED */ 611
612 return p;
554} 613}
555 614
556/* ------------------------------------------------------------------------- * 615/* ------------------------------------------------------------------------- *
557 * PRIVILEGED OPERATIONS * 616 * PRIVILEGED OPERATIONS *
558 * ------------------------------------------------------------------------- */ 617 * ------------------------------------------------------------------------- */
633 * if width/height are non-zero then override calculated width/height 692 * if width/height are non-zero then override calculated width/height
634 */ 693 */
635void 694void
636rxvt_term::window_calc (unsigned int width, unsigned int height) 695rxvt_term::window_calc (unsigned int width, unsigned int height)
637{ 696{
638 short recalc_x, recalc_y; 697 short recalc_x, recalc_y;
639 int x, y, sb_w, mb_h, flags; 698 int x, y, sb_w, mb_h, flags;
640 unsigned int w, h; 699 unsigned int w, h;
641 unsigned int max_width, max_height; 700 unsigned int max_width, max_height;
701 dDisp;
642 702
643 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 703 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
644 TermWin.ncol, TermWin.nrow, szHint.width, 704 TermWin.ncol, TermWin.nrow, szHint.width,
645 szHint.height)); 705 szHint.height));
646 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; 706 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
744 804
745 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 805 if (scrollbar_visible () && (options & Opt_scrollBar_right))
746 window_sb_x = szHint.width - sb_w; 806 window_sb_x = szHint.width - sb_w;
747 807
748 if (recalc_x) 808 if (recalc_x)
749 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 809 szHint.x += (DisplayWidth (disp, display->screen)
750 - szHint.width - 2 * TermWin.ext_bwidth); 810 - szHint.width - 2 * TermWin.ext_bwidth);
751 if (recalc_y) 811 if (recalc_y)
752 szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) 812 szHint.y += (DisplayHeight (disp, display->screen)
753 - szHint.height - 2 * TermWin.ext_bwidth); 813 - szHint.height - 2 * TermWin.ext_bwidth);
754 814
755 TermWin.ncol = TermWin.width / TermWin.fwidth; 815 TermWin.ncol = TermWin.width / TermWin.fwidth;
756 TermWin.nrow = TermWin.height / TermWin.fheight; 816 TermWin.nrow = TermWin.height / TermWin.fheight;
757 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 817 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
798rxvt_term::set_fonts () 858rxvt_term::set_fonts ()
799{ 859{
800 rxvt_fontset *fs = new rxvt_fontset (this); 860 rxvt_fontset *fs = new rxvt_fontset (this);
801 rxvt_fontprop prop; 861 rxvt_fontprop prop;
802 862
803 prop.width = prop.height = prop.weight = prop.slant
804 = rxvt_fontprop::unset;
805
806 if (!fs 863 if (!fs
807 || !fs->populate (rs[Rs_font] ? rs[Rs_font] : "fixed", prop) 864 || !fs->populate (rs[Rs_font] ? rs[Rs_font] : "fixed")
808 || !fs->realize_font (1)) 865 || !fs->realize_font (1))
809 { 866 {
810 delete fs; 867 delete fs;
811 return false; 868 return false;
812 } 869 }
818#endif 875#endif
819 876
820 delete TermWin.fontset[0]; 877 delete TermWin.fontset[0];
821 TermWin.fontset[0] = fs; 878 TermWin.fontset[0] = fs;
822 879
823 fs->prop = prop = (*fs)[1]->properties (); 880 prop = (*fs)[1]->properties ();
881 prop.height += TermWin.lineSpace;
882 fs->set_prop (prop);
824 883
825 TermWin.fwidth = prop.width; 884 TermWin.fwidth = prop.width;
826 TermWin.fheight = prop.height; 885 TermWin.fheight = prop.height;
827 TermWin.fweight = prop.weight; 886 TermWin.fweight = prop.weight;
828 TermWin.fslant = prop.slant; 887 TermWin.fslant = prop.slant;
848 907
849 if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold; 908 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; 909 if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic;
851 } 910 }
852 911
853 fs->populate (res, prop2); 912 fs->populate (res);
913 fs->set_prop (prop2);
854 } 914 }
855#else 915#else
856 TermWin.fontset[style] = TermWin.fontset[0]; 916 TermWin.fontset[style] = TermWin.fontset[0];
857#endif 917#endif
858 } 918 }
865 } 925 }
866 926
867 return true; 927 return true;
868} 928}
869 929
930void rxvt_term::set_string_property (Atom prop, const char *str, int len)
931{
932 // TODO: SMART_WINDOW_TITLE
933 XChangeProperty (display->display, TermWin.parent[0],
934 prop, XA_STRING, 8, PropModeReplace,
935 (const unsigned char *)str, len >= 0 ? len : strlen (str));
936}
937
938void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
939{
940 // TODO: SMART_WINDOW_TITLE
941 wchar_t *ws = rxvt_mbstowcs (str, len);
942 char *s = rxvt_wcstoutf8 (ws);
943
944 XChangeProperty (display->display, TermWin.parent[0],
945 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,
946 (const unsigned char *)s, strlen (s));
947
948 free (s);
949 free (ws);
950}
951
870/*----------------------------------------------------------------------*/ 952/*----------------------------------------------------------------------*/
871/*----------------------------------------------------------------------*/ 953/*----------------------------------------------------------------------*/
872/* xterm sequences - title, iconName, color (exptl) */ 954/* xterm sequences - title, iconName, color (exptl) */
873void 955void
874rxvt_term::set_title (const char *str) 956rxvt_term::set_title (const char *str)
875{ 957{
876#ifdef SMART_WINDOW_TITLE 958 set_string_property (XA_WM_NAME, str);
877 char *name; 959#if ENABLE_FRILLS
878 960 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 961#endif
890} 962}
891 963
892void 964void
893rxvt_term::set_icon_name (const char *str) 965rxvt_term::set_icon_name (const char *str)
894{ 966{
895#ifdef SMART_WINDOW_TITLE 967 set_string_property (XA_WM_ICON_NAME, str);
896 char *name; 968#if ENABLE_FRILLS
897 969 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 970#endif
909} 971}
910 972
911#ifdef XTERM_COLOR_CHANGE 973#ifdef XTERM_COLOR_CHANGE
912void 974void
920 982
921 /* handle color aliases */ 983 /* handle color aliases */
922 if (isdigit (*color)) 984 if (isdigit (*color))
923 { 985 {
924 i = atoi (color); 986 i = atoi (color);
987
925 if (i >= 8 && i <= 15) 988 if (i >= 8 && i <= 15)
926 { /* bright colors */ 989 { /* bright colors */
927 i -= 8; 990 i -= 8;
928# ifndef NO_BRIGHTCOLOR 991# ifndef NO_BRIGHTCOLOR
929 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 992 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
930 SET_PIXCOLOR (idx); 993 SET_PIXCOLOR (idx);
931 goto Done; 994 goto Done;
932# endif 995# endif
933
934 } 996 }
997
935 if (i >= 0 && i <= 7) 998 if (i >= 0 && i <= 7)
936 { /* normal colors */ 999 { /* normal colors */
937 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 1000 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
938 SET_PIXCOLOR (idx); 1001 SET_PIXCOLOR (idx);
939 goto Done; 1002 goto Done;
940 } 1003 }
941 } 1004 }
942 1005
943 if (!rXParseAllocColor (& xcol, color)) 1006 if (!rXParseAllocColor (&xcol, color))
944 return; 1007 return;
945 1008
946 /* XStoreColor (display->display, display->cmap, XColor*); */ 1009 /* XStoreColor (display->display, display->cmap, XColor*); */
947 1010
948 /* 1011 /*
1031 1094
1032 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); 1095 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
1033} 1096}
1034 1097
1035/*----------------------------------------------------------------------*/ 1098/*----------------------------------------------------------------------*/
1036/*
1037 * Colour determination for low colour displays, routine from
1038 * Hans de Goede <hans@highrise.nl>
1039 */
1040 1099
1041int 1100int
1042rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1101rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
1043{ 1102{
1044 if (!screen_in_out->set (display, colour)) 1103 if (!screen_in_out->set (display, colour))
1055 * -------------------------------------------------------------------- */ 1114 * -------------------------------------------------------------------- */
1056void 1115void
1057rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) 1116rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent)
1058{ 1117{
1059 int fix_screen; 1118 int fix_screen;
1060
1061#ifdef SMART_RESIZE 1119#ifdef SMART_RESIZE
1062 int old_width = szHint.width, old_height = szHint.height; 1120 int old_width = szHint.width, old_height = szHint.height;
1063#endif 1121#endif
1122 dDisp;
1064 1123
1065 window_calc (width, height); 1124 window_calc (width, height);
1066 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1125 XSetWMNormalHints (disp, TermWin.parent[0], &szHint);
1067 1126
1068 if (!ignoreparent) 1127 if (!ignoreparent)
1069 { 1128 {
1070#ifdef SMART_RESIZE 1129#ifdef SMART_RESIZE
1071 /* 1130 /*
1075 int x, y, x1, y1; 1134 int x, y, x1, y1;
1076 int dx, dy; 1135 int dx, dy;
1077 unsigned int unused_w1, unused_h1, unused_b1, unused_d1; 1136 unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
1078 Window unused_cr; 1137 Window unused_cr;
1079 1138
1080 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1139 XTranslateCoordinates (disp, TermWin.parent[0], display->root,
1081 0, 0, &x, &y, &unused_cr); 1140 0, 0, &x, &y, &unused_cr);
1082 XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1, 1141 XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1,
1083 &unused_w1, &unused_h1, &unused_b1, &unused_d1); 1142 &unused_w1, &unused_h1, &unused_b1, &unused_d1);
1084 /* 1143 /*
1085 * if display->root isn't the parent window, a WM will probably have offset 1144 * if display->root isn't the parent window, a WM will probably have offset
1086 * our position for handles and decorations. Counter it 1145 * our position for handles and decorations. Counter it
1087 */ 1146 */
1089 { 1148 {
1090 x -= x1; 1149 x -= x1;
1091 y -= y1; 1150 y -= y1;
1092 } 1151 }
1093 1152
1094 x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2; 1153 x1 = (DisplayWidth (disp, display->screen) - old_width) / 2;
1095 y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2; 1154 y1 = (DisplayHeight (disp, display->screen) - old_height) / 2;
1096 dx = old_width - szHint.width; 1155 dx = old_width - szHint.width;
1097 dy = old_height - szHint.height; 1156 dy = old_height - szHint.height;
1098 1157
1099 /* Check position of the center of the window */ 1158 /* Check position of the center of the window */
1100 if (x < x1) /* left half */ 1159 if (x < x1) /* left half */
1104 if (y < y1) /* top half */ 1163 if (y < y1) /* top half */
1105 dy = 0; 1164 dy = 0;
1106 else if (y == y1) /* exact center */ 1165 else if (y == y1) /* exact center */
1107 dy /= 2; 1166 dy /= 2;
1108 1167
1109 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1168 XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy,
1110 szHint.width, szHint.height); 1169 szHint.width, szHint.height);
1111#else 1170#else
1112 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); 1171 XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height);
1113#endif 1172#endif
1114 } 1173 }
1115 1174
1116 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; 1175 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1117 1176
1118 if (fix_screen || width != old_width || height != old_height) 1177 if (fix_screen || width != old_width || height != old_height)
1119 { 1178 {
1120 if (scrollbar_visible ()) 1179 if (scrollbar_visible ())
1121 { 1180 {
1122 XMoveResizeWindow (display->display, scrollBar.win, 1181 XMoveResizeWindow (disp, scrollBar.win,
1123 window_sb_x, 0, 1182 window_sb_x, 0,
1124 scrollbar_TotalWidth (), szHint.height); 1183 scrollbar_TotalWidth (), szHint.height);
1125 resize_scrollbar (); 1184 resize_scrollbar ();
1126 } 1185 }
1127 1186
1128 if (menubar_visible ()) 1187 if (menubar_visible ())
1129 XMoveResizeWindow (display->display, menuBar.win, 1188 XMoveResizeWindow (disp, menuBar.win,
1130 window_vt_x, 0, 1189 window_vt_x, 0,
1131 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1190 TermWin_TotalWidth (), menuBar_TotalHeight ());
1132 1191
1133 XMoveResizeWindow (display->display, TermWin.vt, 1192 XMoveResizeWindow (disp, TermWin.vt,
1134 window_vt_x, window_vt_y, 1193 window_vt_x, window_vt_y,
1135 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1194 TermWin_TotalWidth (), TermWin_TotalHeight ());
1195
1136 scr_clear (); 1196 scr_clear ();
1137#ifdef XPM_BACKGROUND 1197#ifdef XPM_BACKGROUND
1138 resize_pixmap (); 1198 resize_pixmap ();
1139#endif 1199#endif
1140 } 1200 }
1163 } 1223 }
1164 1224
1165 old_width = szHint.width; 1225 old_width = szHint.width;
1166 old_height = szHint.height; 1226 old_height = szHint.height;
1167 1227
1228#ifdef XPM_BACKGROUND
1229 if (TermWin.pixmap)
1230 scr_touch (false);
1231#endif
1232
1168#ifdef USE_XIM 1233#ifdef USE_XIM
1169 IMSetStatusPosition (); 1234 IMSetStatusPosition ();
1170#endif 1235#endif
1171} 1236}
1172 1237
1263} 1328}
1264 1329
1265void 1330void
1266rxvt_term::IMSendSpot () 1331rxvt_term::IMSendSpot ()
1267{ 1332{
1268 XPoint spot; 1333 XPoint nspot;
1269 XVaNestedList preedit_attr; 1334 XVaNestedList preedit_attr;
1270 1335
1271 if (!Input_Context 1336 if (!Input_Context
1272 || !TermWin.focus 1337 || !TermWin.focus
1273 || !(input_style & XIMPreeditPosition) 1338 || !(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; 1339 return;
1283 1340
1284 im_set_position (spot); 1341 im_set_position (nspot);
1342
1343 if (nspot.x == spot.x && nspot.y == spot.y)
1344 return;
1345
1346 spot = nspot;
1285 1347
1286 preedit_attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL); 1348 preedit_attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
1287 XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL); 1349 XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL);
1288 XFree (preedit_attr); 1350 XFree (preedit_attr);
1289} 1351}
1290 1352
1291void 1353void
1292rxvt_term::im_destroy () 1354rxvt_term::im_destroy ()
1293{ 1355{
1294 if (Input_Context)
1295 {
1296 XDestroyIC (Input_Context);
1297 Input_Context = 0;
1298 }
1299
1300 if (input_method) 1356 if (input_method)
1301 { 1357 {
1358 if (Input_Context && input_method->xim)
1359 XDestroyIC (Input_Context);
1360
1302 display->put_xim (input_method); 1361 display->put_xim (input_method);
1303 input_method = 0; 1362 input_method = 0;
1304 } 1363 }
1364
1365 Input_Context = 0;
1305} 1366}
1306 1367
1307/* 1368/*
1308 * Try to open a XIM with the current modifiers, then see if we can 1369 * Try to open a XIM with the current modifiers, then see if we can
1309 * open a suitable preedit type 1370 * open a suitable preedit type
1327 input_method = display->get_xim (locale, modifiers); 1388 input_method = display->get_xim (locale, modifiers);
1328 if (input_method == NULL) 1389 if (input_method == NULL)
1329 return false; 1390 return false;
1330 1391
1331 xim = input_method->xim; 1392 xim = input_method->xim;
1393 spot.x = spot.y = -1;
1332 1394
1333 xim_styles = NULL; 1395 xim_styles = NULL;
1334 if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL) 1396 if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL)
1335 || !xim_styles || !xim_styles->count_styles) 1397 || !xim_styles || !xim_styles->count_styles)
1336 { 1398 {
1337 im_destroy (); 1399 im_destroy ();
1338 return false; 1400 return false;
1339 } 1401 }
1340 1402
1341 p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root"; 1403 const char *pet[] = { rs[Rs_preeditType], "OverTheSpot,OffTheSpot,Root,None" };
1404
1405 for (int pi = 0; pi < 2; pi++)
1406 {
1407 p = pet[pi];
1408
1409 if (!p)
1410 continue;
1411
1342 s = rxvt_splitcommastring (p); 1412 s = rxvt_splitcommastring (p);
1343 1413
1344 for (i = found = 0; !found && s[i]; i++) 1414 for (i = found = 0; !found && s[i]; i++)
1345 { 1415 {
1346 if (!strcmp (s[i], "OverTheSpot")) 1416 if (!strcmp (s[i], "OverTheSpot"))
1347 input_style = (XIMPreeditPosition | XIMStatusNothing); 1417 input_style = (XIMPreeditPosition | XIMStatusNothing);
1348 else if (!strcmp (s[i], "OffTheSpot")) 1418 else if (!strcmp (s[i], "OffTheSpot"))
1349 input_style = (XIMPreeditArea | XIMStatusArea); 1419 input_style = (XIMPreeditArea | XIMStatusArea);
1350 else if (!strcmp (s[i], "Root")) 1420 else if (!strcmp (s[i], "Root"))
1351 input_style = (XIMPreeditNothing | XIMStatusNothing); 1421 input_style = (XIMPreeditNothing | XIMStatusNothing);
1422 else if (!strcmp (s[i], "None"))
1423 input_style = (XIMPreeditNone | XIMStatusNone);
1352 1424
1353 for (j = 0; j < xim_styles->count_styles; j++) 1425 for (j = 0; j < xim_styles->count_styles; j++)
1354 if (input_style == xim_styles->supported_styles[j]) 1426 if (input_style == xim_styles->supported_styles[j])
1355 { 1427 {
1428 rxvt_freecommastring (s);
1429
1356 found = 1; 1430 found = 1;
1357 break; 1431 goto foundpet;
1432 }
1433
1358 } 1434 }
1359 }
1360 1435
1361 for (i = 0; s[i]; i++) 1436 rxvt_freecommastring (s);
1362 free (s[i]); 1437 }
1363 1438
1364 free (s); 1439foundpet:
1440
1365 XFree (xim_styles); 1441 XFree (xim_styles);
1366 1442
1367 if (!found) 1443 if (!found)
1368 { 1444 {
1369 im_destroy (); 1445 im_destroy ();
1390 "*", 1466 "*",
1391 TermWin.fheight, 1467 TermWin.fheight,
1392 TermWin.fheight + 1, TermWin.fheight - 1, 1468 TermWin.fheight + 1, TermWin.fheight - 1,
1393 TermWin.fheight - 2, TermWin.fheight + 2); 1469 TermWin.fheight - 2, TermWin.fheight + 2);
1394 1470
1395 fs = XCreateFontSet (display->display, pat, 1471 fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat,
1396 &missing_charset_list, &missing_charset_count, &def_string); 1472 &missing_charset_list, &missing_charset_count, &def_string);
1397 1473
1398 if (missing_charset_list) 1474 if (missing_charset_list)
1399 XFreeStringList (missing_charset_list); 1475 XFreeStringList (missing_charset_list);
1400 1476
1477 int i, found, had_im; 1553 int i, found, had_im;
1478 const char *p; 1554 const char *p;
1479 char **s; 1555 char **s;
1480 char buf[IMBUFSIZ]; 1556 char buf[IMBUFSIZ];
1481 1557
1558 SET_R (this);
1559
1482 im_destroy (); 1560 im_destroy ();
1483 1561
1484 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); 1562 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
1485 if (Input_Context) 1563 if (Input_Context)
1486 return; 1564 return;
1494 if (p && *p) 1572 if (p && *p)
1495 { 1573 {
1496 bool found = false; 1574 bool found = false;
1497 1575
1498 s = rxvt_splitcommastring (p); 1576 s = rxvt_splitcommastring (p);
1577
1499 for (i = 0; s[i]; i++) 1578 for (i = 0; s[i]; i++)
1500 { 1579 {
1501 if (*s[i]) 1580 if (*s[i])
1502 { 1581 {
1503 strcpy (buf, "@im="); 1582 strcpy (buf, "@im=");
1507 found = true; 1586 found = true;
1508 break; 1587 break;
1509 } 1588 }
1510 } 1589 }
1511 } 1590 }
1512 for (i = 0; s[i]; i++) 1591
1513 free (s[i]); 1592 rxvt_freecommastring (s);
1514 free (s);
1515 1593
1516 if (found) 1594 if (found)
1517 goto done; 1595 goto done;
1518 } 1596 }
1519 1597

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines