Skip to content

Instantly share code, notes, and snippets.

@LemonBoy
Created September 17, 2017 14:20
Show Gist options
  • Save LemonBoy/d14bb45bfc1f5ff41d4884457120fdfd to your computer and use it in GitHub Desktop.
Save LemonBoy/d14bb45bfc1f5ff41d4884457120fdfd to your computer and use it in GitHub Desktop.
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 2b07352..d723251 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -4237,27 +4237,6 @@ do_source(
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)
- p = vim_strsave(firstline + 3);
- if (p != NULL)
- {
- vim_free(firstline);
- firstline = p;
- }
- }
-#endif
-
#ifdef STARTUPTIME
if (time_fd != NULL)
time_push(&tv_rel, &tv_start);
@@ -4350,6 +4329,27 @@ do_source(
# endif
#endif
+#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)
+ p = vim_strsave(firstline + 3);
+ if (p != NULL)
+ {
+ vim_free(firstline);
+ firstline = p;
+ }
+ }
+#endif
+
/*
* Call do_cmdline, which will call getsourceline() to get the lines.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment