home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: patch 5.4.37
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- ------------
-
- A long patch for long viminfo lines...
-
-
- Patch 5.4.37
- Problem: Long strings from the viminfo file are truncated.
- Solution: When writing a long string to the viminfo file, first write a line
- with the length, then the string itself in a second line.
- Files: src/eval.c, src/ex_cmds.c, src/ex_getln.c, src/mark.c, src/ops.c,
- src/search.c, src/proto/ex_cmds.pro, runtime/syntax/viminfo.vim
-
-
- *** ../vim-5.4.36/src/eval.c Wed Aug 18 13:05:53 1999
- --- src/eval.c Thu Aug 19 22:13:46 1999
- ***************
- *** 5280,5304 ****
- {
- char_u *tab;
- int is_string = FALSE;
- ! VAR varp;
-
- if (!writing && (find_viminfo_parameter('!') != NULL))
- {
- tab = vim_strchr(line + 1, '\t');
- if (tab != NULL)
- {
- ! *tab++ = '\0';
- ! if (*tab == 'S') /*string var*/
- is_string = TRUE;
-
- tab = vim_strchr(tab, '\t');
- if (tab != NULL)
- {
- ! /* set variable */
- if (is_string)
- {
- ! viminfo_readstring(tab + 1);
- ! set_internal_string_var(line + 1, tab + 1);
- }
- else
- {
- --- 5282,5308 ----
- {
- char_u *tab;
- int is_string = FALSE;
- ! VAR varp = NULL;
- ! char_u *val;
-
- if (!writing && (find_viminfo_parameter('!') != NULL))
- {
- tab = vim_strchr(line + 1, '\t');
- if (tab != NULL)
- {
- ! *tab++ = '\0'; /* isolate the variable name */
- ! if (*tab == 'S') /* string var */
- is_string = TRUE;
-
- tab = vim_strchr(tab, '\t');
- if (tab != NULL)
- {
- ! /* create a nameless variable to hold the value */
- if (is_string)
- {
- ! val = viminfo_readstring(tab + 1, fp);
- ! if (val != NULL)
- ! varp = alloc_string_var(val);
- }
- else
- {
- ***************
- *** 5306,5315 ****
- if (varp != NULL)
- {
- varp->var_type = VAR_NUMBER;
- ! varp->var_val.var_number = atol((char *)tab);
- ! set_var(line + 1, varp);
- ! free_var(varp);
- }
- }
- }
- }
- --- 5310,5323 ----
- if (varp != NULL)
- {
- varp->var_type = VAR_NUMBER;
- ! varp->var_val.var_number = atol((char *)tab + 1);
- }
- + }
- + /* assign the value to the variable */
- + if (varp != NULL)
- + {
- + set_var(line + 1, varp);
- + free_var(varp);
- }
- }
- }
- *** ../vim-5.4.36/src/ex_cmds.c Sat Jul 24 16:19:00 1999
- --- src/ex_cmds.c Thu Aug 19 23:22:51 1999
- ***************
- *** 1617,1623 ****
- case '-': /* to be defined */
- case '^': /* to be defined */
- case '*': /* to be defined */
- ! case '<': /* to be defined */
- /* A comment */
- case NUL:
- case '\r':
- --- 1617,1623 ----
- case '-': /* to be defined */
- case '^': /* to be defined */
- case '*': /* to be defined */
- ! case '<': /* long line - ignored */
- /* A comment */
- case NUL:
- case '\r':
- ***************
- *** 1675,1696 ****
- * remove '\n' at the end of the line
- * - replace CTRL-V CTRL-V with CTRL-V
- * - replace CTRL-V 'n' with '\n'
- */
- ! void
- ! viminfo_readstring(p)
- char_u *p;
- {
- ! while (*p != NUL && *p != '\n')
- {
- ! if (*p == Ctrl('V'))
- {
- ! if (p[1] == 'n')
- ! p[0] = '\n';
- ! mch_memmove(p + 1, p + 2, STRLEN(p));
- }
- ! ++p;
- }
- ! *p = NUL;
- }
-
- /*
- --- 1675,1732 ----
- * remove '\n' at the end of the line
- * - replace CTRL-V CTRL-V with CTRL-V
- * - replace CTRL-V 'n' with '\n'
- + *
- + * Check for a long line as written by viminfo_writestring().
- + *
- + * Return the string in allocated memory (NULL when out of memory).
- */
- ! char_u *
- ! viminfo_readstring(p, fp)
- char_u *p;
- + FILE *fp;
- {
- ! char_u *retval;
- ! char_u *s, *d;
- ! long len;
- !
- ! if (p[0] == Ctrl('V') && isdigit(p[1]))
- ! {
- ! len = atol(p + 1);
- ! retval = lalloc(len, TRUE);
- ! if (retval == NULL)
- ! {
- ! /* Line too long? File messed up? Skip next line. */
- ! (void)vim_fgets(p, 10, fp);
- ! return NULL;
- ! }
- ! (void)vim_fgets(retval, (int)len, fp);
- ! s = retval + 1; /* Skip the leading '<' */
- ! }
- ! else
- ! {
- ! retval = vim_strsave(p);
- ! if (retval == NULL)
- ! return NULL;
- ! s = retval;
- ! }
- !
- ! /* Change CTRL-V CTRL-V to CTRL-V and CTRL-V n to \n in-place. */
- ! d = retval;
- ! while (*s != NUL && *s != '\n')
- {
- ! if (s[0] == Ctrl('V') && s[1] != NUL)
- {
- ! if (s[1] == 'n')
- ! *d++ = '\n';
- ! else
- ! *d++ = Ctrl('V');
- ! s += 2;
- }
- ! else
- ! *d++ = *s++;
- }
- ! *d = NUL;
- ! return retval;
- }
-
- /*
- ***************
- *** 1698,1710 ****
- * - replace CTRL-V with CTRL-V CTRL-V
- * - replace '\n' with CTRL-V 'n'
- * - add a '\n' at the end
- */
- void
- viminfo_writestring(fd, p)
- ! FILE *fd;
- ! char_u *p;
- {
- ! int c;
-
- while ((c = *p++) != NUL)
- {
- --- 1734,1766 ----
- * - replace CTRL-V with CTRL-V CTRL-V
- * - replace '\n' with CTRL-V 'n'
- * - add a '\n' at the end
- + *
- + * For a long line:
- + * - write " CTRL-V <length> \n " in first line
- + * - write " < <string> \n " in second line
- */
- void
- viminfo_writestring(fd, p)
- ! FILE *fd;
- ! char_u *p;
- {
- ! int c;
- ! char_u *s;
- ! int len = 0;
- !
- ! for (s = p; *s != NUL; ++s)
- ! {
- ! if (*s == Ctrl('V') || *s == '\n')
- ! ++len;
- ! ++len;
- ! }
- !
- ! /* If the string will be too long, write its length and put it in the next
- ! * line. Take into account that some room is needed for what comes before
- ! * the string (e.g., variable name). Add something to the length for the
- ! * '<', NL and trailing NUL. */
- ! if (len > LSIZE / 2)
- ! fprintf(fd, "\026%d\n<", len + 3);
-
- while ((c = *p++) != NUL)
- {
- ***************
- *** 3633,3642 ****
- if (old_sub != NULL && force)
- vim_free(old_sub);
- if (force || old_sub == NULL)
- ! {
- ! viminfo_readstring(line);
- ! old_sub = vim_strsave(line + 1);
- ! }
- return vim_fgets(line, LSIZE, fp);
- }
-
- --- 3689,3695 ----
- if (old_sub != NULL && force)
- vim_free(old_sub);
- if (force || old_sub == NULL)
- ! old_sub = viminfo_readstring(line + 1, fp);
- return vim_fgets(line, LSIZE, fp);
- }
-
- *** ../vim-5.4.36/src/ex_getln.c Tue Aug 10 16:10:35 1999
- --- src/ex_getln.c Thu Aug 19 22:17:52 1999
- ***************
- *** 3549,3562 ****
- FILE *fp;
- {
- int type;
-
- type = hist_char2type(line[0]);
- if (viminfo_hisidx[type] < viminfo_hislen[type])
- {
- ! viminfo_readstring(line);
- ! if (!in_history(type, line + 1, viminfo_add_at_front))
- ! viminfo_history[type][viminfo_hisidx[type]++] =
- ! vim_strsave(line + 1);
- }
- return vim_fgets(line, LSIZE, fp);
- }
- --- 3549,3567 ----
- FILE *fp;
- {
- int type;
- + char_u *val;
-
- type = hist_char2type(line[0]);
- if (viminfo_hisidx[type] < viminfo_hislen[type])
- {
- ! val = viminfo_readstring(line + 1, fp);
- ! if (val != NULL)
- ! {
- ! if (!in_history(type, val, viminfo_add_at_front))
- ! viminfo_history[type][viminfo_hisidx[type]++] = val;
- ! else
- ! vim_free(val);
- ! }
- }
- return vim_fgets(line, LSIZE, fp);
- }
- *** ../vim-5.4.36/src/mark.c Sun Jun 6 20:15:48 1999
- --- src/mark.c Thu Aug 19 22:18:52 1999
- ***************
- *** 758,765 ****
- str = skipwhite(str);
- namedfm[idx].mark.col = getdigits(&str);
- str = skipwhite(str);
- ! viminfo_readstring(line);
- ! namedfm_names[idx] = vim_strsave(str);
- }
- }
- return vim_fgets(line, LSIZE, fp);
- --- 758,764 ----
- str = skipwhite(str);
- namedfm[idx].mark.col = getdigits(&str);
- str = skipwhite(str);
- ! namedfm_names[idx] = viminfo_readstring(str, fp);
- }
- }
- return vim_fgets(line, LSIZE, fp);
- *** ../vim-5.4.36/src/ops.c Thu Jun 17 15:07:58 1999
- --- src/ops.c Thu Aug 19 22:19:55 1999
- ***************
- *** 3952,3959 ****
- limit *= 2;
- array = y_current->y_array;
- }
- ! viminfo_readstring(line);
- ! str = vim_strsave(line + 1);
- if (str != NULL)
- array[size++] = str;
- else
- --- 3952,3958 ----
- limit *= 2;
- array = y_current->y_array;
- }
- ! str = viminfo_readstring(line + 1, fp);
- if (str != NULL)
- array[size++] = str;
- else
- *** ../vim-5.4.36/src/search.c Fri Jul 9 11:23:18 1999
- --- src/search.c Thu Aug 19 22:44:22 1999
- ***************
- *** 3703,3708 ****
- --- 3703,3709 ----
- long off = 0;
- int setlast = FALSE;
- static int hlsearch_on = FALSE;
- + char_u *val;
-
- /*
- * Old line types:
- ***************
- *** 3752,3767 ****
- {
- if (force || spats[idx].pat == NULL)
- {
- ! viminfo_readstring(lp);
- ! set_last_search_pat(lp + 1, idx, magic, setlast);
- ! spats[idx].no_scs = no_scs;
- ! spats[idx].off.line = off_line;
- ! spats[idx].off.end = off_end;
- ! spats[idx].off.off = off;
- #ifdef EXTRA_SEARCH
- ! if (setlast)
- ! no_hlsearch = !hlsearch_on;
- #endif
- }
- }
- return vim_fgets(line, LSIZE, fp);
- --- 3753,3772 ----
- {
- if (force || spats[idx].pat == NULL)
- {
- ! val = viminfo_readstring(lp + 1, fp);
- ! if (val != NULL)
- ! {
- ! set_last_search_pat(val, idx, magic, setlast);
- ! vim_free(val);
- ! spats[idx].no_scs = no_scs;
- ! spats[idx].off.line = off_line;
- ! spats[idx].off.end = off_end;
- ! spats[idx].off.off = off;
- #ifdef EXTRA_SEARCH
- ! if (setlast)
- ! no_hlsearch = !hlsearch_on;
- #endif
- + }
- }
- }
- return vim_fgets(line, LSIZE, fp);
- *** ../vim-5.4.36/src/proto/ex_cmds.pro Sun Jul 25 13:08:13 1999
- --- src/proto/ex_cmds.pro Thu Aug 19 22:43:16 1999
- ***************
- *** 10,16 ****
- int viminfo_error __ARGS((char *message, char_u *line));
- int read_viminfo __ARGS((char_u *file, int want_info, int want_marks, int forceit));
- void write_viminfo __ARGS((char_u *file, int forceit));
- ! void viminfo_readstring __ARGS((char_u *p));
- void viminfo_writestring __ARGS((FILE *fd, char_u *p));
- void do_fixdel __ARGS((void));
- void print_line_no_prefix __ARGS((linenr_t lnum, int use_number));
- --- 10,16 ----
- int viminfo_error __ARGS((char *message, char_u *line));
- int read_viminfo __ARGS((char_u *file, int want_info, int want_marks, int forceit));
- void write_viminfo __ARGS((char_u *file, int forceit));
- ! char_u *viminfo_readstring __ARGS((char_u *p, FILE *fp));
- void viminfo_writestring __ARGS((FILE *fd, char_u *p));
- void do_fixdel __ARGS((void));
- void print_line_no_prefix __ARGS((linenr_t lnum, int use_number));
- *** ../vim-5.4.36/runtime/syntax/viminfo.vim Sun Jan 24 13:39:42 1999
- --- runtime/syntax/viminfo.vim Thu Aug 19 23:08:01 1999
- ***************
- *** 1,7 ****
- " Vim syntax file
- " Language: Vim .viminfo file
- " Maintainer: Bram Moolenaar <Bram@vim.org>
- ! " Last change: 1999 Jan 24
-
- " Remove any old syntax stuff hanging around
- syn clear
- --- 1,7 ----
- " Vim syntax file
- " Language: Vim .viminfo file
- " Maintainer: Bram Moolenaar <Bram@vim.org>
- ! " Last change: 1999 Aug 19
-
- " Remove any old syntax stuff hanging around
- syn clear
- ***************
- *** 10,16 ****
- syn match viminfoError "^[^\t].*"
-
- " The one-character one-liners that are recognized
- ! syn match viminfoStatement "^[/&$@:?=%]"
-
- " The two-character one-liners that are recognized
- syn match viminfoStatement "^['>"]."
- --- 10,16 ----
- syn match viminfoError "^[^\t].*"
-
- " The one-character one-liners that are recognized
- ! syn match viminfoStatement "^[/&$@:?=%!<]"
-
- " The two-character one-liners that are recognized
- syn match viminfoStatement "^['>"]."
- *** ../vim-5.4.36/src/version.h Thu Aug 19 12:04:33 1999
- --- src/version.h Thu Aug 19 23:14:39 1999
- ***************
- *** 19,26 ****
- #define VIM_VERSION_MINOR_STR "4"
- #define VIM_VERSION_BUILD 57
- #define VIM_VERSION_BUILD_STR "57"
- ! #define VIM_VERSION_PATCHLEVEL 36
- ! #define VIM_VERSION_PATCHLEVEL_STR "36"
-
- /*
- * VIM_VERSION_NODOT is used for the runtime directory name.
- --- 19,26 ----
- #define VIM_VERSION_MINOR_STR "4"
- #define VIM_VERSION_BUILD 57
- #define VIM_VERSION_BUILD_STR "57"
- ! #define VIM_VERSION_PATCHLEVEL 37
- ! #define VIM_VERSION_PATCHLEVEL_STR "37"
-
- /*
- * VIM_VERSION_NODOT is used for the runtime directory name.
- ***************
- *** 30,35 ****
- */
- #define VIM_VERSION_NODOT "vim54"
- #define VIM_VERSION_SHORT "5.4"
- ! #define VIM_VERSION_MEDIUM "5.4.36"
- ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.36 (1999 Aug 19)"
- ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.36 (1999 Aug 19, compiled "
- --- 30,35 ----
- */
- #define VIM_VERSION_NODOT "vim54"
- #define VIM_VERSION_SHORT "5.4"
- ! #define VIM_VERSION_MEDIUM "5.4.37"
- ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.37 (1999 Aug 19)"
- ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.37 (1999 Aug 19, compiled "
-
- --
- hundred-and-one symptoms of being an internet addict:
- 156. You forget your friend's name but not her e-mail address.
-
- --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\--
- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /
-