|
Karsten Hopp |
552d0d |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
552d0d |
Subject: Patch 7.3.427
|
|
Karsten Hopp |
552d0d |
Fcc: outbox
|
|
Karsten Hopp |
552d0d |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
552d0d |
Mime-Version: 1.0
|
|
Karsten Hopp |
552d0d |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
552d0d |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
552d0d |
------------
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
Patch 7.3.427
|
|
Karsten Hopp |
552d0d |
Problem: readfile() can be slow with long lines.
|
|
Karsten Hopp |
552d0d |
Solution: Use realloc() instead of alloc(). (John Little)
|
|
Karsten Hopp |
552d0d |
Files: src/eval.c
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
*** ../vim-7.3.426/src/eval.c 2012-01-26 14:32:26.000000000 +0100
|
|
Karsten Hopp |
552d0d |
--- src/eval.c 2012-02-05 00:25:39.000000000 +0100
|
|
Karsten Hopp |
552d0d |
***************
|
|
Karsten Hopp |
552d0d |
*** 14325,14346 ****
|
|
Karsten Hopp |
552d0d |
typval_T *rettv;
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
int binary = FALSE;
|
|
Karsten Hopp |
552d0d |
char_u *fname;
|
|
Karsten Hopp |
552d0d |
FILE *fd;
|
|
Karsten Hopp |
552d0d |
! listitem_T *li;
|
|
Karsten Hopp |
552d0d |
! #define FREAD_SIZE 200 /* optimized for text lines */
|
|
Karsten Hopp |
552d0d |
! char_u buf[FREAD_SIZE];
|
|
Karsten Hopp |
552d0d |
! int readlen; /* size of last fread() */
|
|
Karsten Hopp |
552d0d |
! int buflen; /* nr of valid chars in buf[] */
|
|
Karsten Hopp |
552d0d |
! int filtd; /* how much in buf[] was NUL -> '\n' filtered */
|
|
Karsten Hopp |
552d0d |
! int tolist; /* first byte in buf[] still to be put in list */
|
|
Karsten Hopp |
552d0d |
! int chop; /* how many CR to chop off */
|
|
Karsten Hopp |
552d0d |
! char_u *prev = NULL; /* previously read bytes, if any */
|
|
Karsten Hopp |
552d0d |
! int prevlen = 0; /* length of "prev" if not NULL */
|
|
Karsten Hopp |
552d0d |
! char_u *s;
|
|
Karsten Hopp |
552d0d |
! int len;
|
|
Karsten Hopp |
552d0d |
! long maxline = MAXLNUM;
|
|
Karsten Hopp |
552d0d |
! long cnt = 0;
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
if (argvars[1].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
--- 14325,14343 ----
|
|
Karsten Hopp |
552d0d |
typval_T *rettv;
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
int binary = FALSE;
|
|
Karsten Hopp |
552d0d |
+ int failed = FALSE;
|
|
Karsten Hopp |
552d0d |
char_u *fname;
|
|
Karsten Hopp |
552d0d |
FILE *fd;
|
|
Karsten Hopp |
552d0d |
! char_u buf[(IOSIZE/256)*256]; /* rounded to avoid odd + 1 */
|
|
Karsten Hopp |
552d0d |
! int io_size = sizeof(buf);
|
|
Karsten Hopp |
552d0d |
! int readlen; /* size of last fread() */
|
|
Karsten Hopp |
552d0d |
! char_u *prev = NULL; /* previously read bytes, if any */
|
|
Karsten Hopp |
552d0d |
! long prevlen = 0; /* length of data in prev */
|
|
Karsten Hopp |
552d0d |
! long prevsize = 0; /* size of prev buffer */
|
|
Karsten Hopp |
552d0d |
! long maxline = MAXLNUM;
|
|
Karsten Hopp |
552d0d |
! long cnt = 0;
|
|
Karsten Hopp |
552d0d |
! char_u *p; /* position in buf */
|
|
Karsten Hopp |
552d0d |
! char_u *start; /* start of current line */
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
if (argvars[1].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
***************
|
|
Karsten Hopp |
552d0d |
*** 14362,14410 ****
|
|
Karsten Hopp |
552d0d |
return;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
- filtd = 0;
|
|
Karsten Hopp |
552d0d |
while (cnt < maxline || maxline < 0)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! readlen = (int)fread(buf + filtd, 1, FREAD_SIZE - filtd, fd);
|
|
Karsten Hopp |
552d0d |
! buflen = filtd + readlen;
|
|
Karsten Hopp |
552d0d |
! tolist = 0;
|
|
Karsten Hopp |
552d0d |
! for ( ; filtd < buflen || readlen <= 0; ++filtd)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! if (readlen <= 0 || buf[filtd] == '\n')
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! /* In binary mode add an empty list item when the last
|
|
Karsten Hopp |
552d0d |
! * non-empty line ends in a '\n'. */
|
|
Karsten Hopp |
552d0d |
! if (!binary && readlen == 0 && filtd == 0 && prev == NULL)
|
|
Karsten Hopp |
552d0d |
! break;
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
! /* Found end-of-line or end-of-file: add a text line to the
|
|
Karsten Hopp |
552d0d |
! * list. */
|
|
Karsten Hopp |
552d0d |
! chop = 0;
|
|
Karsten Hopp |
552d0d |
! if (!binary)
|
|
Karsten Hopp |
552d0d |
! while (filtd - chop - 1 >= tolist
|
|
Karsten Hopp |
552d0d |
! && buf[filtd - chop - 1] == '\r')
|
|
Karsten Hopp |
552d0d |
! ++chop;
|
|
Karsten Hopp |
552d0d |
! len = filtd - tolist - chop;
|
|
Karsten Hopp |
552d0d |
! if (prev == NULL)
|
|
Karsten Hopp |
552d0d |
! s = vim_strnsave(buf + tolist, len);
|
|
Karsten Hopp |
552d0d |
else
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! s = alloc((unsigned)(prevlen + len + 1));
|
|
Karsten Hopp |
552d0d |
! if (s != NULL)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! mch_memmove(s, prev, prevlen);
|
|
Karsten Hopp |
552d0d |
! vim_free(prev);
|
|
Karsten Hopp |
552d0d |
! prev = NULL;
|
|
Karsten Hopp |
552d0d |
! mch_memmove(s + prevlen, buf + tolist, len);
|
|
Karsten Hopp |
552d0d |
s[prevlen + len] = NUL;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! tolist = filtd + 1;
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
! li = listitem_alloc();
|
|
Karsten Hopp |
552d0d |
! if (li == NULL)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
vim_free(s);
|
|
Karsten Hopp |
552d0d |
break;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
li->li_tv.v_type = VAR_STRING;
|
|
Karsten Hopp |
552d0d |
--- 14359,14419 ----
|
|
Karsten Hopp |
552d0d |
return;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
while (cnt < maxline || maxline < 0)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! readlen = (int)fread(buf, 1, io_size, fd);
|
|
Karsten Hopp |
552d0d |
!
|
|
Karsten Hopp |
552d0d |
! /* This for loop processes what was read, but is also entered at end
|
|
Karsten Hopp |
552d0d |
! * of file so that either:
|
|
Karsten Hopp |
552d0d |
! * - an incomplete line gets written
|
|
Karsten Hopp |
552d0d |
! * - a "binary" file gets an empty line at the end if it ends in a
|
|
Karsten Hopp |
552d0d |
! * newline. */
|
|
Karsten Hopp |
552d0d |
! for (p = buf, start = buf;
|
|
Karsten Hopp |
552d0d |
! p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary));
|
|
Karsten Hopp |
552d0d |
! ++p)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! if (*p == '\n' || readlen <= 0)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! listitem_T *li;
|
|
Karsten Hopp |
552d0d |
! char_u *s = NULL;
|
|
Karsten Hopp |
552d0d |
! long_u len = p - start;
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
! /* Finished a line. Remove CRs before NL. */
|
|
Karsten Hopp |
552d0d |
! if (readlen > 0 && !binary)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! while (len > 0 && start[len - 1] == '\r')
|
|
Karsten Hopp |
552d0d |
! --len;
|
|
Karsten Hopp |
552d0d |
! /* removal may cross back to the "prev" string */
|
|
Karsten Hopp |
552d0d |
! if (len == 0)
|
|
Karsten Hopp |
552d0d |
! while (prevlen > 0 && prev[prevlen - 1] == '\r')
|
|
Karsten Hopp |
552d0d |
! --prevlen;
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
! if (prevlen == 0)
|
|
Karsten Hopp |
552d0d |
! s = vim_strnsave(start, len);
|
|
Karsten Hopp |
552d0d |
else
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! /* Change "prev" buffer to be the right size. This way
|
|
Karsten Hopp |
552d0d |
! * the bytes are only copied once, and very long lines are
|
|
Karsten Hopp |
552d0d |
! * allocated only once. */
|
|
Karsten Hopp |
552d0d |
! if ((s = vim_realloc(prev, prevlen + len + 1)) != NULL)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! mch_memmove(s + prevlen, start, len);
|
|
Karsten Hopp |
552d0d |
s[prevlen + len] = NUL;
|
|
Karsten Hopp |
552d0d |
+ prev = NULL; /* the list will own the string */
|
|
Karsten Hopp |
552d0d |
+ prevlen = prevsize = 0;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! if (s == NULL)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! do_outofmem_msg((long_u) prevlen + len + 1);
|
|
Karsten Hopp |
552d0d |
! failed = TRUE;
|
|
Karsten Hopp |
552d0d |
! break;
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
! if ((li = listitem_alloc()) == NULL)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
vim_free(s);
|
|
Karsten Hopp |
552d0d |
+ failed = TRUE;
|
|
Karsten Hopp |
552d0d |
break;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
li->li_tv.v_type = VAR_STRING;
|
|
Karsten Hopp |
552d0d |
***************
|
|
Karsten Hopp |
552d0d |
*** 14412,14485 ****
|
|
Karsten Hopp |
552d0d |
li->li_tv.vval.v_string = s;
|
|
Karsten Hopp |
552d0d |
list_append(rettv->vval.v_list, li);
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
! if (++cnt >= maxline && maxline >= 0)
|
|
Karsten Hopp |
552d0d |
! break;
|
|
Karsten Hopp |
552d0d |
! if (readlen <= 0)
|
|
Karsten Hopp |
552d0d |
break;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! else if (buf[filtd] == NUL)
|
|
Karsten Hopp |
552d0d |
! buf[filtd] = '\n';
|
|
Karsten Hopp |
552d0d |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
552d0d |
! else if (buf[filtd] == 0xef
|
|
Karsten Hopp |
552d0d |
! && enc_utf8
|
|
Karsten Hopp |
552d0d |
! && filtd + 2 < buflen
|
|
Karsten Hopp |
552d0d |
! && !binary
|
|
Karsten Hopp |
552d0d |
! && buf[filtd + 1] == 0xbb
|
|
Karsten Hopp |
552d0d |
! && buf[filtd + 2] == 0xbf)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! /* remove utf-8 byte order mark */
|
|
Karsten Hopp |
552d0d |
! mch_memmove(buf + filtd, buf + filtd + 3, buflen - filtd - 3);
|
|
Karsten Hopp |
552d0d |
! --filtd;
|
|
Karsten Hopp |
552d0d |
! buflen -= 3;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
#endif
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
! if (readlen <= 0)
|
|
Karsten Hopp |
552d0d |
! break;
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
! if (tolist == 0)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! if (buflen >= FREAD_SIZE / 2)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! /* "buf" is full, need to move text to an allocated buffer */
|
|
Karsten Hopp |
552d0d |
! if (prev == NULL)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! prev = vim_strnsave(buf, buflen);
|
|
Karsten Hopp |
552d0d |
! prevlen = buflen;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! else
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! s = alloc((unsigned)(prevlen + buflen));
|
|
Karsten Hopp |
552d0d |
! if (s != NULL)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! mch_memmove(s, prev, prevlen);
|
|
Karsten Hopp |
552d0d |
! mch_memmove(s + prevlen, buf, buflen);
|
|
Karsten Hopp |
552d0d |
! vim_free(prev);
|
|
Karsten Hopp |
552d0d |
! prev = s;
|
|
Karsten Hopp |
552d0d |
! prevlen += buflen;
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! filtd = 0;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! else
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! mch_memmove(buf, buf + tolist, buflen - tolist);
|
|
Karsten Hopp |
552d0d |
! filtd -= tolist;
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
/*
|
|
Karsten Hopp |
552d0d |
* For a negative line count use only the lines at the end of the file,
|
|
Karsten Hopp |
552d0d |
* free the rest.
|
|
Karsten Hopp |
552d0d |
*/
|
|
Karsten Hopp |
552d0d |
! if (maxline < 0)
|
|
Karsten Hopp |
552d0d |
while (cnt > -maxline)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
listitem_remove(rettv->vval.v_list, rettv->vval.v_list->lv_first);
|
|
Karsten Hopp |
552d0d |
--cnt;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
vim_free(prev);
|
|
Karsten Hopp |
552d0d |
fclose(fd);
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
--- 14421,14529 ----
|
|
Karsten Hopp |
552d0d |
li->li_tv.vval.v_string = s;
|
|
Karsten Hopp |
552d0d |
list_append(rettv->vval.v_list, li);
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
! start = p + 1; /* step over newline */
|
|
Karsten Hopp |
552d0d |
! if ((++cnt >= maxline && maxline >= 0) || readlen <= 0)
|
|
Karsten Hopp |
552d0d |
break;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! else if (*p == NUL)
|
|
Karsten Hopp |
552d0d |
! *p = '\n';
|
|
Karsten Hopp |
552d0d |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
552d0d |
! /* Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this
|
|
Karsten Hopp |
552d0d |
! * when finding the BF and check the previous two bytes. */
|
|
Karsten Hopp |
552d0d |
! else if (*p == 0xbf && enc_utf8 && !binary)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! /* Find the two bytes before the 0xbf. If p is at buf, or buf
|
|
Karsten Hopp |
552d0d |
! * + 1, these may be in the "prev" string. */
|
|
Karsten Hopp |
552d0d |
! char_u back1 = p >= buf + 1 ? p[-1]
|
|
Karsten Hopp |
552d0d |
! : prevlen >= 1 ? prev[prevlen - 1] : NUL;
|
|
Karsten Hopp |
552d0d |
! char_u back2 = p >= buf + 2 ? p[-2]
|
|
Karsten Hopp |
552d0d |
! : p == buf + 1 && prevlen >= 1 ? prev[prevlen - 1]
|
|
Karsten Hopp |
552d0d |
! : prevlen >= 2 ? prev[prevlen - 2] : NUL;
|
|
Karsten Hopp |
552d0d |
!
|
|
Karsten Hopp |
552d0d |
! if (back2 == 0xef && back1 == 0xbb)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! char_u *dest = p - 2;
|
|
Karsten Hopp |
552d0d |
!
|
|
Karsten Hopp |
552d0d |
! /* Usually a BOM is at the beginning of a file, and so at
|
|
Karsten Hopp |
552d0d |
! * the beginning of a line; then we can just step over it.
|
|
Karsten Hopp |
552d0d |
! */
|
|
Karsten Hopp |
552d0d |
! if (start == dest)
|
|
Karsten Hopp |
552d0d |
! start = p + 1;
|
|
Karsten Hopp |
552d0d |
! else
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! /* have to shuffle buf to close gap */
|
|
Karsten Hopp |
552d0d |
! int adjust_prevlen = 0;
|
|
Karsten Hopp |
552d0d |
!
|
|
Karsten Hopp |
552d0d |
! if (dest < buf)
|
|
Karsten Hopp |
552d0d |
! {
|
|
Karsten Hopp |
552d0d |
! adjust_prevlen = buf - dest; /* must be 1 or 2 */
|
|
Karsten Hopp |
552d0d |
! dest = buf;
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
! if (readlen > p - buf + 1)
|
|
Karsten Hopp |
552d0d |
! mch_memmove(dest, p + 1, readlen - (p - buf) - 1);
|
|
Karsten Hopp |
552d0d |
! readlen -= 3 - adjust_prevlen;
|
|
Karsten Hopp |
552d0d |
! prevlen -= adjust_prevlen;
|
|
Karsten Hopp |
552d0d |
! p = dest - 1;
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
! }
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
#endif
|
|
Karsten Hopp |
552d0d |
! } /* for */
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
! if (failed || (cnt >= maxline && maxline >= 0) || readlen <= 0)
|
|
Karsten Hopp |
552d0d |
! break;
|
|
Karsten Hopp |
552d0d |
! if (start < p)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! /* There's part of a line in buf, store it in "prev". */
|
|
Karsten Hopp |
552d0d |
! if (p - start + prevlen >= prevsize)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! /* need bigger "prev" buffer */
|
|
Karsten Hopp |
552d0d |
! char_u *newprev;
|
|
Karsten Hopp |
552d0d |
!
|
|
Karsten Hopp |
552d0d |
! /* A common use case is ordinary text files and "prev" gets a
|
|
Karsten Hopp |
552d0d |
! * fragment of a line, so the first allocation is made
|
|
Karsten Hopp |
552d0d |
! * small, to avoid repeatedly 'allocing' large and
|
|
Karsten Hopp |
552d0d |
! * 'reallocing' small. */
|
|
Karsten Hopp |
552d0d |
! if (prevsize == 0)
|
|
Karsten Hopp |
552d0d |
! prevsize = p - start;
|
|
Karsten Hopp |
552d0d |
! else
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! long grow50pc = (prevsize * 3) / 2;
|
|
Karsten Hopp |
552d0d |
! long growmin = (p - start) * 2 + prevlen;
|
|
Karsten Hopp |
552d0d |
! prevsize = grow50pc > growmin ? grow50pc : growmin;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! if ((newprev = vim_realloc(prev, prevsize)) == NULL)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
! do_outofmem_msg((long_u)prevsize);
|
|
Karsten Hopp |
552d0d |
! failed = TRUE;
|
|
Karsten Hopp |
552d0d |
! break;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! prev = newprev;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
+ /* Add the line part to end of "prev". */
|
|
Karsten Hopp |
552d0d |
+ mch_memmove(prev + prevlen, start, p - start);
|
|
Karsten Hopp |
552d0d |
+ prevlen += p - start;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
! } /* while */
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
/*
|
|
Karsten Hopp |
552d0d |
* For a negative line count use only the lines at the end of the file,
|
|
Karsten Hopp |
552d0d |
* free the rest.
|
|
Karsten Hopp |
552d0d |
*/
|
|
Karsten Hopp |
552d0d |
! if (!failed && maxline < 0)
|
|
Karsten Hopp |
552d0d |
while (cnt > -maxline)
|
|
Karsten Hopp |
552d0d |
{
|
|
Karsten Hopp |
552d0d |
listitem_remove(rettv->vval.v_list, rettv->vval.v_list->lv_first);
|
|
Karsten Hopp |
552d0d |
--cnt;
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
+ if (failed)
|
|
Karsten Hopp |
552d0d |
+ {
|
|
Karsten Hopp |
552d0d |
+ list_free(rettv->vval.v_list, TRUE);
|
|
Karsten Hopp |
552d0d |
+ /* readfile doc says an empty list is returned on error */
|
|
Karsten Hopp |
552d0d |
+ rettv->vval.v_list = list_alloc();
|
|
Karsten Hopp |
552d0d |
+ }
|
|
Karsten Hopp |
552d0d |
+
|
|
Karsten Hopp |
552d0d |
vim_free(prev);
|
|
Karsten Hopp |
552d0d |
fclose(fd);
|
|
Karsten Hopp |
552d0d |
}
|
|
Karsten Hopp |
552d0d |
***************
|
|
Karsten Hopp |
552d0d |
*** 21802,21808 ****
|
|
Karsten Hopp |
552d0d |
fp = HI2UF(hi);
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
if (fp->uf_flags & FC_DICT)
|
|
Karsten Hopp |
552d0d |
! return ""; /* don't show dict functions */
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
if (STRLEN(fp->uf_name) + 4 >= IOSIZE)
|
|
Karsten Hopp |
552d0d |
return fp->uf_name; /* prevents overflow */
|
|
Karsten Hopp |
552d0d |
--- 21846,21852 ----
|
|
Karsten Hopp |
552d0d |
fp = HI2UF(hi);
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
if (fp->uf_flags & FC_DICT)
|
|
Karsten Hopp |
552d0d |
! return (char_u *)""; /* don't show dict functions */
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
if (STRLEN(fp->uf_name) + 4 >= IOSIZE)
|
|
Karsten Hopp |
552d0d |
return fp->uf_name; /* prevents overflow */
|
|
Karsten Hopp |
552d0d |
*** ../vim-7.3.426/src/version.c 2012-02-04 23:34:57.000000000 +0100
|
|
Karsten Hopp |
552d0d |
--- src/version.c 2012-02-05 00:38:34.000000000 +0100
|
|
Karsten Hopp |
552d0d |
***************
|
|
Karsten Hopp |
552d0d |
*** 716,717 ****
|
|
Karsten Hopp |
552d0d |
--- 716,719 ----
|
|
Karsten Hopp |
552d0d |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
552d0d |
+ /**/
|
|
Karsten Hopp |
552d0d |
+ 427,
|
|
Karsten Hopp |
552d0d |
/**/
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
--
|
|
Karsten Hopp |
552d0d |
One difference between a man and a machine is that a machine is quiet
|
|
Karsten Hopp |
552d0d |
when well oiled.
|
|
Karsten Hopp |
552d0d |
|
|
Karsten Hopp |
552d0d |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
552d0d |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
552d0d |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
552d0d |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|