Patch 9.0.0261

7 views
Skip to first unread message

Bram Moolenaar

unread,
Aug 25, 2022, 7:46:11 AM8/25/22
to vim...@googlegroups.com

Patch 9.0.0261
Problem: bufload() reads a file even if the name is not a file name. (Cyker
Way)
Solution: Do not read the file when the buffer name is not a file name.
(closes #10975)
Files: runtime/doc/builtin.txt, src/buffer.c,
src/testdir/test_functions.vim


*** ../vim-9.0.0260/runtime/doc/builtin.txt 2022-08-24 16:30:30.686752454 +0100
--- runtime/doc/builtin.txt 2022-08-25 12:35:19.813726652 +0100
***************
*** 1179,1185 ****
browsing is not possible, an empty string is returned.

bufadd({name}) *bufadd()*
! Add a buffer to the buffer list with String {name}.
If a buffer for file {name} already exists, return that buffer
number. Otherwise return the buffer number of the newly
created buffer. When {name} is an empty string then a new
--- 1179,1186 ----
browsing is not possible, an empty string is returned.

bufadd({name}) *bufadd()*
! Add a buffer to the buffer list with name {name} (must be a
! String).
If a buffer for file {name} already exists, return that buffer
number. Otherwise return the buffer number of the newly
created buffer. When {name} is an empty string then a new
***************
*** 1232,1238 ****
Ensure the buffer {buf} is loaded. When the buffer name
refers to an existing file then the file is read. Otherwise
the buffer will be empty. If the buffer was already loaded
! then there is no change.
If there is an existing swap file for the file of the buffer,
there will be no dialog, the buffer will be loaded anyway.
The {buf} argument is used like with |bufexists()|.
--- 1233,1240 ----
Ensure the buffer {buf} is loaded. When the buffer name
refers to an existing file then the file is read. Otherwise
the buffer will be empty. If the buffer was already loaded
! then there is no change. If the buffer is not related to a
! file the no file is read (e.g., when 'buftype' is "nofile").
If there is an existing swap file for the file of the buffer,
there will be no dialog, the buffer will be loaded anyway.
The {buf} argument is used like with |bufexists()|.
*** ../vim-9.0.0260/src/buffer.c 2022-08-22 15:19:12.728328961 +0100
--- src/buffer.c 2022-08-25 12:34:17.458110650 +0100
***************
*** 220,226 ****
--- 220,229 ----
// mark cursor position as being invalid
curwin->w_valid = 0;

+ // Read the file if there is one.
if (curbuf->b_ffname != NULL
+ && !bt_quickfix(curbuf)
+ && !bt_nofilename(curbuf)
#ifdef FEAT_NETBEANS_INTG
&& netbeansReadFile
#endif
*** ../vim-9.0.0260/src/testdir/test_functions.vim 2022-06-30 11:03:36.048634818 +0100
--- src/testdir/test_functions.vim 2022-08-25 12:43:31.867356345 +0100
***************
*** 2368,2373 ****
--- 2368,2380 ----
exe 'bwipe ' .. buf2
call assert_equal(0, bufexists(buf2))

+ " when 'buftype' is "nofile" then bufload() does not read the file
+ bwipe! XotherName
+ let buf = bufadd('XotherName')
+ call setbufvar(buf, '&bt', 'nofile')
+ call bufload(buf)
+ call assert_equal([''], getbufline(buf, 1, '$'))
+
bwipe someName
bwipe XotherName
call assert_equal(0, bufexists('someName'))
*** ../vim-9.0.0260/src/version.c 2022-08-24 20:07:19.342558427 +0100
--- src/version.c 2022-08-25 12:44:22.287158139 +0100
***************
*** 733,734 ****
--- 733,736 ----
{ /* Add new patch number below this line */
+ /**/
+ 261,
/**/

--
Q: Why does /dev/null accept only integers?
A: You can't sink a float.

/// Bram Moolenaar -- Br...@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 ///

Tony Mechelynck

unread,
Aug 25, 2022, 8:55:28 AM8/25/22
to Bram Moolenaar, vim...@googlegroups.com
On Thu, Aug 25, 2022 at 1:46 PM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Patch 9.0.0261
> Problem: bufload() reads a file even if the name is not a file name. (Cyker
> Way)
> Solution: Do not read the file when the buffer name is not a file name.
> (closes #10975)
> Files: runtime/doc/builtin.txt, src/buffer.c,
> src/testdir/test_functions.vim

"Linking failed" in Small and Tiny ("undefined reference to
'bt_quickfix'" in buffer.c at text+0x4349):

linux-tuxedo:~/.build/vim/vim-hg/src/shadow-tiny # (make || echo 'exit
status' $? ; date) 2>&1 |tee -a make.log
gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -fno-strength-reduce -Wall
-Wno-deprecated-declarations -D_REENTRANT -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=1 -o objects/buffer.o buffer.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -fno-strength-reduce -Wall
-Wno-deprecated-declarations -D_REENTRANT -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=1 version.c -o objects/version.o
link.sh: $LINK_AS_NEEDED set to 'yes': invoking linker directly.
gcc -L/usr/local/lib -Wl,--as-needed -o vi objects/alloc.o
objects/arabic.o objects/arglist.o objects/autocmd.o objects/beval.o
objects/buffer.o objects/change.o objects/blob.o objects/blowfish.o
objects/cindent.o objects/clientserver.o objects/clipboard.o
objects/cmdexpand.o objects/cmdhist.o objects/crypt.o
objects/crypt_zip.o objects/debugger.o objects/dict.o objects/diff.o
objects/digraph.o objects/drawline.o objects/drawscreen.o
objects/edit.o objects/eval.o objects/evalbuffer.o objects/evalfunc.o
objects/evalvars.o objects/evalwindow.o objects/ex_cmds.o
objects/ex_cmds2.o objects/ex_docmd.o objects/ex_eval.o
objects/ex_getln.o objects/fileio.o objects/filepath.o
objects/findfile.o objects/float.o objects/fold.o objects/getchar.o
objects/gui_xim.o objects/hardcopy.o objects/hashtab.o objects/help.o
objects/highlight.o objects/if_cscope.o objects/if_xcmdsrv.o
objects/indent.o objects/insexpand.o objects/list.o objects/locale.o
objects/map.o objects/mark.o objects/match.o objects/mbyte.o
objects/memline.o objects/menu.o objects/misc1.o objects/misc2.o
objects/mouse.o objects/move.o objects/normal.o objects/ops.o
objects/option.o objects/optionstr.o objects/os_unix.o
objects/pathdef.o objects/popupmenu.o objects/popupwin.o
objects/profiler.o objects/pty.o objects/quickfix.o objects/regexp.o
objects/register.o objects/screen.o objects/scriptfile.o
objects/search.o objects/session.o objects/sha256.o objects/sign.o
objects/sound.o objects/spell.o objects/spellfile.o
objects/spellsuggest.o objects/strings.o objects/syntax.o
objects/tag.o objects/term.o objects/terminal.o objects/testing.o
objects/textformat.o objects/textobject.o objects/textprop.o
objects/time.o objects/typval.o objects/ui.o objects/undo.o
objects/usercmd.o objects/userfunc.o objects/version.o
objects/vim9cmds.o objects/vim9compile.o objects/vim9execute.o
objects/vim9expr.o objects/vim9instr.o objects/vim9script.o
objects/vim9type.o objects/viminfo.o objects/window.o
objects/bufwrite.o objects/charset.o objects/json.o
objects/main.o objects/memfile.o objects/message.o -lSM -lICE -lXpm
-lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lselinux -lgpm
/usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld:
objects/buffer.o: in function `open_buffer':
buffer.c:(.text+0x4349): undefined reference to `bt_quickfix'
collect2: error: ld returned 1 exit status
link.sh: Linking failed
make: *** [Makefile:2112: vi] Error 1
exit status 2
Thu 25 Aug 14:49:00 CEST 2022
linux-tuxedo:~/.build/vim/vim-hg/src/shadow-tiny #
Reply all
Reply to author
Forward
0 new messages