Skip to content

Instantly share code, notes, and snippets.

@mattn
Created November 28, 2011 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/1400283 to your computer and use it in GitHub Desktop.
Save mattn/1400283 to your computer and use it in GitHub Desktop.
diff -r 379a6398d462 src/quickfix.c
--- a/src/quickfix.c Wed Oct 26 23:48:21 2011 +0200
+++ b/src/quickfix.c Tue Nov 29 09:00:19 2011 +0900
@@ -3914,6 +3914,14 @@
regmatch.rm_ic = FALSE;
if (regmatch.regprog != NULL)
{
+#ifdef FEAT_MBYTE
+ vimconv_T vc;
+
+ vc.vc_type = CONV_NONE;
+ if (!enc_utf8 && !enc_latin1like)
+ convert_setup(&vc, "utf-8", p_enc);
+#endif
+
/* create a new quickfix list */
qf_new_list(qi, *eap->cmdlinep);
@@ -3948,21 +3956,31 @@
lnum = 1;
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
{
- if (vim_regexec(&regmatch, IObuff, (colnr_T)0))
+
+ char_u *line = IObuff;
+#ifdef FEAT_MBYTE
+ if (vc.vc_type != CONV_NONE) {
+ line = string_convert(&vc, IObuff, NULL);
+ if (!line)
+ line = IObuff;
+ }
+#endif
+
+ if (vim_regexec(&regmatch, line, (colnr_T)0))
{
- int l = (int)STRLEN(IObuff);
+ int l = (int)STRLEN(line);
/* remove trailing CR, LF, spaces, etc. */
- while (l > 0 && IObuff[l - 1] <= ' ')
- IObuff[--l] = NUL;
+ while (l > 0 && line[l - 1] <= ' ')
+ line[--l] = NUL;
if (qf_add_entry(qi, &prevp,
NULL, /* dir */
fnames[fi],
0,
- IObuff,
+ line,
lnum,
- (int)(regmatch.startp[0] - IObuff)
+ (int)(regmatch.startp[0] - line)
+ 1, /* col */
FALSE, /* vis_col */
NULL, /* search pattern */
@@ -3975,6 +3993,11 @@
break;
}
}
+#ifdef FEAT_MBYTE
+ if (line != IObuff)
+ vim_free(line);
+#endif
+
++lnum;
line_breakcheck();
}
@@ -3990,6 +4013,11 @@
qi->qf_lists[qi->qf_curlist].qf_ptr =
qi->qf_lists[qi->qf_curlist].qf_start;
qi->qf_lists[qi->qf_curlist].qf_index = 1;
+
+#ifdef FEAT_MBYTE
+ if (vc.vc_type != CONV_NONE)
+ convert_setup(&vc, NULL, NULL);
+#endif
}
if (p_cpo == empty_option)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment