home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.1.472 < prev    next >
Encoding:
Internet Message Format  |  2003-04-17  |  6.3 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.472
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.1.472
  11. Problem:    When there is an authentication error when connecting to the X
  12.         server Vim exits.
  13. Solution:   Use XSetIOErrorHandler() to catch the error and longjmp() to avoid
  14.         the exit.  Also do this in the main loop, so that when the X
  15.         server exits a Vim running in a console isn't killed.
  16. Files:        src/globals.h, src/main.c, src/os_unix.c
  17.  
  18.  
  19. *** ../vim61.471/src/globals.h    Thu Apr 10 22:38:13 2003
  20. --- src/globals.h    Wed Apr 16 22:19:13 2003
  21. ***************
  22. *** 542,547 ****
  23. --- 542,552 ----
  24.   EXTERN int    vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */
  25.   #endif
  26.   
  27. + #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
  28. + /* argument to SETJMP() for handling X IO errors */
  29. + EXTERN JMP_BUF x_jump_env;
  30. + #endif
  31.   #if defined(HAVE_SETJMP_H)
  32.   /*
  33.    * Stuff for setjmp() and longjmp().
  34. *** ../vim61.471/src/main.c    Wed Apr 16 20:43:41 2003
  35. --- src/main.c    Fri Apr 18 14:23:46 2003
  36. ***************
  37. *** 1940,1945 ****
  38. --- 1940,1977 ----
  39.   {
  40.       oparg_T    oa;    /* operator arguments */
  41.   
  42. + #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
  43. +     /* Setup to catch a terminating error from the X server.  Just ignore
  44. +      * it, restore the state and continue.  This might not always work
  45. +      * properly, but at least we don't exit unexpectedly when the X server
  46. +      * exists while Vim is running in a console. */
  47. +     if (!cmdwin && SETJMP(x_jump_env))
  48. +     {
  49. +     State = NORMAL;
  50. + # ifdef FEAT_VISUAL
  51. +     VIsual_active = FALSE;
  52. + # endif
  53. +     got_int = TRUE;
  54. +     need_wait_return = FALSE;
  55. +     global_busy = FALSE;
  56. +     exmode_active = 0;
  57. +     skip_redraw = FALSE;
  58. +     RedrawingDisabled = 0;
  59. +     no_wait_return = 0;
  60. + # ifdef FEAT_EVAL
  61. +     emsg_skip = 0;
  62. + # endif
  63. +     emsg_off = 0;
  64. + # ifdef FEAT_MOUSE
  65. +     setmouse();
  66. + # endif
  67. +     settmode(TMODE_RAW);
  68. +     starttermcap();
  69. +     scroll_start();
  70. +     redraw_later_clear();
  71. +     }
  72. + #endif
  73.       clear_oparg(&oa);
  74.       while (!cmdwin
  75.   #ifdef FEAT_CMDWIN
  76. *** ../vim61.471/src/os_unix.c    Wed Apr 16 20:56:52 2003
  77. --- src/os_unix.c    Wed Apr 16 22:18:16 2003
  78. ***************
  79. *** 751,757 ****
  80.    * A simplistic version of setjmp() that only allows one level of using.
  81.    * Don't call twice before calling mch_endjmp()!.
  82.    * Usage:
  83. !  *    mch_startjmp()
  84.    *    if (SETJMP(lc_jump_env) != 0)
  85.    *    {
  86.    *        mch_didjmp();
  87. --- 751,757 ----
  88.    * A simplistic version of setjmp() that only allows one level of using.
  89.    * Don't call twice before calling mch_endjmp()!.
  90.    * Usage:
  91. !  *    mch_startjmp();
  92.    *    if (SETJMP(lc_jump_env) != 0)
  93.    *    {
  94.    *        mch_didjmp();
  95. ***************
  96. *** 1190,1195 ****
  97. --- 1190,1234 ----
  98.       return 0;
  99.   }
  100.   
  101. + #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
  102. + # if defined(HAVE_SETJMP_H)
  103. + /*
  104. +  * An X IO Error handler, used to catch error while opening the display.
  105. +  */
  106. + static int x_IOerror_check __ARGS((Display *dpy));
  107. + /* ARGSUSED */
  108. +     static int
  109. + x_IOerror_check(dpy)
  110. +     Display *dpy;
  111. + {
  112. +     /* This function should not return, it causes exit().  Longjump instead. */
  113. +     LONGJMP(lc_jump_env, 1);
  114. +     /*NOTREACHED*/
  115. + }
  116. + # endif
  117. + /*
  118. +  * An X IO Error handler, used to catch terminal errors.
  119. +  */
  120. + static int x_IOerror_handler __ARGS((Display *dpy));
  121. + /* ARGSUSED */
  122. +     static int
  123. + x_IOerror_handler(dpy)
  124. +     Display *dpy;
  125. + {
  126. +     xterm_dpy = NULL;
  127. +     x11_window = 0;
  128. +     x11_display = NULL;
  129. +     xterm_Shell = (Widget)0;
  130. +     /* This function should not return, it causes exit().  Longjump instead. */
  131. +     LONGJMP(x_jump_env, 1);
  132. +     /*NOTREACHED*/
  133. + }
  134. + #endif
  135.   /*
  136.    * Return TRUE when connection to the X server is desired.
  137.    */
  138. ***************
  139. *** 5203,5209 ****
  140. --- 5242,5251 ----
  141.        */
  142.       mch_startjmp();
  143.       if (SETJMP(lc_jump_env) != 0)
  144. +     {
  145.           success = FALSE;
  146. +         mch_didjmp();
  147. +     }
  148.       else
  149.   # endif
  150.       {
  151. ***************
  152. *** 5310,5315 ****
  153. --- 5352,5360 ----
  154.       if (app_context != NULL && xterm_Shell == (Widget)0)
  155.       {
  156.       int (*oldhandler)();
  157. + #if defined(HAVE_SETJMP_H)
  158. +     int (*oldIOhandler)();
  159. + #endif
  160.   # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
  161.       struct timeval  start_tv;
  162.   
  163. ***************
  164. *** 5320,5328 ****
  165.       /* Ignore X errors while opening the display */
  166.       oldhandler = XSetErrorHandler(x_error_check);
  167.   
  168. !     xterm_dpy = XtOpenDisplay(app_context, xterm_display,
  169. !         "vim_xterm", "Vim_xterm", NULL, 0, &z, &strp);
  170.   
  171.       /* Now handle X errors normally. */
  172.       (void)XSetErrorHandler(oldhandler);
  173.   
  174. --- 5365,5393 ----
  175.       /* Ignore X errors while opening the display */
  176.       oldhandler = XSetErrorHandler(x_error_check);
  177.   
  178. ! #if defined(HAVE_SETJMP_H)
  179. !     /* Ignore X IO errors while opening the display */
  180. !     oldIOhandler = XSetIOErrorHandler(x_IOerror_check);
  181. !     mch_startjmp();
  182. !     if (SETJMP(lc_jump_env) != 0)
  183. !     {
  184. !         mch_didjmp();
  185. !         xterm_dpy = NULL;
  186. !     }
  187. !     else
  188. ! #endif
  189. !     {
  190. !         xterm_dpy = XtOpenDisplay(app_context, xterm_display,
  191. !             "vim_xterm", "Vim_xterm", NULL, 0, &z, &strp);
  192. ! #if defined(HAVE_SETJMP_H)
  193. !         mch_endjmp();
  194. ! #endif
  195. !     }
  196.   
  197. + #if defined(HAVE_SETJMP_H)
  198. +     /* Now handle X IO errors normally. */
  199. +     (void)XSetIOErrorHandler(oldIOhandler);
  200. + #endif
  201.       /* Now handle X errors normally. */
  202.       (void)XSetErrorHandler(oldhandler);
  203.   
  204. ***************
  205. *** 5332,5337 ****
  206. --- 5397,5405 ----
  207.           MSG(_("Opening the X display failed"));
  208.           return;
  209.       }
  210. +     /* Catch terminating error of the X server connection. */
  211. +     (void)XSetIOErrorHandler(x_IOerror_handler);
  212.   
  213.   # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
  214.       if (p_verbose > 0)
  215. *** ../vim61.471/src/version.c    Fri Apr 18 12:32:44 2003
  216. --- src/version.c    Fri Apr 18 14:30:24 2003
  217. ***************
  218. *** 613,614 ****
  219. --- 613,616 ----
  220.   {   /* Add new patch number below this line */
  221. + /**/
  222. +     472,
  223.   /**/
  224.  
  225. -- 
  226. hundred-and-one symptoms of being an internet addict:
  227. 20. When looking at a pageful of someone else's links, you notice all of them
  228.     are already highlighted in purple.
  229.  
  230.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  231. ///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
  232. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  233.  \\\     Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
  234.