comparison src/quickfix.c @ 3257:75217982ea46 v7.3.397

updated for version 7.3.397 Problem: ":helpgrep" does not work properly when 'encoding' is not utf-8 or latin1. Solution: Convert non-ascii lines to 'encoding'. (Yasuhiro Matsumoto)
author Bram Moolenaar <bram@vim.org>
date Tue, 10 Jan 2012 16:28:45 +0100
parents 48252b5fd170
children 9eb7fdfb5e63
comparison
equal deleted inserted replaced
3256:ba708ee8d69d 3257:75217982ea46
3912 3912
3913 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); 3913 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
3914 regmatch.rm_ic = FALSE; 3914 regmatch.rm_ic = FALSE;
3915 if (regmatch.regprog != NULL) 3915 if (regmatch.regprog != NULL)
3916 { 3916 {
3917 #ifdef FEAT_MBYTE
3918 vimconv_T vc;
3919
3920 /* Help files are in utf-8 or latin1, convert lines when 'encoding'
3921 * differs. */
3922 vc.vc_type = CONV_NONE;
3923 if (!enc_utf8)
3924 convert_setup(&vc, (char_u *)"utf-8", p_enc);
3925 #endif
3926
3917 /* create a new quickfix list */ 3927 /* create a new quickfix list */
3918 qf_new_list(qi, *eap->cmdlinep); 3928 qf_new_list(qi, *eap->cmdlinep);
3919 3929
3920 /* Go through all directories in 'runtimepath' */ 3930 /* Go through all directories in 'runtimepath' */
3921 p = p_rtp; 3931 p = p_rtp;
3946 if (fd != NULL) 3956 if (fd != NULL)
3947 { 3957 {
3948 lnum = 1; 3958 lnum = 1;
3949 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) 3959 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
3950 { 3960 {
3951 if (vim_regexec(&regmatch, IObuff, (colnr_T)0)) 3961 char_u *line = IObuff;
3962 #ifdef FEAT_MBYTE
3963 /* Convert a line if 'encoding' is not utf-8 and
3964 * the line contains a non-ASCII character. */
3965 if (vc.vc_type != CONV_NONE
3966 && has_non_ascii(IObuff)) {
3967 line = string_convert(&vc, IObuff, NULL);
3968 if (line == NULL)
3969 line = IObuff;
3970 }
3971 #endif
3972
3973 if (vim_regexec(&regmatch, line, (colnr_T)0))
3952 { 3974 {
3953 int l = (int)STRLEN(IObuff); 3975 int l = (int)STRLEN(line);
3954 3976
3955 /* remove trailing CR, LF, spaces, etc. */ 3977 /* remove trailing CR, LF, spaces, etc. */
3956 while (l > 0 && IObuff[l - 1] <= ' ') 3978 while (l > 0 && line[l - 1] <= ' ')
3957 IObuff[--l] = NUL; 3979 line[--l] = NUL;
3958 3980
3959 if (qf_add_entry(qi, &prevp, 3981 if (qf_add_entry(qi, &prevp,
3960 NULL, /* dir */ 3982 NULL, /* dir */
3961 fnames[fi], 3983 fnames[fi],
3962 0, 3984 0,
3963 IObuff, 3985 line,
3964 lnum, 3986 lnum,
3965 (int)(regmatch.startp[0] - IObuff) 3987 (int)(regmatch.startp[0] - line)
3966 + 1, /* col */ 3988 + 1, /* col */
3967 FALSE, /* vis_col */ 3989 FALSE, /* vis_col */
3968 NULL, /* search pattern */ 3990 NULL, /* search pattern */
3969 0, /* nr */ 3991 0, /* nr */
3970 1, /* type */ 3992 1, /* type */
3971 TRUE /* valid */ 3993 TRUE /* valid */
3972 ) == FAIL) 3994 ) == FAIL)
3973 { 3995 {
3974 got_int = TRUE; 3996 got_int = TRUE;
3997 #ifdef FEAT_MBYTE
3998 if (line != IObuff)
3999 vim_free(line);
4000 #endif
3975 break; 4001 break;
3976 } 4002 }
3977 } 4003 }
4004 #ifdef FEAT_MBYTE
4005 if (line != IObuff)
4006 vim_free(line);
4007 #endif
3978 ++lnum; 4008 ++lnum;
3979 line_breakcheck(); 4009 line_breakcheck();
3980 } 4010 }
3981 fclose(fd); 4011 fclose(fd);
3982 } 4012 }
3983 } 4013 }
3984 FreeWild(fcount, fnames); 4014 FreeWild(fcount, fnames);
3985 } 4015 }
3986 } 4016 }
4017
3987 vim_free(regmatch.regprog); 4018 vim_free(regmatch.regprog);
4019 #ifdef FEAT_MBYTE
4020 if (vc.vc_type != CONV_NONE)
4021 convert_setup(&vc, NULL, NULL);
4022 #endif
3988 4023
3989 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; 4024 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
3990 qi->qf_lists[qi->qf_curlist].qf_ptr = 4025 qi->qf_lists[qi->qf_curlist].qf_ptr =
3991 qi->qf_lists[qi->qf_curlist].qf_start; 4026 qi->qf_lists[qi->qf_curlist].qf_start;
3992 qi->qf_lists[qi->qf_curlist].qf_index = 1; 4027 qi->qf_lists[qi->qf_curlist].qf_index = 1;