Patch 8.2.3919

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3919
Problem:Vim9: wrong argument for append() results in two errors.
Solution:   Check did_emsg.  Also for setline().  Adjust the help for
appendbufline().
Files:  runtime/doc/builtin.txt, src/evalbuffer.c, src/typval.c,
src/testdir/test_vim9_builtin.vim


*** ../vim-8.2.3918/runtime/doc/builtin.txt 2021-12-27 21:26:38.964743253 
+
--- runtime/doc/builtin.txt 2021-12-28 11:07:57.630282485 +
***
*** 806,814 
  
For the use of {buf}, see |bufname()|.
  
!   {lnum} is used like with |append()|.  Note that using |line()|
!   would use the current buffer, not the one appending to.
!   Use "$" to append at the end of the buffer.
  
On success 0 is returned, on failure 1 is returned.
In |Vim9| script an error is given for an invalid {lnum}.
--- 806,815 
  
For the use of {buf}, see |bufname()|.
  
!   {lnum} is the line number to append below.  Note that using
!   |line()| would use the current buffer, not the one appending
!   to.  Use "$" to append at the end of the buffer.  Other string
!   values are not supported.
  
On success 0 is returned, on failure 1 is returned.
In |Vim9| script an error is given for an invalid {lnum}.
*** ../vim-8.2.3918/src/evalbuffer.c2021-12-27 20:57:03.483387913 +
--- src/evalbuffer.c2021-12-28 11:22:06.265309712 +
***
*** 274,285 
  f_append(typval_T *argvars, typval_T *rettv)
  {
  linenr_T  lnum;
  
  if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL)
return;
  
  lnum = tv_get_lnum(&argvars[0]);
! set_buffer_lines(curbuf, lnum, TRUE, &argvars[1], rettv);
  }
  
  /*
--- 274,287 
  f_append(typval_T *argvars, typval_T *rettv)
  {
  linenr_T  lnum;
+ int   did_emsg_before = did_emsg;
  
  if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL)
return;
  
  lnum = tv_get_lnum(&argvars[0]);
! if (did_emsg == did_emsg_before)
!   set_buffer_lines(curbuf, lnum, TRUE, &argvars[1], rettv);
  }
  
  /*
***
*** 290,295 
--- 292,298 
  {
  linenr_T  lnum;
  buf_T *buf;
+ int   did_emsg_before = did_emsg;
  
  if (in_vim9script()
&& (check_for_buffer_arg(argvars, 0) == FAIL
***
*** 303,309 
  else
  {
lnum = tv_get_lnum_buf(&argvars[1], buf);
!   set_buffer_lines(buf, lnum, append, &argvars[2], rettv);
  }
  }
  
--- 306,313 
  else
  {
lnum = tv_get_lnum_buf(&argvars[1], buf);
!   if (did_emsg == did_emsg_before)
!   set_buffer_lines(buf, lnum, append, &argvars[2], rettv);
  }
  }
  
***
*** 502,507 
--- 506,514 
  win_T *curwin_save = NULL;
  tabpage_T *tp;
  win_T *wp;
+ int   did_emsg_before = did_emsg;
+ 
+ rettv->vval.v_number = 1; // FAIL by default
  
  if (in_vim9script()
&& (check_for_buffer_arg(argvars, 0) == FAIL
***
*** 511,523 
  
  buf = tv_get_buf(&argvars[0], FALSE);
  if (buf == NULL)
- {
-   rettv->vval.v_number = 1; // FAIL
return;
- }
  is_curbuf = buf == curbuf;
  
  first = tv_get_lnum_buf(&argvars[1], buf);
  if (argvars[2].v_type != VAR_UNKNOWN)
last = tv_get_lnum_buf(&argvars[2], buf);
  else
--- 518,529 
  
  buf = tv_get_buf(&argvars[0], FALSE);
  if (buf == NULL)
return;
  is_curbuf = buf == curbuf;
  
  first = tv_get_lnum_buf(&argvars[1], buf);
+ if (did_emsg > did_emsg_before)
+   return;
  if (argvars[2].v_type != VAR_UNKNOWN)
last = tv_get_lnum_buf(&argvars[2], buf);
  else
***
*** 525,534 
  
  if (buf->b_ml.ml_mfp == NULL || first < 1
   || first > buf->b_ml.ml_line_count || last < first)
- {
-   rettv->vval.v_number = 1;   // FAIL
return;
- }
  
  if (!is_curbuf)
  {
--- 531,537 
***
*** 577,582 
--- 580,586 
curbuf = curbuf_save;
curwin = curwin_save;
  }
+ rettv->vval.v_number = 0; // OK
  }
  
  /*
***
*** 780,785 
--- 784,790 
  linenr_T  lnum = 1;
  linenr_T  end = 1;
  buf_T *buf;
+ int   did_emsg_before = did_emsg;
  
  if (in_vim9script()
&& (check_for_buffer_arg(argvars, 0) == FAIL
***
*** 791,796 
--- 796,803 
  if (buf != NULL)
  {
lnum = tv_get_lnum_buf(&argvars[1], buf);
+   if (did_emsg > did_emsg_before)
+   return;
if (argvars[2].v_type == VAR_UNKNOWN)
end = lnum;
else
***
*** 852,863 
  f_setline(typval_T *argvars, typval_T *rettv)
  {
  linenr_T 

Patch 8.2.3920

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3920
Problem:Restoring directory after using another window is inefficient.
Solution:   Only restore the directory for win_execute().  Apply 'autochdir'
only when needed.
Files:  src/evalwindow.c, src/testdir/test_autochdir.vim


*** ../vim-8.2.3919/src/evalwindow.c2021-12-20 21:35:55.314175835 +
--- src/evalwindow.c2021-12-28 13:13:08.477118501 +
***
*** 707,712 
--- 707,727 
  if (wp != NULL && tp != NULL)
  {
pos_T   curpos = wp->w_cursor;
+   char_u  cwd[MAXPATHL];
+   int cwd_status;
+   char_u  autocwd[MAXPATHL];
+   int apply_acd = FALSE;
+ 
+   cwd_status = mch_dirname(cwd, MAXPATHL);
+ 
+   // If 'acd' is set, check we are using that directory.  If yes, then
+   // apply 'acd' afterwards, otherwise restore the current directory.
+   if (cwd_status == OK && p_acd)
+   {
+   do_autochdir();
+   apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
+ && STRCMP(cwd, autocwd) == 0;
+   }
  
if (switch_win_noblock(&save_curwin, &save_curtab, wp, tp, TRUE) == OK)
{
***
*** 714,719 
--- 729,738 
execute_common(argvars, rettv, 1);
}
restore_win_noblock(save_curwin, save_curtab, TRUE);
+   if (apply_acd)
+   do_autochdir();
+   else if (cwd_status == OK)
+   mch_chdir((char *)cwd);
  
// Update the status line if the cursor moved.
if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
***
*** 1316,1324 
// to the first valid window.
win_goto(firstwin);
  # endif
- 
- // If called by win_execute() and executing the command changed the
- // directory, it now has to be restored.
- fix_current_dir();
  }
  #endif
--- 1335,1339 
*** ../vim-8.2.3919/src/testdir/test_autochdir.vim  2021-12-05 
13:39:57.624815980 +
--- src/testdir/test_autochdir.vim  2021-12-28 12:17:38.450766408 +
***
*** 51,56 
--- 51,76 
endtry
  endfunc
  
+ func Test_acd_win_execute()
+   let cwd = getcwd()
+   set acd
+   call test_autochdir()
+ 
+   call mkdir('Xfile')
+   let winid = win_getid()
+   new Xfile/file
+   call assert_match('testdir.Xfile$', getcwd())
+   cd ..
+   call assert_match('testdir$', getcwd())
+   call win_execute(winid, 'echo')
+   call assert_match('testdir$', getcwd())
+ 
+   bwipe!
+   set noacd
+   call chdir(cwd)
+   call delete('Xfile', 'rf')
+ endfunc
+ 
  func Test_verbose_pwd()
let cwd = getcwd()
call test_autochdir()
*** ../vim-8.2.3919/src/version.c   2021-12-28 11:24:44.636994380 +
--- src/version.c   2021-12-28 12:50:41.287915926 +
***
*** 751,752 
--- 751,754 
  {   /* Add new patch number below this line */
+ /**/
+ 3920,
  /**/

-- 
The difference between theory and practice, is that in theory, there
is no difference between theory and practice.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228131600.E8A271C0641%40moolenaar.net.


Patch 8.2.3921

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3921
Problem:The way xdiff is used is inefficient.
Solution:   Use hunk_func instead of the out_line callback. (Lewis Russell,
closes #9344)
Files:  src/diff.c


*** ../vim-8.2.3920/src/diff.c  2021-12-27 17:21:38.004449137 +
--- src/diff.c  2021-12-28 13:50:11.975517843 +
***
*** 64,69 
--- 64,77 
  garray_T  dout_ga;  // used for internal diff
  } diffout_T;
  
+ // used for recording hunks from xdiff
+ typedef struct {
+ linenr_T lnum_orig;
+ long count_orig;
+ linenr_T lnum_new;
+ long count_new;
+ } diffhunk_T;
+ 
  // two diff inputs and one result
  typedef struct {
  diffin_T  dio_orig; // original file input
***
*** 84,95 
  #ifdef FEAT_FOLDING
  static void diff_fold_update(diff_T *dp, int skip_idx);
  #endif
! static void diff_read(int idx_orig, int idx_new, diffout_T *fname);
  static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig, int 
idx_new);
  static diff_T *diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp);
! static int parse_diff_ed(char_u *line, linenr_T *lnum_orig, long *count_orig, 
linenr_T *lnum_new, long *count_new);
! static int parse_diff_unified(char_u *line, linenr_T *lnum_orig, long 
*count_orig, linenr_T *lnum_new, long *count_new);
! static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf);
  
  #define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \
  for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next)
--- 92,103 
  #ifdef FEAT_FOLDING
  static void diff_fold_update(diff_T *dp, int skip_idx);
  #endif
! static void diff_read(int idx_orig, int idx_new, diffio_T *dio);
  static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig, int 
idx_new);
  static diff_T *diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp);
! static int parse_diff_ed(char_u *line, diffhunk_T *hunk);
! static int parse_diff_unified(char_u *line, diffhunk_T *hunk);
! static int xdiff_out(long start_a, long count_a, long start_b, long count_b, 
void *priv);
  
  #define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \
  for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next)
***
*** 880,886 
continue;
  
// Read the diff output and add each entry to the diff list.
!   diff_read(idx_orig, idx_new, &dio->dio_diff);
  
clear_diffin(&dio->dio_new);
clear_diffout(&dio->dio_diff);
--- 888,894 
continue;
  
// Read the diff output and add each entry to the diff list.
!   diff_read(idx_orig, idx_new, dio);
  
clear_diffin(&dio->dio_new);
clear_diffout(&dio->dio_diff);
***
*** 1118,1124 
  
  emit_cfg.ctxlen = 0; // don't need any diff_context here
  emit_cb.priv = &diffio->dio_diff;
! emit_cb.out_line = xdiff_out;
  if (xdl_diff(&diffio->dio_orig.din_mmfile,
&diffio->dio_new.din_mmfile,
¶m, &emit_cfg, &emit_cb) < 0)
--- 1126,1132 
  
  emit_cfg.ctxlen = 0; // don't need any diff_context here
  emit_cb.priv = &diffio->dio_diff;
! emit_cfg.hunk_func = xdiff_out;
  if (xdl_diff(&diffio->dio_orig.din_mmfile,
&diffio->dio_new.din_mmfile,
¶m, &emit_cfg, &emit_cb) < 0)
***
*** 1482,1490 
  wp->w_p_crb = TRUE;
  if (!(diff_flags & DIFF_FOLLOWWRAP))
  {
! if (!wp->w_p_diff)
wp->w_p_wrap_save = wp->w_p_wrap;
! wp->w_p_wrap = FALSE;
  }
  # ifdef FEAT_FOLDING
  if (!wp->w_p_diff)
--- 1490,1498 
  wp->w_p_crb = TRUE;
  if (!(diff_flags & DIFF_FOLLOWWRAP))
  {
!   if (!wp->w_p_diff)
wp->w_p_wrap_save = wp->w_p_wrap;
!   wp->w_p_wrap = FALSE;
  }
  # ifdef FEAT_FOLDING
  if (!wp->w_p_diff)
***
*** 1549,1555 
if (!(diff_flags & DIFF_FOLLOWWRAP))
{
if (!wp->w_p_wrap)
!   wp->w_p_wrap = wp->w_p_wrap_save;
}
  #ifdef FEAT_FOLDING
free_string_option(wp->w_p_fdm);
--- 1557,1563 
if (!(diff_flags & DIFF_FOLLOWWRAP))
{
if (!wp->w_p_wrap)
!   wp->w_p_wrap = wp->w_p_wrap_save;
}
  #ifdef FEAT_FOLDING
free_string_option(wp->w_p_fdm);
***
*** 1607,1626 
  diff_read(
  int   idx_orig,   // idx of original file
  int   idx_new,// idx of new file
! diffout_T *dout)  // diff output
  {
  FILE  *fd = NULL;
  int   line_idx = 0;
  diff_T*dprev = NULL;
  diff_T*dp = curtab->tp_first_diff;
  diff_T*dn, *dpl;
  char_ulinebuf[LBUFLEN];   // only need to hold the diff line
  char_u*line;
  long  off;
  int   i;
- linenr_T  lnum_orig, lnum_new;
- long  count_orig, count_new;

Patch 8.2.3922

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3922
Problem:Cannot build with dynamic Ruby 3.1.
Solution:   Add "_EXTRA" variables for CI.  Add missing functions. (Ozaki
Kiichi, closes #9420)
Files:  ci/config.mk.clang-12.sed, ci/config.mk.clang.sed,
ci/config.mk.sed, src/Makefile, src/auto/configure,
src/config.mk.in, src/configure.ac, src/if_ruby.c, src/vim.h


*** ../vim-8.2.3921/ci/config.mk.clang-12.sed   2021-12-09 21:07:07.600331923 
+
--- ci/config.mk.clang-12.sed   2021-12-28 15:35:13.752748640 +
***
*** 1,3 
  # Clang 12 (or Apple clang 13) and later makes a warning 
'-Wcompound-token-split-by-macro' enable by default.
! /^PERL_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=compound-token-split-by-macro/
! /^RUBY_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=compound-token-split-by-macro/
--- 1,3 
  # Clang 12 (or Apple clang 13) and later makes a warning 
'-Wcompound-token-split-by-macro' enable by default.
! /^PERL_CFLAGS_EXTRA[[:blank:]]*=/s/$/ 
-Wno-error=compound-token-split-by-macro/
! /^RUBY_CFLAGS_EXTRA[[:blank:]]*=/s/$/ 
-Wno-error=compound-token-split-by-macro/
*** ../vim-8.2.3921/ci/config.mk.clang.sed  2020-12-28 20:36:52.504817434 
+
--- ci/config.mk.clang.sed  2021-12-28 15:35:13.752748640 +
***
*** 1,2 
  /^CFLAGS[[:blank:]]*=/s/$/ -Wno-error=missing-field-initializers/
! /^RUBY_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=unknown-attributes 
-Wno-error=ignored-attributes/
--- 1,2 
  /^CFLAGS[[:blank:]]*=/s/$/ -Wno-error=missing-field-initializers/
! /^RUBY_CFLAGS_EXTRA[[:blank:]]*=/s/$/ -Wno-error=unknown-attributes 
-Wno-error=ignored-attributes/
*** ../vim-8.2.3921/ci/config.mk.sed2020-05-26 19:09:06.910102525 +0100
--- ci/config.mk.sed2021-12-28 15:35:13.752748640 +
***
*** 1,2 
  /^CFLAGS[[:blank:]]*=/s/$/ -Wall -Wextra -Wshadow -Werror/
! /^PERL_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=unused-function/
--- 1,3 
  /^CFLAGS[[:blank:]]*=/s/$/ -Wall -Wextra -Wshadow -Werror/
! /^PERL_CFLAGS_EXTRA[[:blank:]]*=/s/$/ -Wno-error=unused-function/
! /^RUBY_CFLAGS_EXTRA[[:blank:]]*=/s/$/ -Wno-error=unused-parameter/
*** ../vim-8.2.3921/src/Makefile2021-12-20 22:12:49.330012136 +
--- src/Makefile2021-12-28 15:35:13.756748633 +
***
*** 1491,1503 
  
  ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) 
$(LEAK_CFLAGS) $(ABORT_CFLAGS) $(POST_DEFS)
  
  # Exclude $CFLAGS for osdef.sh, for Mac 10.4 some flags don't work together
  # with "-E".
  OSDEF_CFLAGS = $(PRE_DEFS) $(POST_DEFS)
  
! LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) \
! $(RUBY_CFLAGS) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) \
! $(PYTHON3_CFLAGS) $(TCL_CFLAGS) $(VTERM_CFLAGS) \
  -Dinline= -D__extension__= -Dalloca=alloca
  
  LINT_EXTRA = -D"__attribute__(x)="
--- 1491,1504 
  
  ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) 
$(LEAK_CFLAGS) $(ABORT_CFLAGS) $(POST_DEFS)
  
+ ALL_IF_CFLAGS = $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) 
$(PYTHON3_CFLAGS) $(RUBY_CFLAGS) $(TCL_CFLAGS)
+ ALL_IF_CFLAGS_EXTRA = $(LUA_CFLAGS_EXTRA) $(PERL_CFLAGS_EXTRA) 
$(PYTHON_CFLAGS_EXTRA) $(PYTHON3_CFLAGS_EXTRA) $(RUBY_CFLAGS_EXTRA) 
$(TCL_CFLAGS_EXTRA)
+ 
  # Exclude $CFLAGS for osdef.sh, for Mac 10.4 some flags don't work together
  # with "-E".
  OSDEF_CFLAGS = $(PRE_DEFS) $(POST_DEFS)
  
! LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) $(ALL_IF_CFLAGS) 
$(VTERM_CFLAGS) \
  -Dinline= -D__extension__= -Dalloca=alloca
  
  LINT_EXTRA = -D"__attribute__(x)="
***
*** 3357,3363 
$(CCC) -o $@ if_xcmdsrv.c
  
  objects/if_lua.o: if_lua.c
!   $(CCC_NF) $(LUA_CFLAGS) $(ALL_CFLAGS) -o $@ if_lua.c
  
  objects/if_mzsch.o: if_mzsch.c $(MZSCHEME_EXTRA)
$(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c
--- 3358,3364 
$(CCC) -o $@ if_xcmdsrv.c
  
  objects/if_lua.o: if_lua.c
!   $(CCC_NF) $(LUA_CFLAGS) $(ALL_CFLAGS) $(LUA_CFLAGS_EXTRA) -o $@ if_lua.c
  
  objects/if_mzsch.o: if_mzsch.c $(MZSCHEME_EXTRA)
$(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c
***
*** 3366,3387 
$(MZSCHEME_MZC) --c-mods mzscheme_base.c ++lib scheme/base
  
  objects/if_perl.o: auto/if_perl.c
!   $(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) -o $@ auto/if_perl.c
  
  objects/if_perlsfio.o: if_perlsfio.c
!   $(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) -o $@ if_perlsfio.c
  
  objects/if_python.o: if_python.c if_py_both.h
!   $(CCC_NF) $(PYTHON_CFLAGS) $(PYTHON_CFLAGS_EXTRA) $(ALL_CFLAGS) -o $@ 
if_python.c
  
  objects/if_python3.o: if_python3.c if_py_both.h
!   $(CCC_NF) $(PYTHON3_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) $(ALL_CFLAGS) -o $@ 
if_python3.c
  
  objects/if_ruby.o: if_ruby.c
!   $(CCC_NF) $(RUBY_CFLAGS) $(ALL_CFLAGS) -o $@ if_ruby.c
  
  objects/if_tcl.o: if_tcl.c
!   $(CCC_NF) $(TCL_CFLAGS) $(ALL_CFLAGS) -o $@ if_tcl.c
  
  objects/indent.o: indent.c
$(CCC

Patch 8.2.3923

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3923
Problem:Vim9: double free if a nested function has a line break in the
argument list.
Solution:   Set cmdlinep when freeing the previous line.
Files:  src/userfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.3922/src/userfunc.c  2021-12-27 17:21:38.024449102 +
--- src/userfunc.c  2021-12-28 17:18:47.491285907 +
***
*** 219,224 
--- 219,226 
if (theline == NULL)
break;
vim_free(*line_to_free);
+   if (*eap->cmdlinep == *line_to_free)
+   *eap->cmdlinep = theline;
*line_to_free = theline;
whitep = (char_u *)" ";
p = skipwhite(theline);
*** ../vim-8.2.3922/src/testdir/test_vim9_func.vim  2021-12-26 
14:22:55.665931067 +
--- src/testdir/test_vim9_func.vim  2021-12-28 17:17:17.567445742 +
***
*** 1669,1675 
assert_fails('FuncWithForwardCall()', 'E1096:', '', 1, 
'FuncWithForwardCall')
  enddef
  
! def Test_nested_functin_with_nextcmd()
var lines =<< trim END
vim9script
# Define an outer function
--- 1669,1675 
assert_fails('FuncWithForwardCall()', 'E1096:', '', 1, 
'FuncWithForwardCall')
  enddef
  
! def Test_nested_function_with_nextcmd()
var lines =<< trim END
vim9script
# Define an outer function
***
*** 1689,1694 
--- 1689,1712 
CheckScriptFailure(lines, 'E476: Invalid command: A')
  enddef
  
+ def Test_nested_function_with_args_split()
+   var lines =<< trim END
+   vim9script
+   def FirstFunction()
+ def SecondFunction(
+ )
+ # had a double free if the right parenthesis of the nested function is
+ # on the next line
+  
+ enddef|
+   enddef
+   # Compile all functions
+   defcompile
+   END
+   # FIXME: this should fail on the 
+   CheckScriptSuccess(lines)
+ enddef
+ 
  def Test_return_type_wrong()
CheckScriptFailure([
  'def Func(): number',
*** ../vim-8.2.3922/src/version.c   2021-12-28 15:51:40.079738196 +
--- src/version.c   2021-12-28 17:15:16.239664174 +
***
*** 751,752 
--- 751,754 
  {   /* Add new patch number below this line */
+ /**/
+ 3923,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
129. You cancel your newspaper subscription.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228172354.26A181C0641%40moolenaar.net.


Patch 8.2.3924

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3924
Problem:Vim9: no error if something follows :enddef in a nested function.
Solution:   Give an error.  Move common code to a function.
Files:  src/userfunc.c, src/vim9compile.c, src/errors.h,
src/testdir/test_vim9_func.vim


*** ../vim-8.2.3923/src/userfunc.c  2021-12-28 17:23:08.910865519 +
--- src/userfunc.c  2021-12-28 17:52:16.864088239 +
***
*** 166,171 
--- 166,200 
  }
  
  /*
+  * Handle line continuation in function arguments or body.
+  * Get a next line, store it in "eap" if appropriate and use "line_to_free" to
+  * handle freeing the line later.
+  */
+ static char_u *
+ get_function_line(
+   exarg_T *eap,
+   char_u  **line_to_free,
+   getline_opt_T   getline_options,
+   int indent)
+ {
+ char_u *theline;
+ 
+ if (eap->getline == NULL)
+   theline = getcmdline(':', 0L, indent, getline_options);
+ else
+   theline = eap->getline(':', eap->cookie, indent, getline_options);
+ if (theline != NULL)
+ {
+   if (*eap->cmdlinep == *line_to_free)
+   *eap->cmdlinep = theline;
+   vim_free(*line_to_free);
+   *line_to_free = theline;
+ }
+ 
+ return theline;
+ }
+ 
+ /*
   * Get function arguments.
   * "argp" should point to just after the "(", possibly to white space.
   * "argp" is advanced just after "endchar".
***
*** 212,227 
while (eap != NULL && eap->getline != NULL
 && (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#')))
{
-   char_u *theline;
- 
// End of the line, get the next one.
!   theline = eap->getline(':', eap->cookie, 0, TRUE);
if (theline == NULL)
break;
-   vim_free(*line_to_free);
-   if (*eap->cmdlinep == *line_to_free)
-   *eap->cmdlinep = theline;
-   *line_to_free = theline;
whitep = (char_u *)" ";
p = skipwhite(theline);
}
--- 241,251 
while (eap != NULL && eap->getline != NULL
 && (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#')))
{
// End of the line, get the next one.
!   char_u *theline = get_function_line(eap, line_to_free, 0, TRUE);
! 
if (theline == NULL)
break;
whitep = (char_u *)" ";
p = skipwhite(theline);
}
***
*** 720,734 
}
else
{
!   if (eap->getline == NULL)
!   theline = getcmdline(':', 0L, indent, getline_options);
!   else
!   theline = eap->getline(':', eap->cookie, indent,
  getline_options);
-   if (*eap->cmdlinep == *line_to_free)
-   *eap->cmdlinep = theline;
-   vim_free(*line_to_free);
-   *line_to_free = theline;
}
if (KeyTyped)
lines_left = Rows - 1;
--- 744,751 
}
else
{
!   theline = get_function_line(eap, line_to_free, indent,
  getline_options);
}
if (KeyTyped)
lines_left = Rows - 1;
***
*** 827,833 
SOURCING_LNUM = sourcing_lnum_top
+ newlines->ga_len + 1;
if (eap->cmdidx == CMD_def)
!   semsg(_(e_text_found_after_enddef_str), p);
else
give_warning2((char_u *)
   _("W22: Text found after :endfunction: %s"),
--- 844,850 
SOURCING_LNUM = sourcing_lnum_top
+ newlines->ga_len + 1;
if (eap->cmdidx == CMD_def)
!   semsg(_(e_text_found_after_str_str), "enddef", p);
else
give_warning2((char_u *)
   _("W22: Text found after :endfunction: %s"),
*** ../vim-8.2.3923/src/vim9compile.c   2021-12-26 14:22:55.661931074 +
--- src/vim9compile.c   2021-12-28 17:50:05.036303865 +
***
*** 879,890 
  }
  
  ufunc = define_function(eap, lambda_name, line_to_free);
- 
  if (ufunc == NULL)
  {
r = eap->skip ? OK : FAIL;
goto theend;
  }
  
  // copy over the block scope IDs before compiling
  if (!is_global && cctx->ctx_ufunc->uf_block_depth > 0)
--- 879,896 
  }
  
  ufunc = define_function(eap, lambda_name, line_to_free);
  if (ufunc == NULL)
  {
r = eap->skip ? OK : FAIL;
goto theend;
  }
+ if (eap->nextcmd != NULL)
+ {
+   semsg(_(e_text_found_after_str_str),
+ eap->cmdidx == CMD_def ? "enddef" : "endfunc

Patch 8.2.3925

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3925
Problem:Diff mode confused by NUL bytes.
Solution:   Handle NUL bytes differently. (Christian Brabandt, closes #9421,
closes #9418)
Files:  src/diff.c, src/testdir/test_diffmode.vim,
src/testdir/dumps/Test_diff_bin_01.dump,
src/testdir/dumps/Test_diff_bin_02.dump,
src/testdir/dumps/Test_diff_bin_03.dump,
src/testdir/dumps/Test_diff_bin_04.dump


*** ../vim-8.2.3924/src/diff.c  2021-12-28 13:54:37.475164202 +
--- src/diff.c  2021-12-28 18:21:20.790091624 +
***
*** 777,785 
int orig_len;
char_u  cbuf[MB_MAXBYTES + 1];
  
!   // xdiff doesn't support ignoring case, fold-case the text.
!   c = PTR2CHAR(s);
!   c = MB_CASEFOLD(c);
orig_len = mb_ptr2len(s);
if (mb_char2bytes(c, cbuf) != orig_len)
// TODO: handle byte length difference
--- 777,790 
int orig_len;
char_u  cbuf[MB_MAXBYTES + 1];
  
!   if (*s == NL)
!   c = NUL;
!   else
!   {
!   // xdiff doesn't support ignoring case, fold-case the text.
!   c = PTR2CHAR(s);
!   c = MB_CASEFOLD(c);
!   }
orig_len = mb_ptr2len(s);
if (mb_char2bytes(c, cbuf) != orig_len)
// TODO: handle byte length difference
***
*** 791,797 
len += orig_len;
}
else
!   ptr[len++] = *s++;
}
ptr[len++] = NL;
  }
--- 796,805 
len += orig_len;
}
else
!   {
!   ptr[len++] = *s == NL ? NUL : *s;
!   s++;
!   }
}
ptr[len++] = NL;
  }
*** ../vim-8.2.3924/src/testdir/test_diffmode.vim   2021-12-26 
10:51:33.711079465 +
--- src/testdir/test_diffmode.vim   2021-12-28 18:21:20.794091619 +
***
*** 1417,1420 
--- 1417,1457 
%bw!
  endfunc
  
+ func Test_diff_binary()
+   CheckScreendump
+ 
+   let content =<< trim END
+ call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g'])
+ vnew
+ call setline(1, ['A', 'b', 'c', 'd', 'E', 'f', 'g'])
+ windo diffthis
+ wincmd p
+ norm! gg0
+ redraw!
+   END
+   call writefile(content, 'Xtest_diff_bin')
+   let buf = RunVimInTerminal('-S Xtest_diff_bin', {})
+ 
+   " Test using internal diff
+   call VerifyScreenDump(buf, 'Test_diff_bin_01', {})
+ 
+   " Test using internal diff and case folding
+   call term_sendkeys(buf, ":set diffopt+=icase\")
+   call term_sendkeys(buf, "\")
+   call VerifyScreenDump(buf, 'Test_diff_bin_02', {})
+   " Test using external diff
+   call term_sendkeys(buf, ":set diffopt=filler\")
+   call term_sendkeys(buf, "\")
+   call VerifyScreenDump(buf, 'Test_diff_bin_03', {})
+   " Test using external diff and case folding
+   call term_sendkeys(buf, ":set diffopt=filler,icase\")
+   call term_sendkeys(buf, "\")
+   call VerifyScreenDump(buf, 'Test_diff_bin_04', {})
+ 
+   " clean up
+   call StopVimInTerminal(buf)
+   call delete('Xtest_diff_bin')
+   set diffopt&vim
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.3924/src/testdir/dumps/Test_diff_bin_01.dump 2021-12-28 
18:29:01.405425388 +
--- src/testdir/dumps/Test_diff_bin_01.dump 2021-12-28 18:21:20.794091619 
+
***
*** 0 
--- 1,20 
+ | +0#e05#a8a8a8255@1>A+2#000#ff404010| +0&#ffd7ff255@33||+1&#ff0| 
+0#e05#a8a8a8255@1|a+2#000#ff404010| +0&#ffd7ff255@33
+ | +0#e05#a8a8a8255@1|b+0#000#ff0| @33||+1&&| 
+0#e05#a8a8a8255@1|b+0#000#ff0| @33
+ | +0#e05#a8a8a8255@1|c+0#000#ffd7ff255| @33||+1&#ff0| 
+0#e05#a8a8a8255@1|c+0#000#ffd7ff255|^+2#e05#ff404010|@| 
+0#000#ffd7ff255@31
+ | +0#e05#a8a8a8255@1|d+0#000#ff0| @33||+1&&| 
+0#e05#a8a8a8255@1|d+0#000#ff0| @33
+ | +0#e05#a8a8a8255@1|E+2#000#ff404010| +0&#ffd7ff255@33||+1&#ff0| 
+0#e05#a8a8a8255@1|e+2#000#ff404010| +0&#ffd7ff255@33
+ | +0#e05#a8a8a8255@1|f+0#000#ff0| @33||+1&&| 
+0#e05#a8a8a8255@1|f+0#000#ff0| @33
+ | +0#e05#a8a8a8255@1|g+0#000#ff0| @33||+1&&| 
+0#e05#a8a8a8255@1|g+0#000#ff0| @33
+ |~+0#4040ff13&| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |~| @35||+1#000&|~+0#4040ff13&| @35
+ |[+3#000&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1| |[+1&&|N|o| 
|N|a|m|e|]|

Re: Patch 8.2.3920

2021-12-28 Thread John Marriott


On 29-Dec-2021 00:16, Bram Moolenaar wrote:

Patch 8.2.3920
Problem:Restoring directory after using another window is inefficient.
Solution:   Only restore the directory for win_execute().  Apply 'autochdir'
 only when needed.
Files:  src/evalwindow.c, src/testdir/test_autochdir.vim



After this patch, mingw64 (gcc 11.2.0) spits out this error message if 
FEAT_AUTOCHDIR is not defined (which is only defined if 
FEAT_NETBEANS_INTG or FEAT_BIG are defined):


gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD evalwindow.c -o 
gobjnative/evalwindow.o

evalwindow.c: In function 'f_win_execute':
evalwindow.c:719:33: error: 'p_acd' undeclared (first use in this function)
  719 | if (cwd_status == OK && p_acd)
  | ^
evalwindow.c:719:33: note: each undeclared identifier is reported only 
once for each function it appears in

make: *** [Make_cyg_ming.mak:1162: gobjnative/evalwindow.o] Error 1


The attached patch makes the error go away but I'm not sure that it is 
correct.


Cheers
John

--
--
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/d5abd208-c29c-5912-bed1-6f47b4d7f651%40internode.on.net.
--- evalwindow.c.orig   2021-12-29 06:15:24.855364100 +1100
+++ evalwindow.c2021-12-29 06:38:46.01094 +1100
@@ -707,6 +707,7 @@
 if (wp != NULL && tp != NULL)
 {
pos_T   curpos = wp->w_cursor;
+#ifdef FEAT_AUTOCHDIR
char_u  cwd[MAXPATHL];
int cwd_status;
char_u  autocwd[MAXPATHL];
@@ -722,6 +723,7 @@
apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
  && STRCMP(cwd, autocwd) == 0;
}
+#endif
 
if (switch_win_noblock(&save_curwin, &save_curtab, wp, tp, TRUE) == OK)
{
@@ -729,10 +731,12 @@
execute_common(argvars, rettv, 1);
}
restore_win_noblock(save_curwin, save_curtab, TRUE);
+#ifdef FEAT_AUTOCHDIR
if (apply_acd)
do_autochdir();
else if (cwd_status == OK)
mch_chdir((char *)cwd);
+#endif
 
// Update the status line if the cursor moved.
if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))


Re: Patch 8.2.3920

2021-12-28 Thread Bram Moolenaar


John Marriott wrote:

> On 29-Dec-2021 00:16, Bram Moolenaar wrote:
> > Patch 8.2.3920
> > Problem:Restoring directory after using another window is inefficient.
> > Solution:   Only restore the directory for win_execute().  Apply 'autochdir'
> >  only when needed.
> > Files:  src/evalwindow.c, src/testdir/test_autochdir.vim
> >
> >
> >
> After this patch, mingw64 (gcc 11.2.0) spits out this error message if 
> FEAT_AUTOCHDIR is not defined (which is only defined if 
> FEAT_NETBEANS_INTG or FEAT_BIG are defined):
> 
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
> -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
> -fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD evalwindow.c -o 
> gobjnative/evalwindow.o
> evalwindow.c: In function 'f_win_execute':
> evalwindow.c:719:33: error: 'p_acd' undeclared (first use in this function)
>    719 | if (cwd_status == OK && p_acd)
>    | ^
> evalwindow.c:719:33: note: each undeclared identifier is reported only 
> once for each function it appears in
> make: *** [Make_cyg_ming.mak:1162: gobjnative/evalwindow.o] Error 1
> 
> 
> The attached patch makes the error go away but I'm not sure that it is 
> correct.

Not quite, the directory still needs to be restored.  But I can see
where the problem is.

-- 
All true wisdom is found on T-shirts.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228200415.A65081C0641%40moolenaar.net.


Patch 8.2.3926

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3926 (after 8.2.3920)
Problem:Build failure without the 'autochdir' option. (John Marriott)
Solution:   Add #ifdefs.
Files:  src/evalwindow.c


*** ../vim-8.2.3925/src/evalwindow.c2021-12-28 13:15:02.444896152 +
--- src/evalwindow.c2021-12-28 20:00:48.357090501 +
***
*** 709,719 
--- 709,722 
pos_T   curpos = wp->w_cursor;
char_u  cwd[MAXPATHL];
int cwd_status;
+ #ifdef FEAT_AUTOCHDIR
char_u  autocwd[MAXPATHL];
int apply_acd = FALSE;
+ #endif
  
cwd_status = mch_dirname(cwd, MAXPATHL);
  
+ #ifdef FEAT_AUTOCHDIR
// If 'acd' is set, check we are using that directory.  If yes, then
// apply 'acd' afterwards, otherwise restore the current directory.
if (cwd_status == OK && p_acd)
***
*** 722,727 
--- 725,731 
apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
  && STRCMP(cwd, autocwd) == 0;
}
+ #endif
  
if (switch_win_noblock(&save_curwin, &save_curtab, wp, tp, TRUE) == OK)
{
***
*** 729,737 
execute_common(argvars, rettv, 1);
}
restore_win_noblock(save_curwin, save_curtab, TRUE);
if (apply_acd)
do_autochdir();
!   else if (cwd_status == OK)
mch_chdir((char *)cwd);
  
// Update the status line if the cursor moved.
--- 733,744 
execute_common(argvars, rettv, 1);
}
restore_win_noblock(save_curwin, save_curtab, TRUE);
+ #ifdef FEAT_AUTOCHDIR
if (apply_acd)
do_autochdir();
!   else
! #endif
!   if (cwd_status == OK)
mch_chdir((char *)cwd);
  
// Update the status line if the cursor moved.
*** ../vim-8.2.3925/src/version.c   2021-12-28 18:29:28.637385570 +
--- src/version.c   2021-12-28 20:03:16.580836053 +
***
*** 751,752 
--- 751,754 
  {   /* Add new patch number below this line */
+ /**/
+ 3926,
  /**/

-- 
Why is it called "Windows"?  "Gates" would be more appropriate...

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228200415.A9B4B1C0642%40moolenaar.net.


Patch 8.2.3927

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3927
Problem:Vim9: double free when using lambda.
Solution:   Don't free both cmdline and line_to_free.
Files:  src/userfunc.c


*** ../vim-8.2.3926/src/userfunc.c  2021-12-28 17:55:22.963786520 +
--- src/userfunc.c  2021-12-28 20:13:32.463720698 +
***
*** 1146,1152 
  ga_init2(&newlines, (int)sizeof(char_u *), 10);
  if (get_function_body(&eap, &newlines, NULL, &line_to_free) == FAIL)
  {
!   vim_free(cmdline);
goto erret;
  }
  
--- 1146,1153 
  ga_init2(&newlines, (int)sizeof(char_u *), 10);
  if (get_function_body(&eap, &newlines, NULL, &line_to_free) == FAIL)
  {
!   if (cmdline != line_to_free)
!   vim_free(cmdline);
goto erret;
  }
  
*** ../vim-8.2.3926/src/version.c   2021-12-28 20:03:38.980797969 +
--- src/version.c   2021-12-28 20:18:34.763023710 +
***
*** 751,752 
--- 751,754 
  {   /* Add new patch number below this line */
+ /**/
+ 3927,
  /**/

-- 
In a world without fences, who needs Gates and Windows?

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228201915.AF6BB1C0641%40moolenaar.net.


Patch 8.2.3928

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3928
Problem:Heredoc test fails.
Solution:   Correct order of function arguments.
Files:  src/userfunc.c


*** ../vim-8.2.3927/src/userfunc.c  2021-12-28 20:18:46.958997532 +
--- src/userfunc.c  2021-12-28 20:45:05.964072236 +
***
*** 174,181 
  get_function_line(
exarg_T *eap,
char_u  **line_to_free,
!   getline_opt_T   getline_options,
!   int indent)
  {
  char_u *theline;
  
--- 174,181 
  get_function_line(
exarg_T *eap,
char_u  **line_to_free,
!   int indent,
!   getline_opt_T   getline_options)
  {
  char_u *theline;
  
***
*** 242,248 
 && (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#')))
{
// End of the line, get the next one.
!   char_u *theline = get_function_line(eap, line_to_free, 0, TRUE);
  
if (theline == NULL)
break;
--- 242,249 
 && (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#')))
{
// End of the line, get the next one.
!   char_u *theline = get_function_line(eap, line_to_free, 0,
! GETLINE_CONCAT_CONT);
  
if (theline == NULL)
break;
*** ../vim-8.2.3927/src/version.c   2021-12-28 20:18:46.958997532 +
--- src/version.c   2021-12-28 20:43:51.884201467 +
***
*** 751,752 
--- 751,754 
  {   /* Add new patch number below this line */
+ /**/
+ 3928,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
133. You communicate with people on other continents more than you
 do with your own neighbors.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228205020.D69451C0641%40moolenaar.net.


Patch 8.2.3929

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3929
Problem:Using unititialized variable.
Solution:   Set the option flags to zero for a terminal option.
Files:  src/option.c


*** ../vim-8.2.3928/src/option.c2021-12-27 17:21:38.012449123 +
--- src/option.c2021-12-28 20:34:53.529150795 +
***
*** 3962,3967 
--- 3962,3970 
char_u key_name[2];
char_u *p;
  
+   if (flagsp != NULL)
+   *flagsp = 0;  // terminal option has no flags
+ 
// check for a terminal option
if (key < 0)
{
*** ../vim-8.2.3928/src/version.c   2021-12-28 20:49:52.828138913 +
--- src/version.c   2021-12-28 20:53:10.272146976 +
***
*** 751,752 
--- 751,754 
  {   /* Add new patch number below this line */
+ /**/
+ 3929,
  /**/

-- 
There are three kinds of persons: Those who can count and those who can't.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228205356.08D511C0641%40moolenaar.net.


Patch 8.2.3930

2021-12-28 Thread Bram Moolenaar


Patch 8.2.3930
Problem:getcmdline() argument has a misleading type.
Solution:   Use the correct type, even though the value is not used.
Files:  src/ex_getln.c, src/proto/ex_getln.pro, src/ex_docmd.c,
src/normal.c, src/register.c, src/userfunc.c


*** ../vim-8.2.3929/src/ex_getln.c  2021-12-09 10:50:48.562865618 +
--- src/ex_getln.c  2021-12-28 20:57:11.052047954 +
***
*** 1554,1563 
   */
  char_u *
  getcmdline(
! int   firstc,
! long  count,  // only used for incremental search
! int   indent, // indent for inside conditionals
! int   do_concat UNUSED)
  {
  return getcmdline_int(firstc, count, indent, TRUE);
  }
--- 1554,1563 
   */
  char_u *
  getcmdline(
! int firstc,
! longcount,// only used for incremental search
! int indent,   // indent for inside conditionals
! getline_opt_T do_concat UNUSED)
  {
  return getcmdline_int(firstc, count, indent, TRUE);
  }
*** ../vim-8.2.3929/src/proto/ex_getln.pro  2021-11-20 19:13:35.945146370 
+
--- src/proto/ex_getln.pro  2021-12-28 20:59:03.131973603 +
***
*** 1,6 
  /* ex_getln.c */
  void cmdline_init(void);
! char_u *getcmdline(int firstc, long count, int indent, int do_concat);
  char_u *getcmdline_prompt(int firstc, char_u *prompt, int attr, int 
xp_context, char_u *xp_arg);
  int check_opt_wim(void);
  int text_and_win_locked(void);
--- 1,6 
  /* ex_getln.c */
  void cmdline_init(void);
! char_u *getcmdline(int firstc, long count, int indent, getline_opt_T 
do_concat);
  char_u *getcmdline_prompt(int firstc, char_u *prompt, int attr, int 
xp_context, char_u *xp_arg);
  int check_opt_wim(void);
  int text_and_win_locked(void);
*** ../vim-8.2.3929/src/ex_docmd.c  2021-12-27 17:21:38.004449137 +
--- src/ex_docmd.c  2021-12-28 20:58:11.79482 +
***
*** 1467,1473 
  
// First time inside the ":while"/":for": get line normally.
if (cp->getline == NULL)
!   line = getcmdline(c, 0L, indent, options);
else
line = cp->getline(c, cp->cookie, indent, options);
if (line != NULL && store_loop_line(cp->lines_gap, line) == OK)
--- 1467,1473 
  
// First time inside the ":while"/":for": get line normally.
if (cp->getline == NULL)
!   line = getcmdline(c, 0L, indent, 0);
else
line = cp->getline(c, cp->cookie, indent, options);
if (line != NULL && store_loop_line(cp->lines_gap, line) == OK)
*** ../vim-8.2.3929/src/normal.c2021-12-26 15:00:00.499078785 +
--- src/normal.c2021-12-28 20:56:06.880083593 +
***
*** 4388,4394 
  
  // When using 'incsearch' the cursor may be moved to set a different 
search
  // start position.
! cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, TRUE);
  
  if (cap->searchbuf == NULL)
  {
--- 4388,4394 
  
  // When using 'incsearch' the cursor may be moved to set a different 
search
  // start position.
! cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, 0);
  
  if (cap->searchbuf == NULL)
  {
*** ../vim-8.2.3929/src/register.c  2021-12-05 22:19:22.836153466 +
--- src/register.c  2021-12-28 20:56:25.164074008 +
***
*** 97,103 
  {
  char_u*new_line;
  
! new_line = getcmdline('=', 0L, 0, TRUE);
  if (new_line == NULL)
return NUL;
  if (*new_line == NUL) // use previous line
--- 97,103 
  {
  char_u*new_line;
  
! new_line = getcmdline('=', 0L, 0, 0);
  if (new_line == NULL)
return NUL;
  if (*new_line == NUL) // use previous line
*** ../vim-8.2.3929/src/userfunc.c  2021-12-28 20:49:52.824138911 +
--- src/userfunc.c  2021-12-28 20:57:45.264026765 +
***
*** 180,186 
  char_u *theline;
  
  if (eap->getline == NULL)
!   theline = getcmdline(':', 0L, indent, getline_options);
  else
theline = eap->getline(':', eap->cookie, indent, getline_options);
  if (theline != NULL)
--- 180,186 
  char_u *theline;
  
  if (eap->getline == NULL)
!   theline = getcmdline(':', 0L, indent, 0);
  else
theline = eap->getline(':', eap->cookie, indent, getline_options);
  if (theline != NULL)
*** ../vim-8.2.3929/src/version.c   2021-12-28 20:53:27.208143390 +
--- src/version.c   2021-12-28 20:59:20.291961018 +
***
*** 751,752 
--- 751,754 
  {   /* Add new patch number below this line */
+ /**/
+ 3930,
  /**/

-- 
Never eat yellow snow.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///  \\\
\\\sponsor Vim, vote for features -- http://www.Vim.org/sponso

Unexpected results from applying gqj to C line comment

2021-12-28 Thread Gary Johnson
The formatting command gqj exhibits unexpected behavior when
executed on a C line comment after a statement.  The reformatting is
applied only to the first line of the comment and not to the
following line.

Formatting of C line comments after statements was added with Patch
8.2.3787.  It generally works very well.  I've recently observed the
behavior described here.  It seems like a bug.

Steps to reproduce

 1. Start vim as:

$ vim -N -u NONE -i NONE -c 'set cin tw=40'

The 'tw' setting is just for convenience.

 2. Enter these lines into the buffer:

#if 0   // This is a long end of
// line comment that
// wraps.

 3. Replace the "a" with "another":

#if 0   // This is another long end of
// line comment that
// wraps.

 4. With the cursor still on the first line, attempt to reformat the
first two lines with

gqj

The comment now appears like this:

#if 0   // This is another long
// end of
// line comment that
// wraps.

and the cursor is at the start of the third line.

Expected behavior

I expected the comment to appear like this:

#if 0   // This is another long
// end of line comment
// that
// wraps.

That is, with the first two lines of the comment formatted
together and a third line created for what was the last word of
the second line.  That is the result obtained when "#if 0" is
not present.

Operating system

Ubuntu 20.03.3 LTS
Xterm 370

Version of Vim

8.2.3930

Regards,
Gary

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211229001543.GA9765%40phoenix.