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.6.067 < prev    next >
Encoding:
Internet Message Format  |  2000-04-14  |  9.3 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6.067
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6.067
  8. Problem:    When a file name contains a NL, the viminfo file is corrupted.
  9. Solution:   Use viminfo_writestring() to convert the NL to CTRL-V n.
  10.         Also fix the Buffers menu and listing a menu name with a newline.
  11. Files:        runtime/menu.vim, src/buffer.c, src/mark.c, src/menu.c
  12.  
  13.  
  14. *** ../vim-5.6.66/runtime/menu.vim    Wed Jan 12 20:53:26 2000
  15. --- runtime/menu.vim    Sat Apr 15 17:56:11 2000
  16. ***************
  17. *** 3,9 ****
  18.   " Note that ":amenu" is often used to make a menu work in all modes.
  19.   "
  20.   " Maintainer:    Bram Moolenaar <Bram@vim.org>
  21. ! " Last change:    2000 Jan 02
  22.   
  23.   " Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise
  24.   " <CR> would not be recognized.  See ":help 'cpoptions'".
  25. --- 3,9 ----
  26.   " Note that ":amenu" is often used to make a menu work in all modes.
  27.   "
  28.   " Maintainer:    Bram Moolenaar <Bram@vim.org>
  29. ! " Last change:    2000 Apr 15
  30.   
  31.   " Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise
  32.   " <CR> would not be recognized.  See ":help 'cpoptions'".
  33. ***************
  34. *** 69,75 ****
  35.   if has("win32")
  36.     vmenu 20.390 &Edit.&Delete<Tab>x        x
  37.   endif
  38. ! amenu 20.400 &Edit.&Select\ all<Tab>ggvG    :if &slm != ""<Bar>exe ":norm gggH<C-O>G"<Bar>else<Bar>exe ":norm ggVG"<Bar>endif<CR>
  39.   amenu 20.405 &Edit.-SEP2-            :
  40.   if has("win32") || has("gui_gtk")
  41.     amenu 20.410 &Edit.&Find\.\.\.        :promptfind<CR>
  42. --- 69,75 ----
  43.   if has("win32")
  44.     vmenu 20.390 &Edit.&Delete<Tab>x        x
  45.   endif
  46. ! amenu 20.400 &Edit.&Select\ all<Tab>ggVG    :if &slm != ""<Bar>exe ":norm gggH<C-O>G"<Bar>else<Bar>exe ":norm ggVG"<Bar>endif<CR>
  47.   amenu 20.405 &Edit.-SEP2-            :
  48.   if has("win32") || has("gui_gtk")
  49.     amenu 20.410 &Edit.&Find\.\.\.        :promptfind<CR>
  50. ***************
  51. *** 246,252 ****
  52.       endif
  53.       let name = name2 . "\t" . fnamemodify(name,':h')
  54.       endif
  55. !     let name = escape(name, '\\.     |')
  56.       return name
  57.   endfunc
  58.   
  59. --- 246,253 ----
  60.       endif
  61.       let name = name2 . "\t" . fnamemodify(name,':h')
  62.       endif
  63. !     let name = escape(name, "\\. \t|")
  64. !     let name = substitute(name, "\n", "^@", "g")
  65.       return name
  66.   endfunc
  67.   
  68. *** ../vim-5.6.66/src/buffer.c    Tue Apr  4 20:49:34 2000
  69. --- src/buffer.c    Sat Apr 15 17:39:00 2000
  70. ***************
  71. *** 2607,2626 ****
  72.       colnr_t    col;
  73.       BUF        *buf;
  74.       char_u    *sfname;
  75.   
  76.       /* don't read in if there are files on the command-line or if writing: */
  77. !     if (!writing && arg_file_count == 0 && find_viminfo_parameter('%') != NULL)
  78.       {
  79.       /* Format is: <fname> Tab <lnum> Tab <col>.
  80.        * Watch out for a Tab in the file name, work from the end. */
  81.       lnum = 0;
  82.       col = 0;
  83. !     tab = vim_strrchr(line + 1, '\t');
  84.       if (tab != NULL)
  85.       {
  86.           *tab++ = '\0';
  87.           col = atoi((char *)tab);
  88. !         tab = vim_strrchr(line + 1, '\t');
  89.           if (tab != NULL)
  90.           {
  91.           *tab++ = '\0';
  92. --- 2607,2631 ----
  93.       colnr_t    col;
  94.       BUF        *buf;
  95.       char_u    *sfname;
  96. +     char_u    *xline;
  97. +     /* Handle long line and escaped characters. */
  98. +     xline = viminfo_readstring(line + 1, fp);
  99.   
  100.       /* don't read in if there are files on the command-line or if writing: */
  101. !     if (xline != NULL && !writing && arg_file_count == 0
  102. !                        && find_viminfo_parameter('%') != NULL)
  103.       {
  104.       /* Format is: <fname> Tab <lnum> Tab <col>.
  105.        * Watch out for a Tab in the file name, work from the end. */
  106.       lnum = 0;
  107.       col = 0;
  108. !     tab = vim_strrchr(xline, '\t');
  109.       if (tab != NULL)
  110.       {
  111.           *tab++ = '\0';
  112.           col = atoi((char *)tab);
  113. !         tab = vim_strrchr(xline, '\t');
  114.           if (tab != NULL)
  115.           {
  116.           *tab++ = '\0';
  117. ***************
  118. *** 2630,2636 ****
  119.   
  120.       /* Expand "~/" in the file name at "line + 1" to a full path.
  121.        * Then try shortening it by comparing with the current directory */
  122. !     expand_env(line + 1, NameBuff, MAXPATHL);
  123.       mch_dirname(IObuff, IOSIZE);
  124.       sfname = shorten_fname(NameBuff, IObuff);
  125.       if (sfname == NULL)
  126. --- 2635,2641 ----
  127.   
  128.       /* Expand "~/" in the file name at "line + 1" to a full path.
  129.        * Then try shortening it by comparing with the current directory */
  130. !     expand_env(xline, NameBuff, MAXPATHL);
  131.       mch_dirname(IObuff, IOSIZE);
  132.       sfname = shorten_fname(NameBuff, IObuff);
  133.       if (sfname == NULL)
  134. ***************
  135. *** 2644,2649 ****
  136. --- 2649,2655 ----
  137.           buflist_setfpos(buf, lnum, col);
  138.       }
  139.       }
  140. +     vim_free(xline);
  141.   
  142.       return vim_fgets(line, LSIZE, fp);
  143.   }
  144. ***************
  145. *** 2654,2663 ****
  146. --- 2660,2675 ----
  147.   {
  148.       BUF        *buf;
  149.       WIN        *win;
  150. +     char_u    *line;
  151.   
  152.       if (find_viminfo_parameter('%') == NULL)
  153.       return;
  154.   
  155. +     /* Allocate room for the file name, lnum and col. */
  156. +     line = alloc(MAXPATHL + 30);
  157. +     if (line == NULL)
  158. +     return;
  159.       for (win = firstwin; win != NULL; win = win->w_next)
  160.       set_last_cursor(win);
  161.   
  162. ***************
  163. *** 2667,2677 ****
  164.       if (buf->b_fname == NULL || buf->b_help || removable(buf->b_ffname))
  165.           continue;
  166.   
  167. !     home_replace(NULL, buf->b_ffname, NameBuff, MAXPATHL, TRUE);
  168. !     fprintf(fp, "%%%s\t%ld\t%d\n", NameBuff,
  169.               (long)buf->b_last_cursor.lnum,
  170.               buf->b_last_cursor.col);
  171.       }
  172.   }
  173.   #endif
  174. --- 2679,2690 ----
  175.       if (buf->b_fname == NULL || buf->b_help || removable(buf->b_ffname))
  176.           continue;
  177.   
  178. !     putc('%', fp);
  179. !     home_replace(NULL, buf->b_ffname, line, MAXPATHL, TRUE);
  180. !     sprintf(line + STRLEN(line), "\t%ld\t%d",
  181.               (long)buf->b_last_cursor.lnum,
  182.               buf->b_last_cursor.col);
  183. +     viminfo_writestring(fp, line);
  184.       }
  185.   }
  186.   #endif
  187. *** ../vim-5.6.66/src/mark.c    Thu Aug 19 22:18:52 1999
  188. --- src/mark.c    Sat Apr 15 17:38:44 2000
  189. ***************
  190. *** 817,827 ****
  191.       if (name == NULL)
  192.           continue;
  193.   
  194. !     fprintf(fp, "'%c  %ld  %ld  %s\n",
  195.               i < NMARKS ? i + 'A' : i - NMARKS + '0',
  196.               (long)namedfm[i].mark.lnum,
  197. !             (long)namedfm[i].mark.col,
  198. !             name);
  199.       if (namedfm[i].fnum)
  200.           vim_free(name);
  201.       }
  202. --- 817,827 ----
  203.       if (name == NULL)
  204.           continue;
  205.   
  206. !     fprintf(fp, "'%c  %ld  %ld  ",
  207.               i < NMARKS ? i + 'A' : i - NMARKS + '0',
  208.               (long)namedfm[i].mark.lnum,
  209. !             (long)namedfm[i].mark.col);
  210. !     viminfo_writestring(fp, name);
  211.       if (namedfm[i].fnum)
  212.           vim_free(name);
  213.       }
  214. ***************
  215. *** 902,908 ****
  216.            buf->b_ffname[0] != NUL && !removable(buf->b_ffname))
  217.           {
  218.           home_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE);
  219. !         fprintf(fp_out, "\n> %s\n", (char *)IObuff);
  220.           if (buf->b_last_cursor.lnum != 0)
  221.               fprintf(fp_out, "\t\"\t%ld\t%d\n",
  222.                   buf->b_last_cursor.lnum, buf->b_last_cursor.col);
  223. --- 902,909 ----
  224.            buf->b_ffname[0] != NUL && !removable(buf->b_ffname))
  225.           {
  226.           home_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE);
  227. !         fprintf(fp_out, "\n> ");
  228. !         viminfo_writestring(fp_out, IObuff);
  229.           if (buf->b_last_cursor.lnum != 0)
  230.               fprintf(fp_out, "\t\"\t%ld\t%d\n",
  231.                   buf->b_last_cursor.lnum, buf->b_last_cursor.col);
  232. ***************
  233. *** 933,939 ****
  234.   {
  235.       BUF        *buf;
  236.       int        num_marked_files;
  237. -     char_u    save_char;
  238.       int        load_marks;
  239.       int        copy_marks_out;
  240.       char_u    *str;
  241. --- 934,939 ----
  242. ***************
  243. *** 960,975 ****
  244.       }
  245.   
  246.       /*
  247.        * Find file name, set str to start.
  248.        * Ignore leading and trailing white space.
  249.        */
  250.       str = skipwhite(line + 1);
  251.       p = str + STRLEN(str);
  252.       while (p != str && (*p == NUL || vim_isspace(*p)))
  253.           p--;
  254.       if (*p)
  255.           p++;
  256. -     save_char = *p;
  257.       *p = NUL;
  258.   
  259.       /*
  260. --- 960,978 ----
  261.       }
  262.   
  263.       /*
  264. +      * Handle long line and translate escaped characters.
  265.        * Find file name, set str to start.
  266.        * Ignore leading and trailing white space.
  267.        */
  268.       str = skipwhite(line + 1);
  269. +     str = viminfo_readstring(str, fp_in);
  270. +     if (str == NULL)
  271. +         continue;
  272.       p = str + STRLEN(str);
  273.       while (p != str && (*p == NUL || vim_isspace(*p)))
  274.           p--;
  275.       if (*p)
  276.           p++;
  277.       *p = NUL;
  278.   
  279.       /*
  280. ***************
  281. *** 1003,1014 ****
  282.           if (buf == NULL || !buf->b_marks_read)
  283.           {
  284.           copy_marks_out = TRUE;
  285. !         *p = save_char;
  286. !         fputs("\n", fp_out);
  287. !         fputs((char *)line, fp_out);
  288.           count++;
  289.           }
  290.       }
  291.       while (!(eof = vim_fgets(line, LSIZE, fp_in)) && line[0] == TAB)
  292.       {
  293.           if (load_marks)
  294. --- 1006,1018 ----
  295.           if (buf == NULL || !buf->b_marks_read)
  296.           {
  297.           copy_marks_out = TRUE;
  298. !         fputs("\n> ", fp_out);
  299. !         viminfo_writestring(fp_out, str);
  300.           count++;
  301.           }
  302.       }
  303. +     vim_free(str);
  304.       while (!(eof = vim_fgets(line, LSIZE, fp_in)) && line[0] == TAB)
  305.       {
  306.           if (load_marks)
  307. *** ../vim-5.6.66/src/menu.c    Sun Jan 16 16:32:33 2000
  308. --- src/menu.c    Sat Apr 15 17:51:40 2000
  309. ***************
  310. *** 761,767 ****
  311.           MSG_PUTS(" ");
  312.       }
  313.                   /* Same highlighting as for directories!? */
  314. !     msg_puts_attr(menu->name, hl_attr(HLF_D));
  315.       }
  316.   
  317.       if (menu != NULL && menu->children == NULL)
  318. --- 764,770 ----
  319.           MSG_PUTS(" ");
  320.       }
  321.                   /* Same highlighting as for directories!? */
  322. !     msg_outtrans_attr(menu->name, hl_attr(HLF_D));
  323.       }
  324.   
  325.       if (menu != NULL && menu->children == NULL)
  326. *** ../vim-5.6.66/src/version.c    Thu Apr 13 12:02:05 2000
  327. --- src/version.c    Sat Apr 15 17:58:59 2000
  328. ***************
  329. *** 420,421 ****
  330. --- 420,423 ----
  331.   {   /* Add new patch number below this line */
  332. + /**/
  333. +     67,
  334.   /**/
  335.  
  336. -- 
  337. hundred-and-one symptoms of being an internet addict:
  338. 54. You start tilting your head sideways to smile.
  339.  
  340. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
  341. \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
  342.