summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2009-02-04 16:50:47 +0000
committerBram Moolenaar <Bram@vim.org>2009-02-04 16:50:47 +0000
commit73881403a24c0be9d5239649338c010ca427b4b5 (patch)
tree59b6658de8afc9edc0c30ab7b9b51e72a4dc0632
parentfaff14ae031c3f6a7f8c9aa47d9890bec4e3753d (diff)
downloadvim-git-73881403a24c0be9d5239649338c010ca427b4b5.tar.gz
updated for version 7.2-100v7.2.100
-rw-r--r--src/ex_cmds2.c41
-rw-r--r--src/version.c2
2 files changed, 24 insertions, 19 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 2c0f80dfe..704c7abc3 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2842,6 +2842,7 @@ do_source(fname, check_other, is_vimrc)
linenr_T save_sourcing_lnum;
char_u *p;
char_u *fname_exp;
+ char_u *firstline = NULL;
int retval = FAIL;
#ifdef FEAT_EVAL
scid_T save_current_SID;
@@ -2992,23 +2993,6 @@ do_source(fname, check_other, is_vimrc)
cookie.level = ex_nesting_level;
#endif
-#ifdef FEAT_MBYTE
- cookie.conv.vc_type = CONV_NONE; /* no conversion */
-
- /* Try reading the first few bytes to check for a UTF-8 BOM. */
- {
- char_u buf[3];
-
- if (fread((char *)buf, sizeof(char_u), (size_t)3, cookie.fp)
- == (size_t)3
- && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf)
- /* Found BOM, setup conversion and skip over it. */
- convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
- else
- /* No BOM found, rewind. */
- fseek(cookie.fp, 0L, SEEK_SET);
- }
-#endif
/*
* Keep the sourcing name/lnum, for recursive calls.
@@ -3018,6 +3002,25 @@ do_source(fname, check_other, is_vimrc)
save_sourcing_lnum = sourcing_lnum;
sourcing_lnum = 0;
+#ifdef FEAT_MBYTE
+ cookie.conv.vc_type = CONV_NONE; /* no conversion */
+
+ /* Read the first line so we can check for a UTF-8 BOM. */
+ firstline = getsourceline(0, (void *)&cookie, 0);
+ if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
+ && firstline[1] == 0xbb && firstline[2] == 0xbf)
+ {
+ /* Found BOM; setup conversion, skip over BOM and recode the line. */
+ convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
+ p = string_convert(&cookie.conv, firstline + 3, NULL);
+ if (p != NULL)
+ {
+ vim_free(firstline);
+ firstline = p;
+ }
+ }
+#endif
+
#ifdef STARTUPTIME
time_push(&tv_rel, &tv_start);
#endif
@@ -3111,9 +3114,8 @@ do_source(fname, check_other, is_vimrc)
/*
* Call do_cmdline, which will call getsourceline() to get the lines.
*/
- do_cmdline(NULL, getsourceline, (void *)&cookie,
+ do_cmdline(firstline, getsourceline, (void *)&cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
-
retval = OK;
#ifdef FEAT_PROFILE
@@ -3171,6 +3173,7 @@ almosttheend:
#endif
fclose(cookie.fp);
vim_free(cookie.nextline);
+ vim_free(firstline);
#ifdef FEAT_MBYTE
convert_setup(&cookie.conv, NULL, NULL);
#endif
diff --git a/src/version.c b/src/version.c
index 8a7c1da78..6676f4ab3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -677,6 +677,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 100,
+/**/
99,
/**/
98,