Patch 9.0.0777
Problem:    Code is indented too much.
Solution:   Use an early return. (Yegappan Lakshmanan, closes #11386)
Files:      src/change.c, src/channel.c


*** ../vim-9.0.0776/src/change.c        2022-10-15 16:04:43.998187220 +0100
--- src/change.c        2022-10-16 21:35:15.542496715 +0100
***************
*** 28,70 ****
  {
      static char *w_readonly = N_("W10: Warning: Changing a readonly file");
  
!     if (curbuf->b_did_warn == FALSE
!           && curbufIsChanged() == 0
!           && !autocmd_busy
!           && curbuf->b_p_ro)
!     {
!       ++curbuf_lock;
!       apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
!       --curbuf_lock;
!       if (!curbuf->b_p_ro)
!           return;
! 
!       // Do what msg() does, but with a column offset if the warning should
!       // be after the mode message.
!       msg_start();
!       if (msg_row == Rows - 1)
!           msg_col = col;
!       msg_source(HL_ATTR(HLF_W));
!       msg_puts_attr(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
  #ifdef FEAT_EVAL
!       set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
  #endif
!       msg_clr_eos();
!       (void)msg_end();
!       if (msg_silent == 0 && !silent_mode
  #ifdef FEAT_EVAL
!               && time_for_testing != 1
  #endif
!               )
!       {
!           out_flush();
!           ui_delay(1002L, TRUE); // give the user time to think about it
!       }
!       curbuf->b_did_warn = TRUE;
!       redraw_cmdline = FALSE; // don't redraw and erase the message
!       if (msg_row < Rows - 1)
!           showmode();
      }
  }
  
  /*
--- 28,70 ----
  {
      static char *w_readonly = N_("W10: Warning: Changing a readonly file");
  
!     if (curbuf->b_did_warn
!           || curbufIsChanged()
!           || autocmd_busy
!           || !curbuf->b_p_ro)
!       return;
! 
!     ++curbuf_lock;
!     apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
!     --curbuf_lock;
!     if (!curbuf->b_p_ro)
!       return;
! 
!     // Do what msg() does, but with a column offset if the warning should
!     // be after the mode message.
!     msg_start();
!     if (msg_row == Rows - 1)
!       msg_col = col;
!     msg_source(HL_ATTR(HLF_W));
!     msg_puts_attr(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
  #ifdef FEAT_EVAL
!     set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
  #endif
!     msg_clr_eos();
!     (void)msg_end();
!     if (msg_silent == 0 && !silent_mode
  #ifdef FEAT_EVAL
!           && time_for_testing != 1
  #endif
!        )
!     {
!       out_flush();
!       ui_delay(1002L, TRUE); // give the user time to think about it
      }
+     curbuf->b_did_warn = TRUE;
+     redraw_cmdline = FALSE;   // don't redraw and erase the message
+     if (msg_row < Rows - 1)
+       showmode();
  }
  
  /*
***************
*** 159,183 ****
        linenr_T        lnume,
        long            xtra)
  {
!     if (buf->b_recorded_changes != NULL && xtra != 0)
!     {
!       listitem_T *li;
!       linenr_T    prev_lnum;
!       linenr_T    prev_lnume;
  
!       FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li)
        {
!           prev_lnum = (linenr_T)dict_get_number(
!                                               li->li_tv.vval.v_dict, "lnum");
!           prev_lnume = (linenr_T)dict_get_number(
!                                                li->li_tv.vval.v_dict, "end");
!           if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
!           {
!               // the current change is going to make the line number in
!               // the older change invalid, flush now
!               invoke_listeners(curbuf);
!               break;
!           }
        }
      }
  }
--- 159,183 ----
        linenr_T        lnume,
        long            xtra)
  {
!     if (buf->b_recorded_changes == NULL || xtra == 0)
!       return;
! 
!     listitem_T *li;
!     linenr_T    prev_lnum;
!     linenr_T    prev_lnume;
  
!     FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li)
!     {
!       prev_lnum = (linenr_T)dict_get_number(
!               li->li_tv.vval.v_dict, "lnum");
!       prev_lnume = (linenr_T)dict_get_number(
!               li->li_tv.vval.v_dict, "end");
!       if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
        {
!           // the current change is going to make the line number in
!           // the older change invalid, flush now
!           invoke_listeners(curbuf);
!           break;
        }
      }
  }
*** ../vim-9.0.0776/src/channel.c       2022-09-06 11:26:52.707124288 +0100
--- src/channel.c       2022-10-16 21:39:53.946630204 +0100
***************
*** 203,246 ****
      static void
  ch_log_lead(const char *what, channel_T *ch, ch_part_T part)
  {
!     if (log_fd != NULL)
!     {
  #ifdef FEAT_RELTIME
!       proftime_T log_now;
  
!       profile_start(&log_now);
!       profile_sub(&log_now, &log_start);
!       fprintf(log_fd, "%s ", profile_msg(&log_now));
  #endif
!       if (ch != NULL)
!       {
!           if (part < PART_COUNT)
!               fprintf(log_fd, "%son %d(%s): ",
!                                          what, ch->ch_id, part_names[part]);
!           else
!               fprintf(log_fd, "%son %d: ", what, ch->ch_id);
!       }
        else
!           fprintf(log_fd, "%s: ", what);
      }
  }
  
  #ifndef PROTO  // prototype is in proto.h
      void
  ch_log(channel_T *ch, const char *fmt, ...)
  {
!     if (log_fd != NULL)
!     {
!       va_list ap;
  
!       ch_log_lead("", ch, PART_COUNT);
!       va_start(ap, fmt);
!       vfprintf(log_fd, fmt, ap);
!       va_end(ap);
!       fputc('\n', log_fd);
!       fflush(log_fd);
!       did_repeated_msg = 0;
!     }
  }
  #endif
  
--- 203,246 ----
      static void
  ch_log_lead(const char *what, channel_T *ch, ch_part_T part)
  {
!     if (log_fd == NULL)
!       return;
! 
  #ifdef FEAT_RELTIME
!     proftime_T log_now;
  
!     profile_start(&log_now);
!     profile_sub(&log_now, &log_start);
!     fprintf(log_fd, "%s ", profile_msg(&log_now));
  #endif
!     if (ch != NULL)
!     {
!       if (part < PART_COUNT)
!           fprintf(log_fd, "%son %d(%s): ",
!                   what, ch->ch_id, part_names[part]);
        else
!           fprintf(log_fd, "%son %d: ", what, ch->ch_id);
      }
+     else
+       fprintf(log_fd, "%s: ", what);
  }
  
  #ifndef PROTO  // prototype is in proto.h
      void
  ch_log(channel_T *ch, const char *fmt, ...)
  {
!     if (log_fd == NULL)
!       return;
  
!     va_list ap;
! 
!     ch_log_lead("", ch, PART_COUNT);
!     va_start(ap, fmt);
!     vfprintf(log_fd, fmt, ap);
!     va_end(ap);
!     fputc('\n', log_fd);
!     fflush(log_fd);
!     did_repeated_msg = 0;
  }
  #endif
  
***************
*** 250,267 ****
      static void
  ch_error(channel_T *ch, const char *fmt, ...)
  {
!     if (log_fd != NULL)
!     {
!       va_list ap;
  
!       ch_log_lead("ERR ", ch, PART_COUNT);
!       va_start(ap, fmt);
!       vfprintf(log_fd, fmt, ap);
!       va_end(ap);
!       fputc('\n', log_fd);
!       fflush(log_fd);
!       did_repeated_msg = 0;
!     }
  }
  
  #ifdef MSWIN
--- 250,267 ----
      static void
  ch_error(channel_T *ch, const char *fmt, ...)
  {
!     if (log_fd == NULL)
!       return;
  
!     va_list ap;
! 
!     ch_log_lead("ERR ", ch, PART_COUNT);
!     va_start(ap, fmt);
!     vfprintf(log_fd, fmt, ap);
!     va_end(ap);
!     fputc('\n', log_fd);
!     fflush(log_fd);
!     did_repeated_msg = 0;
  }
  
  #ifdef MSWIN
***************
*** 445,459 ****
      static void
  channel_free(channel_T *channel)
  {
!     if (!in_free_unref_items)
      {
!       if (safe_to_invoke_callback == 0)
!           channel->ch_to_be_freed = TRUE;
!       else
!       {
!           channel_free_contents(channel);
!           channel_free_channel(channel);
!       }
      }
  }
  
--- 445,459 ----
      static void
  channel_free(channel_T *channel)
  {
!     if (in_free_unref_items)
!       return;
! 
!     if (safe_to_invoke_callback == 0)
!       channel->ch_to_be_freed = TRUE;
!     else
      {
!       channel_free_contents(channel);
!       channel_free_channel(channel);
      }
  }
  
***************
*** 540,555 ****
      channel_T *channel;
      ch_part_T part;
  
!     if (fd != INVALID_FD)
!       FOR_ALL_CHANNELS(channel)
!       {
!           for (part = PART_SOCK; part < PART_IN; ++part)
!               if (channel->ch_part[part].ch_fd == fd)
!               {
!                   *partp = part;
!                   return channel;
!               }
!       }
      return NULL;
  }
  
--- 540,557 ----
      channel_T *channel;
      ch_part_T part;
  
!     if (fd == INVALID_FD)
!       return NULL;
! 
!     FOR_ALL_CHANNELS(channel)
!     {
!       for (part = PART_SOCK; part < PART_IN; ++part)
!           if (channel->ch_part[part].ch_fd == fd)
!           {
!               *partp = part;
!               return channel;
!           }
!     }
      return NULL;
  }
  
***************
*** 1214,1234 ****
        if (buf == NULL)
            buf = buflist_findname_exp(name);
      }
      if (buf == NULL)
!     {
!       buf = buflist_new(name == NULL || *name == NUL ? NULL : name,
!                                    NULL, (linenr_T)0, BLN_LISTED | BLN_NEW);
!       if (buf == NULL)
!           return NULL;
!       prepare_buffer(buf);
  
!       curbuf = buf;
!       if (msg)
!           ml_replace(1, (char_u *)(err ? "Reading from channel error..."
!                                  : "Reading from channel output..."), TRUE);
!       changed_bytes(1, 0);
!       curbuf = save_curbuf;
!     }
  
      return buf;
  }
--- 1216,1237 ----
        if (buf == NULL)
            buf = buflist_findname_exp(name);
      }
+ 
+     if (buf != NULL)
+       return buf;
+ 
+     buf = buflist_new(name == NULL || *name == NUL ? NULL : name,
+           NULL, (linenr_T)0, BLN_LISTED | BLN_NEW);
      if (buf == NULL)
!       return NULL;
!     prepare_buffer(buf);
  
!     curbuf = buf;
!     if (msg)
!       ml_replace(1, (char_u *)(err ? "Reading from channel error..."
!                   : "Reading from channel output..."), TRUE);
!     changed_bytes(1, 0);
!     curbuf = save_curbuf;
  
      return buf;
  }
***************
*** 1479,1508 ****
  {
      sock_T *fd = &channel->ch_part[part].ch_fd;
  
!     if (*fd != INVALID_FD)
      {
!       if (part == PART_SOCK)
!           sock_close(*fd);
!       else
        {
-           // When using a pty the same FD is set on multiple parts, only
-           // close it when the last reference is closed.
-           if ((part == PART_IN || channel->CH_IN_FD != *fd)
-                   && (part == PART_OUT || channel->CH_OUT_FD != *fd)
-                   && (part == PART_ERR || channel->CH_ERR_FD != *fd))
-           {
  #ifdef MSWIN
!               if (channel->ch_named_pipe)
!                   DisconnectNamedPipe((HANDLE)fd);
  #endif
!               fd_close(*fd);
!           }
        }
-       *fd = INVALID_FD;
- 
-       // channel is closed, may want to end the job if it was the last
-       channel->ch_to_be_closed &= ~(1U << part);
      }
  }
  
      void
--- 1482,1511 ----
  {
      sock_T *fd = &channel->ch_part[part].ch_fd;
  
!     if (*fd == INVALID_FD)
!       return;
! 
!     if (part == PART_SOCK)
!       sock_close(*fd);
!     else
      {
!       // When using a pty the same FD is set on multiple parts, only
!       // close it when the last reference is closed.
!       if ((part == PART_IN || channel->CH_IN_FD != *fd)
!               && (part == PART_OUT || channel->CH_OUT_FD != *fd)
!               && (part == PART_ERR || channel->CH_ERR_FD != *fd))
        {
  #ifdef MSWIN
!           if (channel->ch_named_pipe)
!               DisconnectNamedPipe((HANDLE)fd);
  #endif
!           fd_close(*fd);
        }
      }
+     *fd = INVALID_FD;
+ 
+     // channel is closed, may want to end the job if it was the last
+     channel->ch_to_be_closed &= ~(1U << part);
  }
  
      void
***************
*** 1556,1589 ****
  
      channel_set_options(channel, options);
  
!     if (job->jv_in_buf != NULL)
!     {
!       chanpart_T *in_part = &channel->ch_part[PART_IN];
  
!       set_bufref(&in_part->ch_bufref, job->jv_in_buf);
!       ch_log(channel, "reading from buffer '%s'",
!                                (char *)in_part->ch_bufref.br_buf->b_ffname);
!       if (options->jo_set & JO_IN_TOP)
!       {
!           if (options->jo_in_top == 0 && !(options->jo_set & JO_IN_BOT))
!           {
!               // Special mode: send last-but-one line when appending a line
!               // to the buffer.
!               in_part->ch_bufref.br_buf->b_write_to_channel = TRUE;
!               in_part->ch_buf_append = TRUE;
!               in_part->ch_buf_top =
!                           in_part->ch_bufref.br_buf->b_ml.ml_line_count + 1;
!           }
!           else
!               in_part->ch_buf_top = options->jo_in_top;
        }
        else
!           in_part->ch_buf_top = 1;
!       if (options->jo_set & JO_IN_BOT)
!           in_part->ch_buf_bot = options->jo_in_bot;
!       else
!           in_part->ch_buf_bot = in_part->ch_bufref.br_buf->b_ml.ml_line_count;
      }
  }
  
  /*
--- 1559,1592 ----
  
      channel_set_options(channel, options);
  
!     if (job->jv_in_buf == NULL)
!       return;
  
!     chanpart_T *in_part = &channel->ch_part[PART_IN];
! 
!     set_bufref(&in_part->ch_bufref, job->jv_in_buf);
!     ch_log(channel, "reading from buffer '%s'",
!           (char *)in_part->ch_bufref.br_buf->b_ffname);
!     if (options->jo_set & JO_IN_TOP)
!     {
!       if (options->jo_in_top == 0 && !(options->jo_set & JO_IN_BOT))
!       {
!           // Special mode: send last-but-one line when appending a line
!           // to the buffer.
!           in_part->ch_bufref.br_buf->b_write_to_channel = TRUE;
!           in_part->ch_buf_append = TRUE;
!           in_part->ch_buf_top =
!               in_part->ch_bufref.br_buf->b_ml.ml_line_count + 1;
        }
        else
!           in_part->ch_buf_top = options->jo_in_top;
      }
+     else
+       in_part->ch_buf_top = 1;
+     if (options->jo_set & JO_IN_BOT)
+       in_part->ch_buf_bot = options->jo_in_bot;
+     else
+       in_part->ch_buf_bot = in_part->ch_bufref.br_buf->b_ml.ml_line_count;
  }
  
  /*
***************
*** 1599,1616 ****
      cbq_T *head = &channel->ch_part[part].ch_cb_head;
      cbq_T *item = ALLOC_ONE(cbq_T);
  
!     if (item != NULL)
!     {
!       copy_callback(&item->cq_callback, callback);
!       item->cq_seq_nr = id;
!       item->cq_prev = head->cq_prev;
!       head->cq_prev = item;
!       item->cq_next = NULL;
!       if (item->cq_prev == NULL)
!           head->cq_next = item;
!       else
!           item->cq_prev->cq_next = item;
!     }
  }
  
      static void
--- 1602,1619 ----
      cbq_T *head = &channel->ch_part[part].ch_cb_head;
      cbq_T *item = ALLOC_ONE(cbq_T);
  
!     if (item == NULL)
!       return;
! 
!     copy_callback(&item->cq_callback, callback);
!     item->cq_seq_nr = id;
!     item->cq_prev = head->cq_prev;
!     head->cq_prev = item;
!     item->cq_next = NULL;
!     if (item->cq_prev == NULL)
!       head->cq_next = item;
!     else
!       item->cq_prev->cq_next = item;
  }
  
      static void
***************
*** 2636,2677 ****
  
      newitem = ALLOC_ONE(jsonq_T);
      if (newitem == NULL)
        clear_tv(rettv);
      else
      {
!       newitem->jq_value = alloc_tv();
!       if (newitem->jq_value == NULL)
!       {
!           vim_free(newitem);
!           clear_tv(rettv);
!       }
        else
!       {
!           newitem->jq_no_callback = FALSE;
!           *newitem->jq_value = *rettv;
!           if (item == NULL)
!           {
!               // append to the end
!               newitem->jq_prev = head->jq_prev;
!               head->jq_prev = newitem;
!               newitem->jq_next = NULL;
!               if (newitem->jq_prev == NULL)
!                   head->jq_next = newitem;
!               else
!                   newitem->jq_prev->jq_next = newitem;
!           }
!           else
!           {
!               // append after "item"
!               newitem->jq_prev = item;
!               newitem->jq_next = item->jq_next;
!               item->jq_next = newitem;
!               if (newitem->jq_next == NULL)
!                   head->jq_prev = newitem;
!               else
!                   newitem->jq_next->jq_prev = newitem;
!           }
!       }
      }
  }
  
--- 2639,2680 ----
  
      newitem = ALLOC_ONE(jsonq_T);
      if (newitem == NULL)
+     {
+       clear_tv(rettv);
+       return;
+     }
+ 
+     newitem->jq_value = alloc_tv();
+     if (newitem->jq_value == NULL)
+     {
+       vim_free(newitem);
        clear_tv(rettv);
+       return;
+     }
+ 
+     newitem->jq_no_callback = FALSE;
+     *newitem->jq_value = *rettv;
+     if (item == NULL)
+     {
+       // append to the end
+       newitem->jq_prev = head->jq_prev;
+       head->jq_prev = newitem;
+       newitem->jq_next = NULL;
+       if (newitem->jq_prev == NULL)
+           head->jq_next = newitem;
+       else
+           newitem->jq_prev->jq_next = newitem;
+     }
      else
      {
!       // append after "item"
!       newitem->jq_prev = item;
!       newitem->jq_next = item->jq_next;
!       item->jq_next = newitem;
!       if (newitem->jq_next == NULL)
!           head->jq_prev = newitem;
        else
!           newitem->jq_next->jq_prev = newitem;
      }
  }
  
***************
*** 4184,4239 ****
      if (opt.jo_set & JO_PART)
        part = opt.jo_part;
      channel = get_channel_arg(&argvars[0], TRUE, TRUE, part);
!     if (channel != NULL)
!     {
!       if (part == PART_COUNT)
!           part = channel_part_read(channel);
!       mode = channel_get_mode(channel, part);
!       timeout = channel_get_timeout(channel, part);
!       if (opt.jo_set & JO_TIMEOUT)
!           timeout = opt.jo_timeout;
! 
!       if (blob)
!       {
!           int     outlen = 0;
!           char_u  *p = channel_read_block(channel, part,
!                                                      timeout, TRUE, &outlen);
!           if (p != NULL)
!           {
!               blob_T  *b = blob_alloc();
  
!               if (b != NULL)
                {
!                   b->bv_ga.ga_len = outlen;
!                   if (ga_grow(&b->bv_ga, outlen) == FAIL)
!                       blob_free(b);
!                   else
!                   {
!                       memcpy(b->bv_ga.ga_data, p, outlen);
!                       rettv_blob_set(rettv, b);
!                   }
                }
-               vim_free(p);
            }
        }
-       else if (raw || mode == CH_MODE_RAW || mode == CH_MODE_NL)
-           rettv->vval.v_string = channel_read_block(channel, part,
-                                                        timeout, raw, NULL);
        else
        {
!           if (opt.jo_set & JO_ID)
!               id = opt.jo_id;
!           channel_read_json_block(channel, part, timeout, id, &listtv);
!           if (listtv != NULL)
!           {
!               *rettv = *listtv;
!               vim_free(listtv);
!           }
!           else
!           {
!               rettv->v_type = VAR_SPECIAL;
!               rettv->vval.v_number = VVAL_NONE;
!           }
        }
      }
  
--- 4187,4242 ----
      if (opt.jo_set & JO_PART)
        part = opt.jo_part;
      channel = get_channel_arg(&argvars[0], TRUE, TRUE, part);
!     if (channel == NULL)
!       goto theend;
  
!     if (part == PART_COUNT)
!       part = channel_part_read(channel);
!     mode = channel_get_mode(channel, part);
!     timeout = channel_get_timeout(channel, part);
!     if (opt.jo_set & JO_TIMEOUT)
!       timeout = opt.jo_timeout;
! 
!     if (blob)
!     {
!       int         outlen = 0;
!       char_u  *p = channel_read_block(channel, part,
!               timeout, TRUE, &outlen);
!       if (p != NULL)
!       {
!           blob_T      *b = blob_alloc();
! 
!           if (b != NULL)
!           {
!               b->bv_ga.ga_len = outlen;
!               if (ga_grow(&b->bv_ga, outlen) == FAIL)
!                   blob_free(b);
!               else
                {
!                   memcpy(b->bv_ga.ga_data, p, outlen);
!                   rettv_blob_set(rettv, b);
                }
            }
+           vim_free(p);
+       }
+     }
+     else if (raw || mode == CH_MODE_RAW || mode == CH_MODE_NL)
+       rettv->vval.v_string = channel_read_block(channel, part,
+               timeout, raw, NULL);
+     else
+     {
+       if (opt.jo_set & JO_ID)
+           id = opt.jo_id;
+       channel_read_json_block(channel, part, timeout, id, &listtv);
+       if (listtv != NULL)
+       {
+           *rettv = *listtv;
+           vim_free(listtv);
        }
        else
        {
!           rettv->v_type = VAR_SPECIAL;
!           rettv->vval.v_number = VVAL_NONE;
        }
      }
  
***************
*** 4263,4278 ****
        for (part = PART_SOCK; part < PART_IN; ++part)
        {
            fd = channel->ch_part[part].ch_fd;
!           if (fd != INVALID_FD)
!           {
!               int r = channel_wait(channel, fd, 0);
  
!               if (r == CW_READY)
!                   channel_read(channel, part, "channel_handle_events");
!               else if (r == CW_ERROR)
!                   ch_close_part_on_error(channel, part, TRUE,
!                                                    "channel_handle_events");
!           }
        }
  
  # ifdef __HAIKU__
--- 4266,4281 ----
        for (part = PART_SOCK; part < PART_IN; ++part)
        {
            fd = channel->ch_part[part].ch_fd;
!           if (fd == INVALID_FD)
!               continue;
  
!           int r = channel_wait(channel, fd, 0);
! 
!           if (r == CW_READY)
!               channel_read(channel, part, "channel_handle_events");
!           else if (r == CW_ERROR)
!               ch_close_part_on_error(channel, part, TRUE,
!                       "channel_handle_events");
        }
  
  # ifdef __HAIKU__
***************
*** 4318,4334 ****
      chanpart_T *ch_part = &channel->ch_part[part];
      int               fd = ch_part->ch_fd;
  
!     if (fd != INVALID_FD)
!     {
  #ifdef MSWIN
!       u_long  val = 1;
  
!       ioctlsocket(fd, FIONBIO, &val);
  #else
!       (void)fcntl(fd, F_SETFL, O_NONBLOCK);
  #endif
!       ch_part->ch_nonblocking = TRUE;
!     }
  }
  
  /*
--- 4321,4337 ----
      chanpart_T *ch_part = &channel->ch_part[part];
      int               fd = ch_part->ch_fd;
  
!     if (fd == INVALID_FD)
!       return;
! 
  #ifdef MSWIN
!     u_long    val = 1;
  
!     ioctlsocket(fd, FIONBIO, &val);
  #else
!     (void)fcntl(fd, F_SETFL, O_NONBLOCK);
  #endif
!     ch_part->ch_nonblocking = TRUE;
  }
  
  /*
***************
*** 5218,5224 ****
      void
  f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
  {
!     channel_T *channel;
  
      rettv->vval.v_number = -1;
  
--- 5221,5227 ----
      void
  f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
  {
!     channel_T *channel;
  
      rettv->vval.v_number = -1;
  
***************
*** 5228,5250 ****
        return;
  
      channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
!     if (channel != NULL)
!     {
!       char_u  *what = tv_get_string(&argvars[1]);
!       int     part;
  
!       if (STRCMP(what, "err") == 0)
!           part = PART_ERR;
!       else if (STRCMP(what, "out") == 0)
!           part = PART_OUT;
!       else if (STRCMP(what, "in") == 0)
!           part = PART_IN;
!       else
!           part = PART_SOCK;
!       if (channel->ch_part[part].ch_bufref.br_buf != NULL)
!           rettv->vval.v_number =
!                             channel->ch_part[part].ch_bufref.br_buf->b_fnum;
!     }
  }
  
  /*
--- 5231,5252 ----
        return;
  
      channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
!     if (channel == NULL)
!       return;
  
!     char_u    *what = tv_get_string(&argvars[1]);
!     int               part;
!     if (STRCMP(what, "err") == 0)
!       part = PART_ERR;
!     else if (STRCMP(what, "out") == 0)
!       part = PART_OUT;
!     else if (STRCMP(what, "in") == 0)
!       part = PART_IN;
!     else
!       part = PART_SOCK;
!     if (channel->ch_part[part].ch_bufref.br_buf != NULL)
!       rettv->vval.v_number =
!           channel->ch_part[part].ch_bufref.br_buf->b_fnum;
  }
  
  /*
***************
*** 5259,5271 ****
        return;
  
      channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
!     if (channel != NULL)
!     {
!       rettv->v_type = VAR_JOB;
!       rettv->vval.v_job = channel->ch_job;
!       if (channel->ch_job != NULL)
!           ++channel->ch_job->jv_refcount;
!     }
  }
  
  /*
--- 5261,5273 ----
        return;
  
      channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
!     if (channel == NULL)
!       return;
! 
!     rettv->v_type = VAR_JOB;
!     rettv->vval.v_job = channel->ch_job;
!     if (channel->ch_job != NULL)
!       ++channel->ch_job->jv_refcount;
  }
  
  /*
*** ../vim-9.0.0776/src/version.c       2022-10-16 20:24:13.135972079 +0100
--- src/version.c       2022-10-16 21:32:03.582317762 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     777,
  /**/

-- 
How do you know when you have run out of invisible ink?

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20221016205305.70E9F1C1EFF%40moolenaar.net.

Raspunde prin e-mail lui