Patch 8.2.0694
Problem:    Haiku: channel and terminal do not work.
Solution:   Close files when the job has finished. (Ozaki Kiichi,
            closes #6039)
Files:      src/channel.c, src/getchar.c, src/gui_haiku.cc, src/misc1.c


*** ../vim-8.2.0693/src/channel.c       2020-05-03 17:03:26.193589966 +0200
--- src/channel.c       2020-05-03 22:54:49.037880880 +0200
***************
*** 3940,3946 ****
      free_job_options(&opt);
  }
  
! # if defined(MSWIN) || defined(FEAT_GUI) || defined(PROTO)
  /*
   * Check the channels for anything that is ready to be read.
   * The data is put in the read queue.
--- 3940,3946 ----
      free_job_options(&opt);
  }
  
! #if defined(MSWIN) || defined(__HAIKU__) || defined(FEAT_GUI) || 
defined(PROTO)
  /*
   * Check the channels for anything that is ready to be read.
   * The data is put in the read queue.
***************
*** 3973,3981 ****
                                                     "channel_handle_events");
            }
        }
      }
  }
! # endif
  
  # if defined(FEAT_GUI) || defined(PROTO)
  /*
--- 3973,3995 ----
                                                     "channel_handle_events");
            }
        }
+ 
+ # ifdef __HAIKU__
+       // Workaround for Haiku: Since select/poll cannot detect EOF from tty,
+       // should close fds when the job has finished if 'channel' connects to
+       // the pty.
+       if (channel->ch_job != NULL)
+       {
+           job_T *job = channel->ch_job;
+ 
+           if (job->jv_tty_out != NULL && job->jv_status == JOB_FINISHED)
+               for (part = PART_SOCK; part < PART_COUNT; ++part)
+                   ch_close_part(channel, part);
+       }
+ # endif
      }
  }
! #endif
  
  # if defined(FEAT_GUI) || defined(PROTO)
  /*
***************
*** 4541,4546 ****
--- 4555,4574 ----
            channel_write_input(channel);
            --ret;
        }
+ 
+ # ifdef __HAIKU__
+       // Workaround for Haiku: Since select/poll cannot detect EOF from tty,
+       // should close fds when the job has finished if 'channel' connects to
+       // the pty.
+       if (channel->ch_job != NULL)
+       {
+           job_T *job = channel->ch_job;
+ 
+           if (job->jv_tty_out != NULL && job->jv_status == JOB_FINISHED)
+               for (part = PART_SOCK; part < PART_COUNT; ++part)
+                   ch_close_part(channel, part);
+       }
+ # endif
      }
  
      return ret;
*** ../vim-8.2.0693/src/getchar.c       2020-05-01 14:26:17.128949276 +0200
--- src/getchar.c       2020-05-03 22:54:49.037880880 +0200
***************
*** 2147,2153 ****
      for (i = 0; i < MAX_REPEAT_PARSE; ++i)
      {
        // For Win32 mch_breakcheck() does not check for input, do it here.
! # if defined(MSWIN) && defined(FEAT_JOB_CHANNEL)
        channel_handle_events(FALSE);
  # endif
  
--- 2147,2153 ----
      for (i = 0; i < MAX_REPEAT_PARSE; ++i)
      {
        // For Win32 mch_breakcheck() does not check for input, do it here.
! # if (defined(MSWIN) || defined(__HAIKU__)) && defined(FEAT_JOB_CHANNEL)
        channel_handle_events(FALSE);
  # endif
  
*** ../vim-8.2.0693/src/gui_haiku.cc    2020-04-30 22:50:55.605076816 +0200
--- src/gui_haiku.cc    2020-05-03 22:54:49.037880880 +0200
***************
*** 1145,1154 ****
  VimTextAreaView::VimTextAreaView(BRect frame):
      BView(frame, "VimTextAreaView", B_FOLLOW_ALL_SIDES,
  #ifdef FEAT_MBYTE_IME
!       B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INPUT_METHOD_AWARE),
  #else
!       B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
  #endif
      mouseDragEventCount(0)
  {
  #ifdef FEAT_MBYTE_IME
--- 1145,1155 ----
  VimTextAreaView::VimTextAreaView(BRect frame):
      BView(frame, "VimTextAreaView", B_FOLLOW_ALL_SIDES,
  #ifdef FEAT_MBYTE_IME
!       B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INPUT_METHOD_AWARE
  #else
!       B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE
  #endif
+       ),
      mouseDragEventCount(0)
  {
  #ifdef FEAT_MBYTE_IME
***************
*** 3093,3099 ****
                        }
                    }
  #else
!                   add_to_input_buf_csi(string, len);
  #endif
                    else
                        add_to_input_buf(string, len);
--- 3094,3100 ----
                        }
                    }
  #else
!                       add_to_input_buf_csi(string, len);
  #endif
                    else
                        add_to_input_buf(string, len);
***************
*** 4437,4451 ****
        int     wtime)
  {
      int               focus;
!     bigtime_t     until, timeout;
!     status_t      st;
  
!     if (wtime >= 0) {
        timeout = wtime * 1000;
        until = system_time() + timeout;
-     } else {
-       timeout = B_INFINITE_TIMEOUT;
      }
  
      focus = gui.in_focus;
      for (;;)
--- 4438,4453 ----
        int     wtime)
  {
      int               focus;
!     bigtime_t until, timeout;
!     status_t  st;
  
!     if (wtime >= 0)
!     {
        timeout = wtime * 1000;
        until = system_time() + timeout;
      }
+     else
+       timeout = B_INFINITE_TIMEOUT;
  
      focus = gui.in_focus;
      for (;;)
***************
*** 4461,4466 ****
--- 4463,4490 ----
        }
  
        gui_mch_flush();
+ 
+ #ifdef MESSAGE_QUEUE
+ # ifdef FEAT_TIMERS
+       did_add_timer = FALSE;
+ # endif
+       parse_queued_messages();
+ # ifdef FEAT_TIMERS
+       if (did_add_timer)
+           // Need to recompute the waiting time.
+           break;
+ # endif
+ # ifdef FEAT_JOB_CHANNEL
+       if (has_any_channel())
+       {
+           if (wtime < 0 || timeout > 20000)
+               timeout = 20000;
+       }
+       else if (wtime < 0)
+           timeout = B_INFINITE_TIMEOUT;
+ # endif
+ #endif
+ 
        /*
         * Don't use gui_mch_update() because then we will spin-lock until a
         * char arrives, instead we use gui_haiku_process_event() to hang until
***************
*** 4478,4484 ****
         * Calculate how much longer we're willing to wait for the
         * next event.
         */
!       if (wtime >= 0) {
            timeout = until - system_time();
            if (timeout < 0)
                break;
--- 4502,4509 ----
         * Calculate how much longer we're willing to wait for the
         * next event.
         */
!       if (wtime >= 0)
!       {
            timeout = until - system_time();
            if (timeout < 0)
                break;
*** ../vim-8.2.0693/src/misc1.c 2020-04-12 19:37:13.518297259 +0200
--- src/misc1.c 2020-05-03 22:54:49.037880880 +0200
***************
*** 1666,1688 ****
  
      if (p != NULL)
        return p;
  #endif
  
      // handling $VIMRUNTIME and $VIM is below, bail out if it's another name.
      vimruntime = (STRCMP(name, "VIMRUNTIME") == 0);
      if (!vimruntime && STRCMP(name, "VIM") != 0)
- #if defined(__HAIKU__)
-       // special handling for user settings directory...
-       if (STRCMP(name, "BE_USER_SETTINGS") == 0)
-       {
-           static char userSettingsPath[MAXPATHL] = {0};
- 
-           if (B_OK == find_directory(B_USER_SETTINGS_DIRECTORY, 0,
-                                           false, userSettingsPath, MAXPATHL))
-               return userSettingsPath;
-       }
-       else
- #endif
        return NULL;
  
      /*
--- 1666,1690 ----
  
      if (p != NULL)
        return p;
+ 
+ # ifdef __HAIKU__
+     // special handling for user settings directory...
+     if (STRCMP(name, "BE_USER_SETTINGS") == 0)
+     {
+       static char userSettingsPath[MAXPATHL];
+ 
+       if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false,
+                                          userSettingsPath, MAXPATHL) == B_OK)
+           return (char_u *)userSettingsPath;
+       else
+           return NULL;
+     }
+ # endif
  #endif
  
      // handling $VIMRUNTIME and $VIM is below, bail out if it's another name.
      vimruntime = (STRCMP(name, "VIMRUNTIME") == 0);
      if (!vimruntime && STRCMP(name, "VIM") != 0)
        return NULL;
  
      /*
*** ../vim-8.2.0693/src/version.c       2020-05-03 22:30:44.038682664 +0200
--- src/version.c       2020-05-03 22:52:59.446180953 +0200
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     694,
  /**/

-- 
Microsoft is to software what McDonalds is to gourmet cooking

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005032058.043Kw8Sv016260%40masaka.moolenaar.net.

Raspunde prin e-mail lui