Patch 8.0.1774
Problem: Reading very long lines can be slow.
Solution: Read up to 1 Mbyte at a time to avoid a lot of copying. Add a
check for going over the column limit.
Files: src/fileio.c
*** ../vim-8.0.1773/src/fileio.c 2018-04-24 15:19:00.503068778 +0200
--- src/fileio.c 2018-04-29 13:30:43.291444234 +0200
***************
*** 1209,1236 ****
* The amount is limited by the fact that read() only can read
* upto max_unsigned characters (and other things).
*/
! #if VIM_SIZEOF_INT <= 2
! if (linerest >= 0x7ff0)
! {
! ++split;
! *ptr = NL; /* split line by inserting a NL */
! size = 1;
! }
! else
! #endif
{
- if (!skip_read)
- {
#if VIM_SIZEOF_INT > 2
# if defined(SSIZE_MAX) && (SSIZE_MAX < 0x10000L)
size = SSIZE_MAX; /* use max I/O size, 52K */
# else
! size = 0x10000L; /* use buffer >= 64K */
# endif
#else
size = 0x7ff0L - linerest; /* limit buffer to 32K */
#endif
for ( ; size >= 10; size = (long)((long_u)size >> 1))
{
if ((new_buffer = lalloc((long_u)(size + linerest + 1),
--- 1209,1250 ----
* The amount is limited by the fact that read() only can read
* upto max_unsigned characters (and other things).
*/
! if (!skip_read)
{
#if VIM_SIZEOF_INT > 2
# if defined(SSIZE_MAX) && (SSIZE_MAX < 0x10000L)
size = SSIZE_MAX; /* use max I/O size, 52K */
# else
! /* Use buffer >= 64K. Add linerest to double the size if the
! * line gets very long, to avoid a lot of copying. But don't
! * read more than 1 Mbyte at a time, so we can be interrupted.
! */
! size = 0x10000L + linerest;
! if (size > 0x100000L)
! size = 0x100000L;
# endif
#else
size = 0x7ff0L - linerest; /* limit buffer to 32K */
#endif
+ }
+ /* Protect against the argument of lalloc() going negative. */
+ if (
+ #if VIM_SIZEOF_INT <= 2
+ linerest >= 0x7ff0
+ #else
+ size < 0 || size + linerest + 1 < 0 || linerest >= MAXCOL
+ #endif
+ )
+ {
+ ++split;
+ *ptr = NL; /* split line by inserting a NL */
+ size = 1;
+ }
+ else
+ {
+ if (!skip_read)
+ {
for ( ; size >= 10; size = (long)((long_u)size >> 1))
{
if ((new_buffer = lalloc((long_u)(size + linerest + 1),
*** ../vim-8.0.1773/src/version.c 2018-04-29 12:22:49.167522589 +0200
--- src/version.c 2018-04-29 13:33:29.446475593 +0200
***************
*** 763,764 ****
--- 763,766 ----
{ /* Add new patch number below this line */
+ /**/
+ 1774,
/**/
--
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ 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].
For more options, visit https://groups.google.com/d/optout.