Karsten Hopp 474b1b
To: vim_dev@googlegroups.com
Karsten Hopp 474b1b
Subject: Patch 7.3.273
Karsten Hopp 474b1b
Fcc: outbox
Karsten Hopp 474b1b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 474b1b
Mime-Version: 1.0
Karsten Hopp 474b1b
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 474b1b
Content-Transfer-Encoding: 8bit
Karsten Hopp 474b1b
------------
Karsten Hopp 474b1b
Karsten Hopp 474b1b
Patch 7.3.273
Karsten Hopp 474b1b
Problem:    A BOM in an error file is seen as text. (Aleksey Baibarin)
Karsten Hopp 474b1b
Solution:   Remove the BOM from the text before evaluating. (idea by Christian
Karsten Hopp 474b1b
            Brabandt)
Karsten Hopp 474b1b
Files:      src/quickfix.c, src/mbyte.c, src/proto/mbyte.pro,
Karsten Hopp 474b1b
            src/testdir/test10.in
Karsten Hopp 474b1b
    
Karsten Hopp 474b1b
Karsten Hopp 474b1b
*** ../vim-7.3.272/src/quickfix.c	2011-05-19 17:42:54.000000000 +0200
Karsten Hopp 474b1b
--- src/quickfix.c	2011-08-10 12:56:15.000000000 +0200
Karsten Hopp 474b1b
***************
Karsten Hopp 474b1b
*** 561,566 ****
Karsten Hopp 474b1b
--- 561,570 ----
Karsten Hopp 474b1b
  	    break;
Karsten Hopp 474b1b
  
Karsten Hopp 474b1b
  	IObuff[CMDBUFFSIZE - 2] = NUL;  /* for very long lines */
Karsten Hopp 474b1b
+ #ifdef FEAT_MBYTE
Karsten Hopp 474b1b
+ 	remove_bom(IObuff);
Karsten Hopp 474b1b
+ #endif
Karsten Hopp 474b1b
+ 
Karsten Hopp 474b1b
  	if ((efmp = vim_strrchr(IObuff, '\n')) != NULL)
Karsten Hopp 474b1b
  	    *efmp = NUL;
Karsten Hopp 474b1b
  #ifdef USE_CRNL
Karsten Hopp 474b1b
*** ../vim-7.3.272/src/mbyte.c	2011-07-27 18:25:40.000000000 +0200
Karsten Hopp 474b1b
--- src/mbyte.c	2011-08-10 13:11:56.000000000 +0200
Karsten Hopp 474b1b
***************
Karsten Hopp 474b1b
*** 838,843 ****
Karsten Hopp 474b1b
--- 838,864 ----
Karsten Hopp 474b1b
  }
Karsten Hopp 474b1b
  
Karsten Hopp 474b1b
  /*
Karsten Hopp 474b1b
+  * Remove all BOM from "s" by moving remaining text.
Karsten Hopp 474b1b
+  */
Karsten Hopp 474b1b
+     void
Karsten Hopp 474b1b
+ remove_bom(s)
Karsten Hopp 474b1b
+     char_u *s;
Karsten Hopp 474b1b
+ {
Karsten Hopp 474b1b
+     if (enc_utf8)
Karsten Hopp 474b1b
+     {
Karsten Hopp 474b1b
+ 	char_u *p = s;
Karsten Hopp 474b1b
+ 
Karsten Hopp 474b1b
+ 	while ((p = vim_strbyte(p, 0xef)) != NULL)
Karsten Hopp 474b1b
+ 	{
Karsten Hopp 474b1b
+ 	    if (p[1] == 0xbb && p[2] == 0xbf)
Karsten Hopp 474b1b
+ 		STRMOVE(p, p + 3);
Karsten Hopp 474b1b
+ 	    else
Karsten Hopp 474b1b
+ 		++p;
Karsten Hopp 474b1b
+ 	}
Karsten Hopp 474b1b
+     }
Karsten Hopp 474b1b
+ }
Karsten Hopp 474b1b
+ 
Karsten Hopp 474b1b
+ /*
Karsten Hopp 474b1b
   * Get class of pointer:
Karsten Hopp 474b1b
   * 0 for blank or NUL
Karsten Hopp 474b1b
   * 1 for punctuation
Karsten Hopp 474b1b
*** ../vim-7.3.272/src/proto/mbyte.pro	2011-07-07 15:08:53.000000000 +0200
Karsten Hopp 474b1b
--- src/proto/mbyte.pro	2011-08-10 12:50:44.000000000 +0200
Karsten Hopp 474b1b
***************
Karsten Hopp 474b1b
*** 2,7 ****
Karsten Hopp 474b1b
--- 2,8 ----
Karsten Hopp 474b1b
  int enc_canon_props __ARGS((char_u *name));
Karsten Hopp 474b1b
  char_u *mb_init __ARGS((void));
Karsten Hopp 474b1b
  int bomb_size __ARGS((void));
Karsten Hopp 474b1b
+ void remove_bom __ARGS((char_u *s));
Karsten Hopp 474b1b
  int mb_get_class __ARGS((char_u *p));
Karsten Hopp 474b1b
  int dbcs_class __ARGS((unsigned lead, unsigned trail));
Karsten Hopp 474b1b
  int latin_char2len __ARGS((int c));
Karsten Hopp 474b1b
*** ../vim-7.3.272/src/testdir/test10.in	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp 474b1b
--- src/testdir/test10.in	2011-08-10 13:01:46.000000000 +0200
Karsten Hopp 474b1b
***************
Karsten Hopp 474b1b
*** 2,7 ****
Karsten Hopp 474b1b
--- 2,10 ----
Karsten Hopp 474b1b
  
Karsten Hopp 474b1b
  STARTTEST
Karsten Hopp 474b1b
  :so small.vim
Karsten Hopp 474b1b
+ :" Also test a BOM is ignored.
Karsten Hopp 474b1b
+ :so mbyte.vim
Karsten Hopp 474b1b
+ :set encoding=utf-8
Karsten Hopp 474b1b
  :/start of errorfile/,/end of errorfile/w! Xerrorfile
Karsten Hopp 474b1b
  :/start of testfile/,/end of testfile/w! Xtestfile
Karsten Hopp 474b1b
  :cf Xerrorfile
Karsten Hopp 474b1b
***************
Karsten Hopp 474b1b
*** 20,26 ****
Karsten Hopp 474b1b
  
Karsten Hopp 474b1b
  start of errorfile
Karsten Hopp 474b1b
  "Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.
Karsten Hopp 474b1b
! "Xtestfile", line 7 col 19; this is an error
Karsten Hopp 474b1b
  gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include  version.c
Karsten Hopp 474b1b
  Xtestfile:13: parse error before `asd'
Karsten Hopp 474b1b
  make: *** [vim] Error 1
Karsten Hopp 474b1b
--- 23,29 ----
Karsten Hopp 474b1b
  
Karsten Hopp 474b1b
  start of errorfile
Karsten Hopp 474b1b
  "Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.
Karsten Hopp 474b1b
! "Xtestfile", line 7 col 19; this is an error
Karsten Hopp 474b1b
  gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include  version.c
Karsten Hopp 474b1b
  Xtestfile:13: parse error before `asd'
Karsten Hopp 474b1b
  make: *** [vim] Error 1
Karsten Hopp 474b1b
*** ../vim-7.3.272/src/version.c	2011-08-10 12:38:02.000000000 +0200
Karsten Hopp 474b1b
--- src/version.c	2011-08-10 13:14:35.000000000 +0200
Karsten Hopp 474b1b
***************
Karsten Hopp 474b1b
*** 711,712 ****
Karsten Hopp 474b1b
--- 711,714 ----
Karsten Hopp 474b1b
  {   /* Add new patch number below this line */
Karsten Hopp 474b1b
+ /**/
Karsten Hopp 474b1b
+     273,
Karsten Hopp 474b1b
  /**/
Karsten Hopp 474b1b
Karsten Hopp 474b1b
-- 
Karsten Hopp 474b1b
Compilation process failed successfully.
Karsten Hopp 474b1b
Karsten Hopp 474b1b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 474b1b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 474b1b
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 474b1b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///