Patch 9.0.1598

2023-06-01 Fir de Conversatie Bram Moolenaar


Patch 9.0.1598
Problem:screenchar(), screenchars() and screenstring() do not work
properly when 'encoding' is set to a double-byte encoding.
Solution:   Fix the way the bytes of the characters are obtained.
(issue #12469)
Files:  src/evalfunc.c, src/screen.c, src/testdir/test_functions.vim,
src/testdir/test_utf8.vim


*** ../vim-9.0.1597/src/evalfunc.c  2023-05-11 15:02:52.231456894 +0100
--- src/evalfunc.c  2023-06-01 20:21:12.233128848 +0100
***
*** 8934,8940 
  {
  int   row;
  int   col;
- int   off;
  int   c;
  
  if (in_vim9script()
--- 8934,8939 
***
*** 8948,8958 
c = -1;
  else
  {
!   off = LineOffset[row] + col;
!   if (enc_utf8 && ScreenLinesUC[off] != 0)
!   c = ScreenLinesUC[off];
!   else
!   c = ScreenLines[off];
  }
  rettv->vval.v_number = c;
  }
--- 8947,8955 
c = -1;
  else
  {
!   char_u buf[MB_MAXBYTES + 1];
!   screen_getbytes(row, col, buf, NULL);
!   c = (*mb_ptr2char)(buf);
  }
  rettv->vval.v_number = c;
  }
***
*** 8965,8971 
  {
  int   row;
  int   col;
- int   off;
  int   c;
  int   i;
  
--- 8962,8967 
***
*** 8982,8999 
  if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns)
return;
  
! off = LineOffset[row] + col;
! if (enc_utf8 && ScreenLinesUC[off] != 0)
!   c = ScreenLinesUC[off];
  else
!   c = ScreenLines[off];
  list_append_number(rettv->vval.v_list, (varnumber_T)c);
  
  if (enc_utf8)
! 
!   for (i = 0; i < Screen_mco && ScreenLinesC[i][off] != 0; ++i)
!   list_append_number(rettv->vval.v_list,
!  (varnumber_T)ScreenLinesC[i][off]);
  }
  
  /*
--- 8978,8995 
  if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns)
return;
  
! char_u buf[MB_MAXBYTES + 1];
! screen_getbytes(row, col, buf, NULL);
! int pcc[MAX_MCO];
! if (enc_utf8)
!   c = utfc_ptr2char(buf, pcc);
  else
!   c = (*mb_ptr2char)(buf);
  list_append_number(rettv->vval.v_list, (varnumber_T)c);
  
  if (enc_utf8)
!   for (i = 0; i < Screen_mco && pcc[i] != 0; ++i)
!   list_append_number(rettv->vval.v_list, (varnumber_T)pcc[i]);
  }
  
  /*
***
*** 9024,9034 
  {
  int   row;
  int   col;
- int   off;
- int   c;
- int   i;
  char_ubuf[MB_MAXBYTES + 1];
- int   buflen = 0;
  
  rettv->vval.v_string = NULL;
  rettv->v_type = VAR_STRING;
--- 9020,9026 
***
*** 9043,9060 
  if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns)
return;
  
! off = LineOffset[row] + col;
! if (enc_utf8 && ScreenLinesUC[off] != 0)
!   c = ScreenLinesUC[off];
! else
!   c = ScreenLines[off];
! buflen += mb_char2bytes(c, buf);
! 
! if (enc_utf8 && ScreenLinesUC[off] != 0)
!   for (i = 0; i < Screen_mco && ScreenLinesC[i][off] != 0; ++i)
!   buflen += mb_char2bytes(ScreenLinesC[i][off], buf + buflen);
! 
! buf[buflen] = NUL;
  rettv->vval.v_string = vim_strsave(buf);
  }
  
--- 9035,9041 
  if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns)
return;
  
! screen_getbytes(row, col, buf, NULL);
  rettv->vval.v_string = vim_strsave(buf);
  }
  
***
*** 9433,9439 
  
  /*
   * Set the cursor or mark position.
!  * If 'charpos' is TRUE, then use the column number as a character offset.
   * Otherwise use the column number as a byte offset.
   */
  static void
--- 9414,9420 
  
  /*
   * Set the cursor or mark position.
!  * If "charpos" is TRUE, then use the column number as a character offset.
   * Otherwise use the column number as a byte offset.
   */
  static void
*** ../vim-9.0.1597/src/screen.c2023-05-20 14:06:56.673542805 +0100
--- src/screen.c2023-06-01 20:26:30.112235831 +0100
***
*** 1199,1206 
  }
  
  /*
!  * Get a single character directly from ScreenLines into "bytes[]".
!  * Also return its attribute in *attrp;
   */
  void
  screen_getbytes(int row, int col, char_u *bytes, int *attrp)
--- 1199,1207 
  }
  
  /*
!  * Get a single character directly from ScreenLines into "bytes", which must
!  * have a size of "MB_MAXBYTES + 1".
!  * If "attrp" is not NULL, return the character's attribute in "*attrp".
   */
  void
  screen_getbytes(int row, int col, char_u *bytes, int *attrp)
***
*** 1212,1218 
return;
  
  off = LineOffset[row] + col;
! *attrp = ScreenAttrs[off];
  bytes[0] = ScreenLines[off];
  bytes[1] = 

Patch 9.0.1597

2023-06-01 Fir de Conversatie Bram Moolenaar


Patch 9.0.1597
Problem:Cursor ends up below the window after a put.
Solution:   Mark w_crow and w_botline invalid when changing the cursor line.
(closes #12465)
Files:  src/eval.c, src/move.c, src/register.c, src/testdir/test_put.vim,
src/testdir/dumps/Test_put_in_last_displayed_line_1.dump


*** ../vim-9.0.1596/src/eval.c  2023-05-19 19:01:13.292413300 +0100
--- src/eval.c  2023-06-01 19:23:13.048692262 +0100
***
*** 6322,6327 
--- 6322,6331 
  
  if (name[0] == 'w' && dollar_lnum)
  {
+   // the "w_valid" flags are not reset when moving the cursor, but they
+   // do matter for update_topline() and validate_botline().
+   check_cursor_moved(curwin);
+ 
pos.col = 0;
if (name[1] == '0') // "w0": first visible line
{
*** ../vim-9.0.1596/src/move.c  2023-05-19 14:04:23.133885852 +0100
--- src/move.c  2023-06-01 19:23:33.008570939 +0100
***
*** 715,733 
  /*
   * Call this function when the length of the cursor line (in screen
   * characters) has changed, and the change is before the cursor.
   * Need to take care of w_botline separately!
   */
  void
  changed_cline_bef_curs(void)
  {
! curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL
|VALID_CHEIGHT|VALID_TOPLINE);
  }
  
  void
  changed_cline_bef_curs_win(win_T *wp)
  {
! wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL
|VALID_CHEIGHT|VALID_TOPLINE);
  }
  
--- 715,735 
  /*
   * Call this function when the length of the cursor line (in screen
   * characters) has changed, and the change is before the cursor.
+  * If the line length changed the number of screen lines might change,
+  * requiring updating w_topline.  That may also invalidate w_crow.
   * Need to take care of w_botline separately!
   */
  void
  changed_cline_bef_curs(void)
  {
! curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW
|VALID_CHEIGHT|VALID_TOPLINE);
  }
  
  void
  changed_cline_bef_curs_win(win_T *wp)
  {
! wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW
|VALID_CHEIGHT|VALID_TOPLINE);
  }
  
*** ../vim-9.0.1596/src/register.c  2023-05-09 17:09:25.657491200 +0100
--- src/register.c  2023-06-01 19:25:30.523904258 +0100
***
*** 2098,2103 
--- 2098,2104 
{
// make sure curwin->w_virtcol is updated
changed_cline_bef_curs();
+   invalidate_botline();
curwin->w_cursor.col += (colnr_T)(totlen - 1);
}
if (VIsual_active)
*** ../vim-9.0.1596/src/testdir/test_put.vim2023-04-22 15:35:08.857815545 
+0100
--- src/testdir/test_put.vim2023-06-01 19:18:06.346953669 +0100
***
*** 262,266 
--- 262,284 
call StopVimInTerminal(buf)
  endfunc
  
+ func Test_put_in_last_displayed_line()
+   CheckRunVimInTerminal
+ 
+   let lines =<< trim END
+   vim9script
+   autocmd CursorMoved * eval line('w$')
+   @a = 'x'->repeat( * 2 - 2)
+   range()->setline(1)
+   feedkeys('G"ap')
+   END
+   call writefile(lines, 'Xtest_put_last_line', 'D')
+   let buf = RunVimInTerminal('-S Xtest_put_last_line', #{rows: 10})
+ 
+   call VerifyScreenDump(buf, 'Test_put_in_last_displayed_line_1', {})
+ 
+   call StopVimInTerminal(buf)
+ endfunc
+ 
  
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.1596/src/testdir/dumps/Test_put_in_last_displayed_line_1.dump
2023-06-01 19:25:52.255789000 +0100
--- src/testdir/dumps/Test_put_in_last_displayed_line_1.dump2023-06-01 
19:18:54.082543033 +0100
***
*** 0 
--- 1,10 
+ 

Re: building vim with clang and python3 support

2023-06-01 Fir de Conversatie N i c o l a s
Yes right. That's the way to go.
Thank you Ken.

Le jeu. 1 juin 2023 à 13:58, Ken Takata  a écrit :

> Hi,
>
> So, you are using the beta version of python 3.12, right?
> Then, if_python3.c should be updated to support python 3.12, I think.
>
> Regards,
> Ken Takata
>
> 2023年6月1日木曜日 2:50:46 UTC+9 N i c o l a s:
>
>> Hi,
>>
>> From vim.9.0.1594 source, I obtain this error trying to build gvim HUGE
>> version under win10 with python3(12) support.
>>
>>
>> c -Wl,-Bdynamic -lgcc_eh -Wl,-Bstatic -lwinpthread -Wl,-Bdynamic -lole32
>> -luuid
>> D:/msys64/mingw64/bin/ld:
>> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa07b): undefined reference to
>> `__imp_PyLong_Type'
>> D:/msys64/mingw64/bin/ld:
>> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa088): undefined reference to
>> `__imp_PyBool_Type'
>> D:/msys64/mingw64/bin/ld:
>> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa644): undefined reference to
>> `__imp_PyLong_Type'
>> D:/msys64/mingw64/bin/ld:
>> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa64d): undefined reference to
>> `__imp_PyBool_Type'
>> D:/msys64/mingw64/bin/ld:
>> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa6c4): undefined reference to
>> `__imp_PyLong_Type'
>> D:/msys64/mingw64/bin/ld:
>> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa6cd): undefined reference to
>> `__imp_PyBool_Type'
>> clang++: error: linker command failed with exit code 1 (use -v to see
>> invocation)
>> make: [Make_cyg_ming.mak:1126: gvim.exe] Error 1 (ignored)
>>
>>
>> My FLAGS are these :
>>
>> * CC=clang CXX=clang++ -pipe OLE=yes GUI=yes XPM=no DIRECTx=yes   ASAN=no
>>   DYNAMIC_LUA=yes LUA=./lua-5.4.6/src LUA_VER=54   PYTHON3=D:/Python312
>> DYNAMIC_PYTHON3=yes PYTHON3_VER=312   -I /d/python312/include
>> DYNAMIC_PYTHON3_DLL=python312.dllRUBY=D:/Ruby32-x64 DYNAMIC_RUBY=yes
>> RUBY_VER=32 RUBY_API_VER_LONG=3.2.0
>> -I/d/Ruby32-x64/include/ruby-3.2.0/ruby SODIUM=yes TERMINAL=yes
>> EVENT_LOOP=yes   STATIC_STDCPLUS=yes WINVER=0x0A00
>>
>> The install_PC.txt file just tell that for a clang compilation :
>>
>> CC=clang
>> CXX=clang++
>> make -f Make_ming.mak DEBUG=yes ASAN=yes
>>
>> Thank you for help
>>
>> --
> --
> 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 a topic in the
> Google Groups "vim_dev" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vim_dev/Epoifw56POA/unsubscribe.
> To unsubscribe from this group and all its topics, 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/73ae1253-405e-4503-96ef-08cd0278be69n%40googlegroups.com
> 
> .
>

-- 
-- 
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/CAOKxv4GMMRLe3vSw-sBse_W1-PM74HGn%3Dr%2B3KW3MyNNN8dgpiw%40mail.gmail.com.


Re: building vim with clang and python3 support

2023-06-01 Fir de Conversatie Ken Takata
Hi,

So, you are using the beta version of python 3.12, right?
Then, if_python3.c should be updated to support python 3.12, I think.

Regards,
Ken Takata

2023年6月1日木曜日 2:50:46 UTC+9 N i c o l a s:

> Hi,
>
> From vim.9.0.1594 source, I obtain this error trying to build gvim HUGE 
> version under win10 with python3(12) support.
>
>
> c -Wl,-Bdynamic -lgcc_eh -Wl,-Bstatic -lwinpthread -Wl,-Bdynamic -lole32 
> -luuid
> D:/msys64/mingw64/bin/ld: 
> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa07b): undefined reference to 
> `__imp_PyLong_Type'
> D:/msys64/mingw64/bin/ld: 
> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa088): undefined reference to 
> `__imp_PyBool_Type'
> D:/msys64/mingw64/bin/ld: 
> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa644): undefined reference to 
> `__imp_PyLong_Type'
> D:/msys64/mingw64/bin/ld: 
> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa64d): undefined reference to 
> `__imp_PyBool_Type'
> D:/msys64/mingw64/bin/ld: 
> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa6c4): undefined reference to 
> `__imp_PyLong_Type'
> D:/msys64/mingw64/bin/ld: 
> gobjx86-64/if_python3.o:if_python3.c:(.text+0xa6cd): undefined reference to 
> `__imp_PyBool_Type'
> clang++: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> make: [Make_cyg_ming.mak:1126: gvim.exe] Error 1 (ignored)
>
>
> My FLAGS are these :
>
> * CC=clang CXX=clang++ -pipe OLE=yes GUI=yes XPM=no DIRECTx=yes   ASAN=no 
>   DYNAMIC_LUA=yes LUA=./lua-5.4.6/src LUA_VER=54   PYTHON3=D:/Python312 
> DYNAMIC_PYTHON3=yes PYTHON3_VER=312   -I /d/python312/include   
> DYNAMIC_PYTHON3_DLL=python312.dllRUBY=D:/Ruby32-x64 DYNAMIC_RUBY=yes 
> RUBY_VER=32 RUBY_API_VER_LONG=3.2.0   
> -I/d/Ruby32-x64/include/ruby-3.2.0/ruby SODIUM=yes TERMINAL=yes 
> EVENT_LOOP=yes   STATIC_STDCPLUS=yes WINVER=0x0A00
>
> The install_PC.txt file just tell that for a clang compilation :
>
> CC=clang
> CXX=clang++
> make -f Make_ming.mak DEBUG=yes ASAN=yes
>
> Thank you for help
>
>

-- 
-- 
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/73ae1253-405e-4503-96ef-08cd0278be69n%40googlegroups.com.


Patch 9.0.1596

2023-06-01 Fir de Conversatie Bram Moolenaar


Patch 9.0.1596
Problem::registers command does not work in sandbox.
Solution:   Add flag to the command. (closes #12473)
Files:  src/ex_cmds.h, src/testdir/test_registers.vim


*** ../vim-9.0.1595/src/ex_cmds.h   2023-01-27 13:16:14.670850401 +
--- src/ex_cmds.h   2023-06-01 12:41:07.447910816 +0100
***
*** 1286,1292 
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
  EXCMD(CMD_registers,  "registers",ex_display,
!   EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
  EXCMD(CMD_resize, "resize",   ex_resize,
EX_RANGE|EX_TRLBAR|EX_WORD1|EX_CMDWIN|EX_LOCK_OK,
--- 1286,1292 
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
  EXCMD(CMD_registers,  "registers",ex_display,
!   EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
  EXCMD(CMD_resize, "resize",   ex_resize,
EX_RANGE|EX_TRLBAR|EX_WORD1|EX_CMDWIN|EX_LOCK_OK,
*** ../vim-9.0.1595/src/testdir/test_registers.vim  2023-05-09 
17:09:25.657491200 +0100
--- src/testdir/test_registers.vim  2023-06-01 11:54:09.823182365 +0100
***
*** 51,58 
  call feedkeys("i\=2*4\n\")
  call feedkeys(":ls\n", 'xt')
  
! let a = execute('display')
! let b = execute('registers')
  
  call assert_equal(a, b)
  call assert_match('^\nType Name Content\n'
--- 51,59 
  call feedkeys("i\=2*4\n\")
  call feedkeys(":ls\n", 'xt')
  
! " these commands work in the sandbox
! let a = execute('sandbox display')
! let b = execute('sandbox registers')
  
  call assert_equal(a, b)
  call assert_match('^\nType Name Content\n'
*** ../vim-9.0.1595/src/version.c   2023-05-31 18:57:10.513953154 +0100
--- src/version.c   2023-06-01 12:42:43.623812020 +0100
***
*** 697,698 
--- 697,700 
  {   /* Add new patch number below this line */
+ /**/
+ 1596,
  /**/

-- 
I AM THANKFUL...
...for a lawn that needs mowing, windows that need cleaning
and gutters that need fixing because it means I have a home.

 /// 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/20230601114732.F2A0D1C1B32%40moolenaar.net.