]>
Commit | Line | Data |
---|---|---|
51f9884c AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.430 | |
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.430 | |
11 | Problem: BOM at start of a vim script file is not recognized and causes an | |
12 | error message. | |
13 | Solution: Detect the BOM and skip over it. Also fix that after using | |
14 | ":scriptencoding" the iconv() file descriptor was not closed | |
15 | (memory leak). | |
16 | Files: src/ex_cmds2.c | |
17 | ||
18 | ||
19 | *** ../vim-6.2.429/src/ex_cmds2.c Sat Mar 27 13:23:01 2004 | |
20 | --- src/ex_cmds2.c Fri Apr 2 15:20:21 2004 | |
21 | *************** | |
22 | *** 2256,2261 **** | |
23 | --- 2256,2275 ---- | |
24 | #endif | |
25 | #ifdef FEAT_MBYTE | |
26 | cookie.conv.vc_type = CONV_NONE; /* no conversion */ | |
27 | + | |
28 | + /* Try reading the first few bytes to check for a UTF-8 BOM. */ | |
29 | + { | |
30 | + char_u buf[3]; | |
31 | + | |
32 | + if (fread((char *)buf, sizeof(char_u), (size_t)3, cookie.fp) | |
33 | + == (size_t)3 | |
34 | + && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) | |
35 | + /* Found BOM, setup conversion and skip over it. */ | |
36 | + convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc); | |
37 | + else | |
38 | + /* No BOM found, rewind. */ | |
39 | + fseek(cookie.fp, (off_t)0L, SEEK_SET); | |
40 | + } | |
41 | #endif | |
42 | ||
43 | /* | |
44 | *************** | |
45 | *** 2332,2337 **** | |
46 | --- 2346,2355 ---- | |
47 | retval = OK; | |
48 | fclose(cookie.fp); | |
49 | vim_free(cookie.nextline); | |
50 | + #ifdef FEAT_MBYTE | |
51 | + convert_setup(&cookie.conv, NULL, NULL); | |
52 | + #endif | |
53 | + | |
54 | if (got_int) | |
55 | EMSG(_(e_interr)); | |
56 | sourcing_name = save_sourcing_name; | |
57 | *** ../vim-6.2.429/src/version.c Fri Apr 2 14:41:35 2004 | |
58 | --- src/version.c Fri Apr 2 15:23:36 2004 | |
59 | *************** | |
60 | *** 639,640 **** | |
61 | --- 639,642 ---- | |
62 | { /* Add new patch number below this line */ | |
63 | + /**/ | |
64 | + 430, | |
65 | /**/ | |
66 | ||
67 | -- | |
68 | hundred-and-one symptoms of being an internet addict: | |
69 | 240. You think Webster's Dictionary is a directory of WEB sites. | |
70 | ||
71 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
72 | /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
73 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
74 | \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html /// |