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 / 6.2.420 < prev    next >
Encoding:
Internet Message Format  |  2004-03-29  |  10.1 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.420
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.2.420
  11. Problem:    Cannot specify a file to be edited in binary mode without setting
  12.         the global value of the 'binary' option.
  13. Solution:   Support ":edit ++bin file".
  14. Files:        runtime/doc/editing.txt, src/buffer.c, src/eval.c, src/ex_cmds.h,
  15.         src/ex_docmd.c, src/fileio.c, src/misc2.c
  16.  
  17.  
  18. *** ../vim-6.2.419/runtime/doc/editing.txt    Sun Jun  1 12:20:31 2003
  19. --- runtime/doc/editing.txt    Tue Mar 30 20:55:09 2004
  20. ***************
  21. *** 1,4 ****
  22. ! *editing.txt*   For Vim version 6.2.  Last change: 2003 May 04
  23.   
  24.   
  25.             VIM REFERENCE MANUAL    by Bram Moolenaar
  26. --- 1,4 ----
  27. ! *editing.txt*   For Vim version 6.2.  Last change: 2004 Mar 30
  28.   
  29.   
  30.             VIM REFERENCE MANUAL    by Bram Moolenaar
  31. ***************
  32. *** 345,353 ****
  33.   'fileencoding' to a value for one command.  The form is: >
  34.       ++{optname}={value}
  35.   
  36. ! Where {optname} is one of:                *++ff* *++enc*
  37. !     ff  or  fileformat        overrides 'fileformat'
  38. !     enc  or  encoding        overrides 'fileencoding'
  39.   
  40.   {value} cannot contain white space.  It can be any valid value for these
  41.   options.  Examples: >
  42. --- 349,359 ----
  43.   'fileencoding' to a value for one command.  The form is: >
  44.       ++{optname}={value}
  45.   
  46. ! Where {optname} is one of:        *++ff* *++enc* *++bin* *++nobin*
  47. !     ff     or  fileformat   overrides 'fileformat'
  48. !     enc    or  encoding        overrides 'fileencoding'
  49. !     bin    or  binary        sets 'binary'
  50. !     nobin  or  nobinary        resets 'binary'
  51.   
  52.   {value} cannot contain white space.  It can be any valid value for these
  53.   options.  Examples: >
  54. ***************
  55. *** 359,365 ****
  56.   
  57.   Note that when reading, the 'fileformat' and 'fileencoding' options will be
  58.   set to the used format.  When writing this doesn't happen, thus a next write
  59. ! will use the old value of the option.
  60.   
  61.   There may be several ++opt arguments, separated by white space.  They must all
  62.   appear before any |+cmd| argument.
  63. --- 365,371 ----
  64.   
  65.   Note that when reading, the 'fileformat' and 'fileencoding' options will be
  66.   set to the used format.  When writing this doesn't happen, thus a next write
  67. ! will use the old value of the option.  Same for the 'binary' option.
  68.   
  69.   There may be several ++opt arguments, separated by white space.  They must all
  70.   appear before any |+cmd| argument.
  71. *** ../vim-6.2.419/src/buffer.c    Thu Mar 25 19:27:28 2004
  72. --- src/buffer.c    Tue Mar 30 21:05:55 2004
  73. ***************
  74. *** 150,156 ****
  75.        */
  76.       curbuf->b_p_bin = TRUE;
  77.       retval = readfile(NULL, NULL, (linenr_T)0,
  78. !           (linenr_T)0, (linenr_T)MAXLNUM, eap, READ_NEW + READ_STDIN);
  79.       curbuf->b_p_bin = save_bin;
  80.       if (retval == OK)
  81.       {
  82. --- 150,156 ----
  83.        */
  84.       curbuf->b_p_bin = TRUE;
  85.       retval = readfile(NULL, NULL, (linenr_T)0,
  86. !           (linenr_T)0, (linenr_T)MAXLNUM, NULL, READ_NEW + READ_STDIN);
  87.       curbuf->b_p_bin = save_bin;
  88.       if (retval == OK)
  89.       {
  90. *** ../vim-6.2.419/src/eval.c    Tue Mar 30 21:47:08 2004
  91. --- src/eval.c    Tue Mar 30 20:27:02 2004
  92. ***************
  93. *** 7887,7907 ****
  94.       oldval = vimvars[VV_CMDARG].val;
  95.       if (eap != NULL)
  96.       {
  97. !     if (eap->force_ff != 0)
  98. !         len = (unsigned)STRLEN(eap->cmd + eap->force_ff) + 6;
  99.       else
  100.           len = 0;
  101.   # ifdef FEAT_MBYTE
  102.       if (eap->force_enc != 0)
  103.           len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
  104.   # endif
  105.       newval = alloc(len + 1);
  106.       if (newval == NULL)
  107.           return NULL;
  108. !     if (eap->force_ff != 0)
  109. !         sprintf((char *)newval, " ++ff=%s", eap->cmd + eap->force_ff);
  110.       else
  111.           *newval = NUL;
  112.   # ifdef FEAT_MBYTE
  113.       if (eap->force_enc != 0)
  114.           sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
  115. --- 7887,7918 ----
  116.       oldval = vimvars[VV_CMDARG].val;
  117.       if (eap != NULL)
  118.       {
  119. !     if (eap->force_bin == FORCE_BIN)
  120. !         len = 6;
  121. !     else if (eap->force_bin == FORCE_NOBIN)
  122. !         len = 8;
  123.       else
  124.           len = 0;
  125. +     if (eap->force_ff != 0)
  126. +         len += (unsigned)STRLEN(eap->cmd + eap->force_ff) + 6;
  127.   # ifdef FEAT_MBYTE
  128.       if (eap->force_enc != 0)
  129.           len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
  130.   # endif
  131.       newval = alloc(len + 1);
  132.       if (newval == NULL)
  133.           return NULL;
  134. !     if (eap->force_bin == FORCE_BIN)
  135. !         sprintf((char *)newval, " ++bin");
  136. !     else if (eap->force_bin == FORCE_NOBIN)
  137. !         sprintf((char *)newval, " ++nobin");
  138.       else
  139.           *newval = NUL;
  140. +     if (eap->force_ff != 0)
  141. +         sprintf((char *)newval + STRLEN(newval), " ++ff=%s",
  142. +                             eap->cmd + eap->force_ff);
  143.   # ifdef FEAT_MBYTE
  144.       if (eap->force_enc != 0)
  145.           sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
  146. *** ../vim-6.2.419/src/ex_cmds.h    Sat Mar 13 14:28:50 2004
  147. --- src/ex_cmds.h    Tue Mar 30 20:20:53 2004
  148. ***************
  149. *** 939,944 ****
  150. --- 939,945 ----
  151.       int        usefilter;    /* TRUE with ":w !command" and ":r!command" */
  152.       int        amount;        /* number of '>' or '<' for shift command */
  153.       int        regname;    /* register name (NUL if none) */
  154. +     int        force_bin;    /* 0, FORCE_BIN or FORCE_NOBIN */
  155.       int        force_ff;    /* forced 'fileformat' (index in cmd[]) */
  156.   #ifdef FEAT_MBYTE
  157.       int        force_enc;    /* forced 'encoding' (index in cmd[]) */
  158. ***************
  159. *** 953,956 ****
  160. --- 954,961 ----
  161.       struct condstack *cstack;    /* condition stack for ":if" etc. */
  162.   #endif
  163.   };
  164. + #define FORCE_BIN 1        /* ":edit ++bin file" */
  165. + #define FORCE_NOBIN 2        /* ":edit ++nobin file" */
  166.   #endif
  167. *** ../vim-6.2.419/src/ex_docmd.c    Tue Mar 30 21:47:08 2004
  168. --- src/ex_docmd.c    Tue Mar 30 20:28:50 2004
  169. ***************
  170. *** 4220,4225 ****
  171. --- 4218,4239 ----
  172.       char_u    *p;
  173.   #endif
  174.   
  175. +     /* ":edit ++[no]bin[ary] file" */
  176. +     if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0)
  177. +     {
  178. +     if (*arg == 'n')
  179. +     {
  180. +         arg += 2;
  181. +         eap->force_bin = FORCE_NOBIN;
  182. +     }
  183. +     else
  184. +         eap->force_bin = FORCE_BIN;
  185. +     if (!checkforcmd(&arg, "binary", 3))
  186. +         return FAIL;
  187. +     eap->arg = skipwhite(arg);
  188. +     return OK;
  189. +     }
  190.       if (STRNCMP(arg, "ff", 2) == 0)
  191.       {
  192.       arg += 2;
  193. ***************
  194. *** 6057,6070 ****
  195.        * Move to the first file.
  196.        */
  197.       /* Fake up a minimal "next" command for do_argfile() */
  198.       ea.cmd = (char_u *)"next";
  199. -     ea.forceit = FALSE;
  200. -     ea.do_ecmd_cmd = NULL;
  201. -     ea.do_ecmd_lnum = 0;
  202. -     ea.force_ff = 0;
  203. - # ifdef FEAT_MBYTE
  204. -     ea.force_enc = 0;
  205. - # endif
  206.       do_argfile(&ea, 0);
  207.   
  208.       /* do_ecmd() may set need_start_insertmode, but since we never left Insert
  209. --- 6071,6078 ----
  210.        * Move to the first file.
  211.        */
  212.       /* Fake up a minimal "next" command for do_argfile() */
  213. +     vim_memset(&ea, 0, sizeof(ea));
  214.       ea.cmd = (char_u *)"next";
  215.       do_argfile(&ea, 0);
  216.   
  217.       /* do_ecmd() may set need_start_insertmode, but since we never left Insert
  218. *** ../vim-6.2.419/src/fileio.c    Sat Mar 20 21:21:41 2004
  219. --- src/fileio.c    Tue Mar 30 21:12:07 2004
  220. ***************
  221. *** 409,414 ****
  222. --- 409,423 ----
  223.           set_fileformat(default_fileformat(), OPT_LOCAL);
  224.       }
  225.   
  226. +     /* set or reset 'binary' */
  227. +     if (eap != NULL && eap->force_bin != 0)
  228. +     {
  229. +     int    oldval = curbuf->b_p_bin;
  230. +     curbuf->b_p_bin = (eap->force_bin == FORCE_BIN);
  231. +     set_options_bin(oldval, curbuf->b_p_bin, OPT_LOCAL);
  232. +     }
  233.       /*
  234.        * When opening a new file we take the readonly flag from the file.
  235.        * Default is r/w, can be set to r/o below.
  236. ***************
  237. *** 2420,2425 ****
  238. --- 2429,2435 ----
  239.   #endif
  240.       int            attr;
  241.       int            fileformat;
  242. +     int            write_bin;
  243.       struct bw_info  write_info;        /* info for buf_write_bytes() */
  244.   #ifdef FEAT_MBYTE
  245.       int            converted = FALSE;
  246. ***************
  247. *** 3593,3603 ****
  248.       write_info.bw_buf = buffer;
  249.       nchars = 0;
  250.   
  251.   #ifdef FEAT_MBYTE
  252.       /*
  253.        * The BOM is written just after the encryption magic number.
  254.        */
  255. !     if (buf->b_p_bomb && !buf->b_p_bin)
  256.       {
  257.       write_info.bw_len = make_bom(buffer, fenc);
  258.       if (write_info.bw_len > 0)
  259. --- 3603,3619 ----
  260.       write_info.bw_buf = buffer;
  261.       nchars = 0;
  262.   
  263. +     /* use "++bin", "++nobin" or 'binary' */
  264. +     if (eap != NULL && eap->force_bin != 0)
  265. +     write_bin = (eap->force_bin == FORCE_BIN);
  266. +     else
  267. +     write_bin = buf->b_p_bin;
  268.   #ifdef FEAT_MBYTE
  269.       /*
  270.        * The BOM is written just after the encryption magic number.
  271.        */
  272. !     if (buf->b_p_bomb && !write_bin)
  273.       {
  274.       write_info.bw_len = make_bom(buffer, fenc);
  275.       if (write_info.bw_len > 0)
  276. ***************
  277. *** 3649,3655 ****
  278.       /* write failed or last line has no EOL: stop here */
  279.       if (end == 0
  280.           || (lnum == end
  281. !             && buf->b_p_bin
  282.               && (lnum == write_no_eol_lnum
  283.               || (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol))))
  284.       {
  285. --- 3665,3671 ----
  286.       /* write failed or last line has no EOL: stop here */
  287.       if (end == 0
  288.           || (lnum == end
  289. !             && write_bin
  290.               && (lnum == write_no_eol_lnum
  291.               || (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol))))
  292.       {
  293. *** ../vim-6.2.419/src/misc2.c    Tue Mar 23 21:19:08 2004
  294. --- src/misc2.c    Tue Mar 30 21:01:29 2004
  295. ***************
  296. *** 2488,2494 ****
  297.       c = eap->cmd[eap->force_ff];
  298.       else
  299.       {
  300. !     if (buf->b_p_bin)
  301.           return EOL_UNIX;
  302.       c = *buf->b_p_ff;
  303.       }
  304. --- 2488,2495 ----
  305.       c = eap->cmd[eap->force_ff];
  306.       else
  307.       {
  308. !     if ((eap != NULL && eap->force_bin != 0)
  309. !                    ? (eap->force_bin == FORCE_BIN) : buf->b_p_bin)
  310.           return EOL_UNIX;
  311.       c = *buf->b_p_ff;
  312.       }
  313. *** ../vim-6.2.419/src/version.c    Tue Mar 30 22:11:17 2004
  314. --- src/version.c    Tue Mar 30 22:13:54 2004
  315. ***************
  316. *** 639,640 ****
  317. --- 639,642 ----
  318.   {   /* Add new patch number below this line */
  319. + /**/
  320. +     420,
  321.   /**/
  322.  
  323. -- 
  324. Some of the well know MS-Windows errors:
  325.     EMEMORY        Memory error caused by..., eh...
  326.     ELICENSE    Your license has expired, give us more money!
  327.     EMOUSE        Mouse moved, reinstall Windows
  328.     EILLEGAL    Illegal error, you are not allowed to see this
  329.     EVIRUS        Undetectable virus found
  330.  
  331.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  332. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  333. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  334.  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
  335.