home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / old / 5.4.37 < prev    next >
Encoding:
Internet Message Format  |  1999-08-18  |  12.8 KB

  1. To: vim-dev@vim.org
  2. Subject: patch 5.4.37
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. A long patch for long viminfo lines...
  8.  
  9.  
  10. Patch 5.4.37
  11. Problem:    Long strings from the viminfo file are truncated.
  12. Solution:   When writing a long string to the viminfo file, first write a line
  13.         with the length, then the string itself in a second line.
  14. Files:        src/eval.c, src/ex_cmds.c, src/ex_getln.c, src/mark.c, src/ops.c,
  15.         src/search.c, src/proto/ex_cmds.pro, runtime/syntax/viminfo.vim
  16.  
  17.  
  18. *** ../vim-5.4.36/src/eval.c    Wed Aug 18 13:05:53 1999
  19. --- src/eval.c    Thu Aug 19 22:13:46 1999
  20. ***************
  21. *** 5280,5304 ****
  22.   {
  23.       char_u    *tab;
  24.       int        is_string = FALSE;
  25. !     VAR        varp;
  26.   
  27.       if (!writing && (find_viminfo_parameter('!') != NULL))
  28.       {
  29.       tab = vim_strchr(line + 1, '\t');
  30.       if (tab != NULL)
  31.       {
  32. !         *tab++ = '\0';
  33. !         if (*tab == 'S') /*string var*/
  34.           is_string = TRUE;
  35.   
  36.           tab = vim_strchr(tab, '\t');
  37.           if (tab != NULL)
  38.           {
  39. !         /* set variable */
  40.           if (is_string)
  41.           {
  42. !             viminfo_readstring(tab + 1);
  43. !             set_internal_string_var(line + 1, tab + 1);
  44.           }
  45.           else
  46.           {
  47. --- 5282,5308 ----
  48.   {
  49.       char_u    *tab;
  50.       int        is_string = FALSE;
  51. !     VAR        varp = NULL;
  52. !     char_u    *val;
  53.   
  54.       if (!writing && (find_viminfo_parameter('!') != NULL))
  55.       {
  56.       tab = vim_strchr(line + 1, '\t');
  57.       if (tab != NULL)
  58.       {
  59. !         *tab++ = '\0';    /* isolate the variable name */
  60. !         if (*tab == 'S')    /* string var */
  61.           is_string = TRUE;
  62.   
  63.           tab = vim_strchr(tab, '\t');
  64.           if (tab != NULL)
  65.           {
  66. !         /* create a nameless variable to hold the value */
  67.           if (is_string)
  68.           {
  69. !             val = viminfo_readstring(tab + 1, fp);
  70. !             if (val != NULL)
  71. !             varp = alloc_string_var(val);
  72.           }
  73.           else
  74.           {
  75. ***************
  76. *** 5306,5315 ****
  77.               if (varp != NULL)
  78.               {
  79.               varp->var_type = VAR_NUMBER;
  80. !             varp->var_val.var_number = atol((char *)tab);
  81. !             set_var(line + 1, varp);
  82. !             free_var(varp);
  83.               }
  84.           }
  85.           }
  86.       }
  87. --- 5310,5323 ----
  88.               if (varp != NULL)
  89.               {
  90.               varp->var_type = VAR_NUMBER;
  91. !             varp->var_val.var_number = atol((char *)tab + 1);
  92.               }
  93. +         }
  94. +         /* assign the value to the variable */
  95. +         if (varp != NULL)
  96. +         {
  97. +             set_var(line + 1, varp);
  98. +             free_var(varp);
  99.           }
  100.           }
  101.       }
  102. *** ../vim-5.4.36/src/ex_cmds.c    Sat Jul 24 16:19:00 1999
  103. --- src/ex_cmds.c    Thu Aug 19 23:22:51 1999
  104. ***************
  105. *** 1617,1623 ****
  106.           case '-': /* to be defined */
  107.           case '^': /* to be defined */
  108.           case '*': /* to be defined */
  109. !         case '<': /* to be defined */
  110.           /* A comment */
  111.           case NUL:
  112.           case '\r':
  113. --- 1617,1623 ----
  114.           case '-': /* to be defined */
  115.           case '^': /* to be defined */
  116.           case '*': /* to be defined */
  117. !         case '<': /* long line - ignored */
  118.           /* A comment */
  119.           case NUL:
  120.           case '\r':
  121. ***************
  122. *** 1675,1696 ****
  123.    * remove '\n' at the end of the line
  124.    * - replace CTRL-V CTRL-V with CTRL-V
  125.    * - replace CTRL-V 'n'    with '\n'
  126.    */
  127. !     void
  128. ! viminfo_readstring(p)
  129.       char_u    *p;
  130.   {
  131. !     while (*p != NUL && *p != '\n')
  132.       {
  133. !     if (*p == Ctrl('V'))
  134.       {
  135. !         if (p[1] == 'n')
  136. !         p[0] = '\n';
  137. !         mch_memmove(p + 1, p + 2, STRLEN(p));
  138.       }
  139. !     ++p;
  140.       }
  141. !     *p = NUL;
  142.   }
  143.   
  144.   /*
  145. --- 1675,1732 ----
  146.    * remove '\n' at the end of the line
  147.    * - replace CTRL-V CTRL-V with CTRL-V
  148.    * - replace CTRL-V 'n'    with '\n'
  149. +  *
  150. +  * Check for a long line as written by viminfo_writestring().
  151. +  *
  152. +  * Return the string in allocated memory (NULL when out of memory).
  153.    */
  154. !     char_u *
  155. ! viminfo_readstring(p, fp)
  156.       char_u    *p;
  157. +     FILE    *fp;
  158.   {
  159. !     char_u    *retval;
  160. !     char_u    *s, *d;
  161. !     long    len;
  162. !     if (p[0] == Ctrl('V') && isdigit(p[1]))
  163. !     {
  164. !     len = atol(p + 1);
  165. !     retval = lalloc(len, TRUE);
  166. !     if (retval == NULL)
  167. !     {
  168. !         /* Line too long?  File messed up?  Skip next line. */
  169. !         (void)vim_fgets(p, 10, fp);
  170. !         return NULL;
  171. !     }
  172. !     (void)vim_fgets(retval, (int)len, fp);
  173. !     s = retval + 1;        /* Skip the leading '<' */
  174. !     }
  175. !     else
  176. !     {
  177. !     retval = vim_strsave(p);
  178. !     if (retval == NULL)
  179. !         return NULL;
  180. !     s = retval;
  181. !     }
  182. !     /* Change CTRL-V CTRL-V to CTRL-V and CTRL-V n to \n in-place. */
  183. !     d = retval;
  184. !     while (*s != NUL && *s != '\n')
  185.       {
  186. !     if (s[0] == Ctrl('V') && s[1] != NUL)
  187.       {
  188. !         if (s[1] == 'n')
  189. !         *d++ = '\n';
  190. !         else
  191. !         *d++ = Ctrl('V');
  192. !         s += 2;
  193.       }
  194. !     else
  195. !         *d++ = *s++;
  196.       }
  197. !     *d = NUL;
  198. !     return retval;
  199.   }
  200.   
  201.   /*
  202. ***************
  203. *** 1698,1710 ****
  204.    * - replace CTRL-V with CTRL-V CTRL-V
  205.    * - replace '\n'   with CTRL-V 'n'
  206.    * - add a '\n' at the end
  207.    */
  208.       void
  209.   viminfo_writestring(fd, p)
  210. !     FILE    *fd;
  211. !     char_u  *p;
  212.   {
  213. !     int        c;
  214.   
  215.       while ((c = *p++) != NUL)
  216.       {
  217. --- 1734,1766 ----
  218.    * - replace CTRL-V with CTRL-V CTRL-V
  219.    * - replace '\n'   with CTRL-V 'n'
  220.    * - add a '\n' at the end
  221. +  *
  222. +  * For a long line:
  223. +  * - write " CTRL-V <length> \n " in first line
  224. +  * - write " < <string> \n "      in second line
  225.    */
  226.       void
  227.   viminfo_writestring(fd, p)
  228. !     FILE    *fd;
  229. !     char_u    *p;
  230.   {
  231. !     int        c;
  232. !     char_u    *s;
  233. !     int        len = 0;
  234. !     for (s = p; *s != NUL; ++s)
  235. !     {
  236. !     if (*s == Ctrl('V') || *s == '\n')
  237. !         ++len;
  238. !     ++len;
  239. !     }
  240. !     /* If the string will be too long, write its length and put it in the next
  241. !      * line.  Take into account that some room is needed for what comes before
  242. !      * the string (e.g., variable name).  Add something to the length for the
  243. !      * '<', NL and trailing NUL. */
  244. !     if (len > LSIZE / 2)
  245. !     fprintf(fd, "\026%d\n<", len + 3);
  246.   
  247.       while ((c = *p++) != NUL)
  248.       {
  249. ***************
  250. *** 3633,3642 ****
  251.       if (old_sub != NULL && force)
  252.       vim_free(old_sub);
  253.       if (force || old_sub == NULL)
  254. !     {
  255. !     viminfo_readstring(line);
  256. !     old_sub = vim_strsave(line + 1);
  257. !     }
  258.       return vim_fgets(line, LSIZE, fp);
  259.   }
  260.   
  261. --- 3689,3695 ----
  262.       if (old_sub != NULL && force)
  263.       vim_free(old_sub);
  264.       if (force || old_sub == NULL)
  265. !     old_sub = viminfo_readstring(line + 1, fp);
  266.       return vim_fgets(line, LSIZE, fp);
  267.   }
  268.   
  269. *** ../vim-5.4.36/src/ex_getln.c    Tue Aug 10 16:10:35 1999
  270. --- src/ex_getln.c    Thu Aug 19 22:17:52 1999
  271. ***************
  272. *** 3549,3562 ****
  273.       FILE    *fp;
  274.   {
  275.       int        type;
  276.   
  277.       type = hist_char2type(line[0]);
  278.       if (viminfo_hisidx[type] < viminfo_hislen[type])
  279.       {
  280. !     viminfo_readstring(line);
  281. !     if (!in_history(type, line + 1, viminfo_add_at_front))
  282. !         viminfo_history[type][viminfo_hisidx[type]++] =
  283. !                             vim_strsave(line + 1);
  284.       }
  285.       return vim_fgets(line, LSIZE, fp);
  286.   }
  287. --- 3549,3567 ----
  288.       FILE    *fp;
  289.   {
  290.       int        type;
  291. +     char_u  *val;
  292.   
  293.       type = hist_char2type(line[0]);
  294.       if (viminfo_hisidx[type] < viminfo_hislen[type])
  295.       {
  296. !     val = viminfo_readstring(line + 1, fp);
  297. !     if (val != NULL)
  298. !     {
  299. !         if (!in_history(type, val, viminfo_add_at_front))
  300. !         viminfo_history[type][viminfo_hisidx[type]++] = val;
  301. !         else
  302. !         vim_free(val);
  303. !     }
  304.       }
  305.       return vim_fgets(line, LSIZE, fp);
  306.   }
  307. *** ../vim-5.4.36/src/mark.c    Sun Jun  6 20:15:48 1999
  308. --- src/mark.c    Thu Aug 19 22:18:52 1999
  309. ***************
  310. *** 758,765 ****
  311.           str = skipwhite(str);
  312.           namedfm[idx].mark.col = getdigits(&str);
  313.           str = skipwhite(str);
  314. !         viminfo_readstring(line);
  315. !         namedfm_names[idx] = vim_strsave(str);
  316.       }
  317.       }
  318.       return vim_fgets(line, LSIZE, fp);
  319. --- 758,764 ----
  320.           str = skipwhite(str);
  321.           namedfm[idx].mark.col = getdigits(&str);
  322.           str = skipwhite(str);
  323. !         namedfm_names[idx] = viminfo_readstring(str, fp);
  324.       }
  325.       }
  326.       return vim_fgets(line, LSIZE, fp);
  327. *** ../vim-5.4.36/src/ops.c    Thu Jun 17 15:07:58 1999
  328. --- src/ops.c    Thu Aug 19 22:19:55 1999
  329. ***************
  330. *** 3952,3959 ****
  331.           limit *= 2;
  332.           array = y_current->y_array;
  333.           }
  334. !         viminfo_readstring(line);
  335. !         str = vim_strsave(line + 1);
  336.           if (str != NULL)
  337.           array[size++] = str;
  338.           else
  339. --- 3952,3958 ----
  340.           limit *= 2;
  341.           array = y_current->y_array;
  342.           }
  343. !         str = viminfo_readstring(line + 1, fp);
  344.           if (str != NULL)
  345.           array[size++] = str;
  346.           else
  347. *** ../vim-5.4.36/src/search.c    Fri Jul  9 11:23:18 1999
  348. --- src/search.c    Thu Aug 19 22:44:22 1999
  349. ***************
  350. *** 3703,3708 ****
  351. --- 3703,3709 ----
  352.       long    off = 0;
  353.       int        setlast = FALSE;
  354.       static int    hlsearch_on = FALSE;
  355. +     char_u    *val;
  356.   
  357.       /*
  358.        * Old line types:
  359. ***************
  360. *** 3752,3767 ****
  361.       {
  362.       if (force || spats[idx].pat == NULL)
  363.       {
  364. !         viminfo_readstring(lp);
  365. !         set_last_search_pat(lp + 1, idx, magic, setlast);
  366. !         spats[idx].no_scs = no_scs;
  367. !         spats[idx].off.line = off_line;
  368. !         spats[idx].off.end = off_end;
  369. !         spats[idx].off.off = off;
  370.   #ifdef EXTRA_SEARCH
  371. !         if (setlast)
  372. !         no_hlsearch = !hlsearch_on;
  373.   #endif
  374.       }
  375.       }
  376.       return vim_fgets(line, LSIZE, fp);
  377. --- 3753,3772 ----
  378.       {
  379.       if (force || spats[idx].pat == NULL)
  380.       {
  381. !         val = viminfo_readstring(lp + 1, fp);
  382. !         if (val != NULL)
  383. !         {
  384. !         set_last_search_pat(val, idx, magic, setlast);
  385. !         vim_free(val);
  386. !         spats[idx].no_scs = no_scs;
  387. !         spats[idx].off.line = off_line;
  388. !         spats[idx].off.end = off_end;
  389. !         spats[idx].off.off = off;
  390.   #ifdef EXTRA_SEARCH
  391. !         if (setlast)
  392. !             no_hlsearch = !hlsearch_on;
  393.   #endif
  394. +         }
  395.       }
  396.       }
  397.       return vim_fgets(line, LSIZE, fp);
  398. *** ../vim-5.4.36/src/proto/ex_cmds.pro    Sun Jul 25 13:08:13 1999
  399. --- src/proto/ex_cmds.pro    Thu Aug 19 22:43:16 1999
  400. ***************
  401. *** 10,16 ****
  402.   int viminfo_error __ARGS((char *message, char_u *line));
  403.   int read_viminfo __ARGS((char_u *file, int want_info, int want_marks, int forceit));
  404.   void write_viminfo __ARGS((char_u *file, int forceit));
  405. ! void viminfo_readstring __ARGS((char_u *p));
  406.   void viminfo_writestring __ARGS((FILE *fd, char_u *p));
  407.   void do_fixdel __ARGS((void));
  408.   void print_line_no_prefix __ARGS((linenr_t lnum, int use_number));
  409. --- 10,16 ----
  410.   int viminfo_error __ARGS((char *message, char_u *line));
  411.   int read_viminfo __ARGS((char_u *file, int want_info, int want_marks, int forceit));
  412.   void write_viminfo __ARGS((char_u *file, int forceit));
  413. ! char_u *viminfo_readstring __ARGS((char_u *p, FILE *fp));
  414.   void viminfo_writestring __ARGS((FILE *fd, char_u *p));
  415.   void do_fixdel __ARGS((void));
  416.   void print_line_no_prefix __ARGS((linenr_t lnum, int use_number));
  417. *** ../vim-5.4.36/runtime/syntax/viminfo.vim    Sun Jan 24 13:39:42 1999
  418. --- runtime/syntax/viminfo.vim    Thu Aug 19 23:08:01 1999
  419. ***************
  420. *** 1,7 ****
  421.   " Vim syntax file
  422.   " Language:    Vim .viminfo file
  423.   " Maintainer:    Bram Moolenaar <Bram@vim.org>
  424. ! " Last change:    1999 Jan 24
  425.   
  426.   " Remove any old syntax stuff hanging around
  427.   syn clear
  428. --- 1,7 ----
  429.   " Vim syntax file
  430.   " Language:    Vim .viminfo file
  431.   " Maintainer:    Bram Moolenaar <Bram@vim.org>
  432. ! " Last change:    1999 Aug 19
  433.   
  434.   " Remove any old syntax stuff hanging around
  435.   syn clear
  436. ***************
  437. *** 10,16 ****
  438.   syn match viminfoError "^[^\t].*"
  439.   
  440.   " The one-character one-liners that are recognized
  441. ! syn match viminfoStatement "^[/&$@:?=%]"
  442.   
  443.   " The two-character one-liners that are recognized
  444.   syn match viminfoStatement "^['>"]."
  445. --- 10,16 ----
  446.   syn match viminfoError "^[^\t].*"
  447.   
  448.   " The one-character one-liners that are recognized
  449. ! syn match viminfoStatement "^[/&$@:?=%!<]"
  450.   
  451.   " The two-character one-liners that are recognized
  452.   syn match viminfoStatement "^['>"]."
  453. *** ../vim-5.4.36/src/version.h    Thu Aug 19 12:04:33 1999
  454. --- src/version.h    Thu Aug 19 23:14:39 1999
  455. ***************
  456. *** 19,26 ****
  457.   #define VIM_VERSION_MINOR_STR        "4"
  458.   #define VIM_VERSION_BUILD         57
  459.   #define VIM_VERSION_BUILD_STR        "57"
  460. ! #define VIM_VERSION_PATCHLEVEL         36
  461. ! #define VIM_VERSION_PATCHLEVEL_STR    "36"
  462.   
  463.   /*
  464.    * VIM_VERSION_NODOT is used for the runtime directory name.
  465. --- 19,26 ----
  466.   #define VIM_VERSION_MINOR_STR        "4"
  467.   #define VIM_VERSION_BUILD         57
  468.   #define VIM_VERSION_BUILD_STR        "57"
  469. ! #define VIM_VERSION_PATCHLEVEL         37
  470. ! #define VIM_VERSION_PATCHLEVEL_STR    "37"
  471.   
  472.   /*
  473.    * VIM_VERSION_NODOT is used for the runtime directory name.
  474. ***************
  475. *** 30,35 ****
  476.    */
  477.   #define VIM_VERSION_NODOT    "vim54"
  478.   #define VIM_VERSION_SHORT    "5.4"
  479. ! #define VIM_VERSION_MEDIUM    "5.4.36"
  480. ! #define VIM_VERSION_LONG    "VIM - Vi IMproved 5.4.36 (1999 Aug 19)"
  481. ! #define VIM_VERSION_LONG_DATE    "VIM - Vi IMproved 5.4.36 (1999 Aug 19, compiled "
  482. --- 30,35 ----
  483.    */
  484.   #define VIM_VERSION_NODOT    "vim54"
  485.   #define VIM_VERSION_SHORT    "5.4"
  486. ! #define VIM_VERSION_MEDIUM    "5.4.37"
  487. ! #define VIM_VERSION_LONG    "VIM - Vi IMproved 5.4.37 (1999 Aug 19)"
  488. ! #define VIM_VERSION_LONG_DATE    "VIM - Vi IMproved 5.4.37 (1999 Aug 19, compiled "
  489.  
  490. --
  491. hundred-and-one symptoms of being an internet addict:
  492. 156. You forget your friend's name but not her e-mail address.
  493.  
  494. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\--
  495.   \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /
  496.