Mercurial > vim
comparison src/quickfix.c @ 15603:639b8318472c v8.1.0809
patch 8.1.0809: too many #ifdefs
commit https://github.com/vim/vim/commit/a12a161b8ce09d024ed71c2134149fa323f8ee8e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 16:39:02 2019 +0100
patch 8.1.0809: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 3.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 16:45:06 +0100 |
parents | dd725a8ab112 |
children | 2c264fda0f59 |
comparison
equal
deleted
inserted
replaced
15602:2ef2028868e2 | 15603:639b8318472c |
---|---|
802 state->linelen = growbuflen; | 802 state->linelen = growbuflen; |
803 } | 803 } |
804 else | 804 else |
805 state->linebuf = IObuff; | 805 state->linebuf = IObuff; |
806 | 806 |
807 #ifdef FEAT_MBYTE | |
808 // Convert a line if it contains a non-ASCII character. | 807 // Convert a line if it contains a non-ASCII character. |
809 if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf)) | 808 if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf)) |
810 { | 809 { |
811 char_u *line; | 810 char_u *line; |
812 | 811 |
825 state->growbufsiz = state->linelen < LINE_MAXLEN | 824 state->growbufsiz = state->linelen < LINE_MAXLEN |
826 ? state->linelen : LINE_MAXLEN; | 825 ? state->linelen : LINE_MAXLEN; |
827 } | 826 } |
828 } | 827 } |
829 } | 828 } |
830 #endif | |
831 | 829 |
832 return QF_OK; | 830 return QF_OK; |
833 } | 831 } |
834 | 832 |
835 /* | 833 /* |
870 if (state->linelen > 1 && state->linebuf[state->linelen - 2] == '\r') | 868 if (state->linelen > 1 && state->linebuf[state->linelen - 2] == '\r') |
871 state->linebuf[state->linelen - 2] = NUL; | 869 state->linebuf[state->linelen - 2] = NUL; |
872 #endif | 870 #endif |
873 } | 871 } |
874 | 872 |
875 #ifdef FEAT_MBYTE | |
876 remove_bom(state->linebuf); | 873 remove_bom(state->linebuf); |
877 #endif | |
878 | 874 |
879 return QF_OK; | 875 return QF_OK; |
880 } | 876 } |
881 | 877 |
882 typedef struct { | 878 typedef struct { |
1536 typval_T *tv, | 1532 typval_T *tv, |
1537 buf_T *buf, | 1533 buf_T *buf, |
1538 linenr_T lnumfirst, | 1534 linenr_T lnumfirst, |
1539 linenr_T lnumlast) | 1535 linenr_T lnumlast) |
1540 { | 1536 { |
1541 #ifdef FEAT_MBYTE | |
1542 pstate->vc.vc_type = CONV_NONE; | 1537 pstate->vc.vc_type = CONV_NONE; |
1543 if (enc != NULL && *enc != NUL) | 1538 if (enc != NULL && *enc != NUL) |
1544 convert_setup(&pstate->vc, enc, p_enc); | 1539 convert_setup(&pstate->vc, enc, p_enc); |
1545 #endif | |
1546 | 1540 |
1547 if (efile != NULL && (pstate->fd = mch_fopen((char *)efile, "r")) == NULL) | 1541 if (efile != NULL && (pstate->fd = mch_fopen((char *)efile, "r")) == NULL) |
1548 { | 1542 { |
1549 semsg(_(e_openerrf), efile); | 1543 semsg(_(e_openerrf), efile); |
1550 return FAIL; | 1544 return FAIL; |
1574 { | 1568 { |
1575 if (pstate->fd != NULL) | 1569 if (pstate->fd != NULL) |
1576 fclose(pstate->fd); | 1570 fclose(pstate->fd); |
1577 | 1571 |
1578 vim_free(pstate->growbuf); | 1572 vim_free(pstate->growbuf); |
1579 #ifdef FEAT_MBYTE | |
1580 if (pstate->vc.vc_type != CONV_NONE) | 1573 if (pstate->vc.vc_type != CONV_NONE) |
1581 convert_setup(&pstate->vc, NULL, NULL); | 1574 convert_setup(&pstate->vc, NULL, NULL); |
1582 #endif | |
1583 } | 1575 } |
1584 | 1576 |
1585 /* | 1577 /* |
1586 * Read the errorfile "efile" into memory, line by line, building the error | 1578 * Read the errorfile "efile" into memory, line by line, building the error |
1587 * list. | 1579 * list. |
4688 #ifdef FEAT_EVAL | 4680 #ifdef FEAT_EVAL |
4689 if (aborting()) | 4681 if (aborting()) |
4690 return; | 4682 return; |
4691 #endif | 4683 #endif |
4692 } | 4684 } |
4693 #ifdef FEAT_MBYTE | |
4694 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; | 4685 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; |
4695 #endif | |
4696 | 4686 |
4697 if (is_loclist_cmd(eap->cmdidx)) | 4687 if (is_loclist_cmd(eap->cmdidx)) |
4698 wp = curwin; | 4688 wp = curwin; |
4699 | 4689 |
4700 autowrite_all(); | 4690 autowrite_all(); |
5030 case CMD_laddfile: au_name = (char_u *)"laddfile"; break; | 5020 case CMD_laddfile: au_name = (char_u *)"laddfile"; break; |
5031 default: break; | 5021 default: break; |
5032 } | 5022 } |
5033 if (au_name != NULL) | 5023 if (au_name != NULL) |
5034 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); | 5024 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); |
5035 #ifdef FEAT_MBYTE | |
5036 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; | 5025 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; |
5037 #endif | |
5038 #ifdef FEAT_BROWSE | 5026 #ifdef FEAT_BROWSE |
5039 if (cmdmod.browse) | 5027 if (cmdmod.browse) |
5040 { | 5028 { |
5041 char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg, | 5029 char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg, |
5042 NULL, NULL, | 5030 NULL, NULL, |
7033 */ | 7021 */ |
7034 static void | 7022 static void |
7035 hgr_search_file( | 7023 hgr_search_file( |
7036 qf_info_T *qi, | 7024 qf_info_T *qi, |
7037 char_u *fname, | 7025 char_u *fname, |
7038 #ifdef FEAT_MBYTE | |
7039 vimconv_T *p_vc, | 7026 vimconv_T *p_vc, |
7040 #endif | |
7041 regmatch_T *p_regmatch) | 7027 regmatch_T *p_regmatch) |
7042 { | 7028 { |
7043 FILE *fd; | 7029 FILE *fd; |
7044 long lnum; | 7030 long lnum; |
7045 | 7031 |
7049 | 7035 |
7050 lnum = 1; | 7036 lnum = 1; |
7051 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) | 7037 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) |
7052 { | 7038 { |
7053 char_u *line = IObuff; | 7039 char_u *line = IObuff; |
7054 #ifdef FEAT_MBYTE | 7040 |
7055 // Convert a line if 'encoding' is not utf-8 and | 7041 // Convert a line if 'encoding' is not utf-8 and |
7056 // the line contains a non-ASCII character. | 7042 // the line contains a non-ASCII character. |
7057 if (p_vc->vc_type != CONV_NONE | 7043 if (p_vc->vc_type != CONV_NONE |
7058 && has_non_ascii(IObuff)) | 7044 && has_non_ascii(IObuff)) |
7059 { | 7045 { |
7060 line = string_convert(p_vc, IObuff, NULL); | 7046 line = string_convert(p_vc, IObuff, NULL); |
7061 if (line == NULL) | 7047 if (line == NULL) |
7062 line = IObuff; | 7048 line = IObuff; |
7063 } | 7049 } |
7064 #endif | |
7065 | 7050 |
7066 if (vim_regexec(p_regmatch, line, (colnr_T)0)) | 7051 if (vim_regexec(p_regmatch, line, (colnr_T)0)) |
7067 { | 7052 { |
7068 int l = (int)STRLEN(line); | 7053 int l = (int)STRLEN(line); |
7069 | 7054 |
7087 1, // type | 7072 1, // type |
7088 TRUE // valid | 7073 TRUE // valid |
7089 ) == FAIL) | 7074 ) == FAIL) |
7090 { | 7075 { |
7091 got_int = TRUE; | 7076 got_int = TRUE; |
7092 #ifdef FEAT_MBYTE | |
7093 if (line != IObuff) | 7077 if (line != IObuff) |
7094 vim_free(line); | 7078 vim_free(line); |
7095 #endif | |
7096 break; | 7079 break; |
7097 } | 7080 } |
7098 } | 7081 } |
7099 #ifdef FEAT_MBYTE | |
7100 if (line != IObuff) | 7082 if (line != IObuff) |
7101 vim_free(line); | 7083 vim_free(line); |
7102 #endif | |
7103 ++lnum; | 7084 ++lnum; |
7104 line_breakcheck(); | 7085 line_breakcheck(); |
7105 } | 7086 } |
7106 fclose(fd); | 7087 fclose(fd); |
7107 } | 7088 } |
7112 */ | 7093 */ |
7113 static void | 7094 static void |
7114 hgr_search_files_in_dir( | 7095 hgr_search_files_in_dir( |
7115 qf_info_T *qi, | 7096 qf_info_T *qi, |
7116 char_u *dirname, | 7097 char_u *dirname, |
7117 regmatch_T *p_regmatch | 7098 regmatch_T *p_regmatch, |
7118 #ifdef FEAT_MBYTE | 7099 vimconv_T *p_vc |
7119 , vimconv_T *p_vc | |
7120 #endif | |
7121 #ifdef FEAT_MULTI_LANG | 7100 #ifdef FEAT_MULTI_LANG |
7122 , char_u *lang | 7101 , char_u *lang |
7123 #endif | 7102 #endif |
7124 ) | 7103 ) |
7125 { | 7104 { |
7145 && STRNICMP("txt", fnames[fi] | 7124 && STRNICMP("txt", fnames[fi] |
7146 + STRLEN(fnames[fi]) - 3, 3) == 0)) | 7125 + STRLEN(fnames[fi]) - 3, 3) == 0)) |
7147 continue; | 7126 continue; |
7148 #endif | 7127 #endif |
7149 | 7128 |
7150 hgr_search_file(qi, fnames[fi], | 7129 hgr_search_file(qi, fnames[fi], p_vc, p_regmatch); |
7151 #ifdef FEAT_MBYTE | |
7152 p_vc, | |
7153 #endif | |
7154 p_regmatch); | |
7155 } | 7130 } |
7156 FreeWild(fcount, fnames); | 7131 FreeWild(fcount, fnames); |
7157 } | 7132 } |
7158 } | 7133 } |
7159 | 7134 |
7166 static void | 7141 static void |
7167 hgr_search_in_rtp(qf_info_T *qi, regmatch_T *p_regmatch, char_u *lang) | 7142 hgr_search_in_rtp(qf_info_T *qi, regmatch_T *p_regmatch, char_u *lang) |
7168 { | 7143 { |
7169 char_u *p; | 7144 char_u *p; |
7170 | 7145 |
7171 #ifdef FEAT_MBYTE | |
7172 vimconv_T vc; | 7146 vimconv_T vc; |
7173 | 7147 |
7174 // Help files are in utf-8 or latin1, convert lines when 'encoding' | 7148 // Help files are in utf-8 or latin1, convert lines when 'encoding' |
7175 // differs. | 7149 // differs. |
7176 vc.vc_type = CONV_NONE; | 7150 vc.vc_type = CONV_NONE; |
7177 if (!enc_utf8) | 7151 if (!enc_utf8) |
7178 convert_setup(&vc, (char_u *)"utf-8", p_enc); | 7152 convert_setup(&vc, (char_u *)"utf-8", p_enc); |
7179 #endif | |
7180 | 7153 |
7181 // Go through all the directories in 'runtimepath' | 7154 // Go through all the directories in 'runtimepath' |
7182 p = p_rtp; | 7155 p = p_rtp; |
7183 while (*p != NUL && !got_int) | 7156 while (*p != NUL && !got_int) |
7184 { | 7157 { |
7185 copy_option_part(&p, NameBuff, MAXPATHL, ","); | 7158 copy_option_part(&p, NameBuff, MAXPATHL, ","); |
7186 | 7159 |
7187 hgr_search_files_in_dir(qi, NameBuff, p_regmatch | 7160 hgr_search_files_in_dir(qi, NameBuff, p_regmatch, &vc |
7188 #ifdef FEAT_MBYTE | |
7189 , &vc | |
7190 #endif | |
7191 #ifdef FEAT_MULTI_LANG | 7161 #ifdef FEAT_MULTI_LANG |
7192 , lang | 7162 , lang |
7193 #endif | 7163 #endif |
7194 ); | 7164 ); |
7195 } | 7165 } |
7196 | 7166 |
7197 #ifdef FEAT_MBYTE | |
7198 if (vc.vc_type != CONV_NONE) | 7167 if (vc.vc_type != CONV_NONE) |
7199 convert_setup(&vc, NULL, NULL); | 7168 convert_setup(&vc, NULL, NULL); |
7200 #endif | |
7201 } | 7169 } |
7202 | 7170 |
7203 /* | 7171 /* |
7204 * ":helpgrep {pattern}" | 7172 * ":helpgrep {pattern}" |
7205 */ | 7173 */ |