Patch 8.2.5131
Problem:    Timeout implementation is not optimal.
Solution:   Further improvements for timeouts.  Add a test for searchpair()
            timeout. (partly by Paul Ollis)
Files:      src/configure.ac, src/auto/configure,
            src/testdir/test_hlsearch.vim, src/testdir/test_search.vim


*** ../vim-8.2.5130/src/configure.ac    2022-06-05 22:05:15.596289407 +0100
--- src/configure.ac    2022-06-19 16:26:19.759598047 +0100
***************
*** 80,86 ****
  AC_MSG_CHECKING(--enable-fail-if-missing argument)
  AC_ARG_ENABLE(fail_if_missing,
        [  --enable-fail-if-missing    Fail if dependencies on additional 
features
!      specified on the command line are missing.], 
        [fail_if_missing="yes"],
        [fail_if_missing="no"])
  AC_MSG_RESULT($fail_if_missing)
--- 80,86 ----
  AC_MSG_CHECKING(--enable-fail-if-missing argument)
  AC_ARG_ENABLE(fail_if_missing,
        [  --enable-fail-if-missing    Fail if dependencies on additional 
features
!      specified on the command line are missing.],
        [fail_if_missing="yes"],
        [fail_if_missing="no"])
  AC_MSG_RESULT($fail_if_missing)
***************
*** 237,243 ****
    AC_ARG_WITH(developer-dir, [  --with-developer-dir=PATH    use PATH as 
location for Xcode developer tools],
        DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
          AC_MSG_RESULT(not present))
!   
    if test "x$DEVELOPER_DIR" = "x"; then
      AC_PATH_PROG(XCODE_SELECT, xcode-select)
      if test "x$XCODE_SELECT" != "x"; then
--- 237,243 ----
    AC_ARG_WITH(developer-dir, [  --with-developer-dir=PATH    use PATH as 
location for Xcode developer tools],
        DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
          AC_MSG_RESULT(not present))
! 
    if test "x$DEVELOPER_DIR" = "x"; then
      AC_PATH_PROG(XCODE_SELECT, xcode-select)
      if test "x$XCODE_SELECT" != "x"; then
***************
*** 287,292 ****
--- 287,294 ----
      MACOS_X_DARWIN=yes
      OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
      OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
+     dnl os_macosx.m implements timer_create() and friends
+     AC_DEFINE(HAVE_TIMER_CREATE)
      dnl TODO: use -arch i386 on Intel machines
      dnl Removed -no-cpp-precomp, only for very old compilers.
      CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
***************
*** 1499,1534 ****
         if ${vi_cv_path_python3} -c \
             "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
         then
!          vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \    
             "import sys; print(sys.abiflags)"`
         fi ])
!   
        dnl -- find where python3 thinks it was installed
        AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
        [ vi_cv_path_python3_pfx=`
         ${vi_cv_path_python3} -c \
         "import sys; print(sys.prefix)"` ])
!   
        dnl -- and where it thinks it runs
        AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
        [ vi_cv_path_python3_epfx=`
         ${vi_cv_path_python3} -c \
         "import sys; print(sys.exec_prefix)"` ])
!   
        dnl -- python3's internal library path
!   
        AC_CACHE_VAL(vi_cv_path_python3path,
        [ vi_cv_path_python3path=`
         unset PYTHONPATH;
         ${vi_cv_path_python3} -c \
         "import sys, string; print(':'.join(sys.path))"` ])
!   
        dnl -- where the Python implementation library archives are
!   
        AC_ARG_WITH(python3-config-dir,
         [  --with-python3-config-dir=PATH  Python's config directory 
(deprecated)],
         [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
!   
        AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
        [
         vi_cv_path_python3_conf=
--- 1501,1536 ----
         if ${vi_cv_path_python3} -c \
             "import sys; sys.exit(${vi_cv_var_python3_version} < 3.2)"
         then
!          vi_cv_var_python3_abiflags=`${vi_cv_path_python3} -c \
             "import sys; print(sys.abiflags)"`
         fi ])
! 
        dnl -- find where python3 thinks it was installed
        AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
        [ vi_cv_path_python3_pfx=`
         ${vi_cv_path_python3} -c \
         "import sys; print(sys.prefix)"` ])
! 
        dnl -- and where it thinks it runs
        AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
        [ vi_cv_path_python3_epfx=`
         ${vi_cv_path_python3} -c \
         "import sys; print(sys.exec_prefix)"` ])
! 
        dnl -- python3's internal library path
! 
        AC_CACHE_VAL(vi_cv_path_python3path,
        [ vi_cv_path_python3path=`
         unset PYTHONPATH;
         ${vi_cv_path_python3} -c \
         "import sys, string; print(':'.join(sys.path))"` ])
! 
        dnl -- where the Python implementation library archives are
! 
        AC_ARG_WITH(python3-config-dir,
         [  --with-python3-config-dir=PATH  Python's config directory 
(deprecated)],
         [ vi_cv_path_python3_conf="${withval}"; have_python3_config_dir=1 ] )
! 
        AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
        [
         vi_cv_path_python3_conf=
***************
*** 1550,1562 ****
           done
         fi
        ])
!   
        PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
!   
        if test "X$PYTHON3_CONFDIR" = "X"; then
          AC_MSG_RESULT([can't find it!])
        else
!   
          dnl -- we need to examine Python's config/Makefile too
          dnl    see what the interpreter is built from
          AC_CACHE_VAL(vi_cv_path_python3_plibs,
--- 1552,1564 ----
           done
         fi
        ])
! 
        PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
! 
        if test "X$PYTHON3_CONFDIR" = "X"; then
          AC_MSG_RESULT([can't find it!])
        else
! 
          dnl -- we need to examine Python's config/Makefile too
          dnl    see what the interpreter is built from
          AC_CACHE_VAL(vi_cv_path_python3_plibs,
***************
*** 1601,1607 ****
        fi
          PYTHON3_SRC="if_python3.c"
          PYTHON3_OBJ="objects/if_python3.o"
!   
          dnl On FreeBSD linking with "-pthread" is required to use threads.
          dnl _THREAD_SAFE must be used for compiling then.
          dnl The "-pthread" is added to $LIBS, so that the following check for
--- 1603,1609 ----
        fi
          PYTHON3_SRC="if_python3.c"
          PYTHON3_OBJ="objects/if_python3.o"
! 
          dnl On FreeBSD linking with "-pthread" is required to use threads.
          dnl _THREAD_SAFE must be used for compiling then.
          dnl The "-pthread" is added to $LIBS, so that the following check for
***************
*** 1636,1642 ****
          else
            AC_MSG_RESULT(no)
          fi
!   
          dnl check that compiling a simple program still works with the flags
          dnl added for Python.
          AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
--- 1638,1644 ----
          else
            AC_MSG_RESULT(no)
          fi
! 
          dnl check that compiling a simple program still works with the flags
          dnl added for Python.
          AC_MSG_CHECKING([if compile and link flags for Python 3 are sane])
***************
*** 1675,1681 ****
  AC_SUBST(PYTHON3_OBJ)
  
  dnl if python2.x and python3.x are enabled one can only link in code
! dnl with dlopen(), dlsym(), dlclose() 
  if test "$python_ok" = yes && test "$python3_ok" = yes; then
    AC_DEFINE(DYNAMIC_PYTHON)
    AC_DEFINE(DYNAMIC_PYTHON3)
--- 1677,1683 ----
  AC_SUBST(PYTHON3_OBJ)
  
  dnl if python2.x and python3.x are enabled one can only link in code
! dnl with dlopen(), dlsym(), dlclose()
  if test "$python_ok" = yes && test "$python3_ok" = yes; then
    AC_DEFINE(DYNAMIC_PYTHON)
    AC_DEFINE(DYNAMIC_PYTHON3)
***************
*** 3113,3119 ****
        AC_CHECK_HEADERS(Xm/Xm.h)
    else
        AC_CHECK_HEADERS(Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h 
Xm/Manager.h Xm/UnhighlightT.h Xm/Notebook.h)
!   fi    
  
    if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
      dnl Solaris uses XpmAttributes_21, very annoying.
--- 3115,3121 ----
        AC_CHECK_HEADERS(Xm/Xm.h)
    else
        AC_CHECK_HEADERS(Xm/Xm.h Xm/XpmP.h Xm/JoinSideT.h Xm/TraitP.h 
Xm/Manager.h Xm/UnhighlightT.h Xm/Notebook.h)
!   fi
  
    if test "x$ac_cv_header_Xm_XpmP_h" = "xyes"; then
      dnl Solaris uses XpmAttributes_21, very annoying.
***************
*** 3809,3815 ****
  AC_LINK_IFELSE([AC_LANG_PROGRAM([
  #include<signal.h>
  #include<time.h>
! static void set_flag(union sigval) {}
  ], [
    struct timespec ts;
    struct sigevent action = {0};
--- 3811,3817 ----
  AC_LINK_IFELSE([AC_LANG_PROGRAM([
  #include<signal.h>
  #include<time.h>
! static void set_flag(union sigval sv) {}
  ], [
    struct timespec ts;
    struct sigevent action = {0};
***************
*** 3824,3830 ****
    AC_LINK_IFELSE([AC_LANG_PROGRAM([
  #include<signal.h>
  #include<time.h>
! static void set_flag(union sigval) {}
      ], [
      struct timespec ts;
      struct sigevent action = {0};
--- 3826,3832 ----
    AC_LINK_IFELSE([AC_LANG_PROGRAM([
  #include<signal.h>
  #include<time.h>
! static void set_flag(union sigval sv) {}
      ], [
      struct timespec ts;
      struct sigevent action = {0};
***************
*** 3885,3891 ****
    AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
    [Define if struct stat contains a nanoseconds field])
  fi
!   
  dnl Link with iconv for charset translation, if not found without library.
  dnl check for iconv() requires including iconv.h
  dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
--- 3887,3893 ----
    AC_DEFINE_UNQUOTED([ST_MTIM_NSEC], [$ac_cv_struct_st_mtim_nsec],
    [Define if struct stat contains a nanoseconds field])
  fi
! 
  dnl Link with iconv for charset translation, if not found without library.
  dnl check for iconv() requires including iconv.h
  dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it
*** ../vim-8.2.5130/src/auto/configure  2022-06-05 22:05:15.600289401 +0100
--- src/auto/configure  2022-06-19 16:26:26.115617024 +0100
***************
*** 4769,4774 ****
--- 4769,4776 ----
      MACOS_X_DARWIN=yes
      OS_EXTRA_SRC="os_macosx.m os_mac_conv.c";
      OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
+         $as_echo "#define HAVE_TIMER_CREATE 1" >>confdefs.h
+ 
              CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN"
  
                 if test -z "$with_x" -a "X$enable_gui" != Xmotif -a 
"X$enable_gui" != Xgtk2 -a "X$enable_gui" != Xgtk3; then
***************
*** 13044,13050 ****
  
  #include<signal.h>
  #include<time.h>
! static void set_flag(union sigval) {}
  
  int
  main ()
--- 13046,13052 ----
  
  #include<signal.h>
  #include<time.h>
! static void set_flag(union sigval sv) {}
  
  int
  main ()
***************
*** 13073,13079 ****
  
  #include<signal.h>
  #include<time.h>
! static void set_flag(union sigval) {}
  
  int
  main ()
--- 13075,13081 ----
  
  #include<signal.h>
  #include<time.h>
! static void set_flag(union sigval sv) {}
  
  int
  main ()
*** ../vim-8.2.5130/src/testdir/test_hlsearch.vim       2022-06-19 
11:45:42.654832438 +0100
--- src/testdir/test_hlsearch.vim       2022-06-19 16:16:11.232487602 +0100
***************
*** 37,43 ****
  func Test_hlsearch_hangs()
    CheckFunction reltimefloat
  
!   " So, it turns out the Windows 7 implements TimerQueue timers differently
    " and they can expire *before* the requested time has elapsed. So allow for
    " the timeout occurring after 80 ms (5 * 16 (the typical clock tick)).
    if has("win32")
--- 37,43 ----
  func Test_hlsearch_hangs()
    CheckFunction reltimefloat
  
!   " So, it turns out that Windows 7 implements TimerQueue timers differently
    " and they can expire *before* the requested time has elapsed. So allow for
    " the timeout occurring after 80 ms (5 * 16 (the typical clock tick)).
    if has("win32")
*** ../vim-8.2.5130/src/testdir/test_search.vim 2022-06-17 15:17:06.308400366 
+0100
--- src/testdir/test_search.vim 2022-06-19 16:49:57.164410597 +0100
***************
*** 355,360 ****
--- 355,391 ----
    bwipe!
  endfunc
  
+ func SearchpairSkip()
+   let id = synID(line('.'), col('.'), 0)
+   let attr = synIDattr(id, 'name')
+   return attr !~ 'comment'
+ endfunc
+ 
+ func Test_searchpair_timeout_with_skip()
+   let g:test_is_flaky = 1
+ 
+   edit ../evalfunc.c
+   if has('win32')
+     " Windows timeouts are rather coarse grained, about 16ms.
+     let ms = 20
+     let min_time = 0.016
+     let max_time = min_time * 10.0
+   else
+     let ms = 1
+     let min_time = 0.001
+     let max_time = min_time * 10.0
+     if GetVimCommand() =~ 'valgrind.*--log-file='
+       let max_time += 0.04  " this can be slow with valgrind
+     endif
+   endif
+   let start = reltime()
+   let found = searchpair('(', '', ')', 'crnm', 'SearchpairSkip()', 0, ms)
+   let elapsed = reltimefloat(reltime(start))
+   call assert_inrange(min_time, max_time, elapsed)
+ 
+   bwipe!
+ endfunc
+ 
  func Test_searchpairpos()
    new
    call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])
*** ../vim-8.2.5130/src/version.c       2022-06-19 15:22:32.094517237 +0100
--- src/version.c       2022-06-19 17:05:08.617161527 +0100
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     5131,
  /**/

-- 
DENNIS: You can't expect to wield supreme executive power just 'cause some
        watery tart threw a sword at you!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/20220619160617.E497C1C075E%40moolenaar.net.

Raspunde prin e-mail lui