Mercurial > vim
comparison src/ex_cmds2.c @ 15595:1ec942f1b648 v8.1.0805
patch 8.1.0805: too many #ifdefs
commit https://github.com/vim/vim/commit/135059724f140ceac889c9f8136bd1bf5c41d49d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 15:04:48 2019 +0100
patch 8.1.0805: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 1.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 15:15:06 +0100 |
parents | d89c5b339c2a |
children | 536dd2bc5ac9 |
comparison
equal
deleted
inserted
replaced
15594:7a8983fe4f97 | 15595:1ec942f1b648 |
---|---|
1955 /* When a line has been truncated, append NL, taking care | 1955 /* When a line has been truncated, append NL, taking care |
1956 * of multi-byte characters . */ | 1956 * of multi-byte characters . */ |
1957 if (IObuff[IOSIZE - 2] != NUL && IObuff[IOSIZE - 2] != NL) | 1957 if (IObuff[IOSIZE - 2] != NUL && IObuff[IOSIZE - 2] != NL) |
1958 { | 1958 { |
1959 int n = IOSIZE - 2; | 1959 int n = IOSIZE - 2; |
1960 # ifdef FEAT_MBYTE | 1960 |
1961 if (enc_utf8) | 1961 if (enc_utf8) |
1962 { | 1962 { |
1963 /* Move to the first byte of this char. | 1963 /* Move to the first byte of this char. |
1964 * utf_head_off() doesn't work, because it checks | 1964 * utf_head_off() doesn't work, because it checks |
1965 * for a truncated character. */ | 1965 * for a truncated character. */ |
1966 while (n > 0 && (IObuff[n] & 0xc0) == 0x80) | 1966 while (n > 0 && (IObuff[n] & 0xc0) == 0x80) |
1967 --n; | 1967 --n; |
1968 } | 1968 } |
1969 else if (has_mbyte) | 1969 else if (has_mbyte) |
1970 n -= mb_head_off(IObuff, IObuff + n); | 1970 n -= mb_head_off(IObuff, IObuff + n); |
1971 # endif | |
1972 IObuff[n] = NL; | 1971 IObuff[n] = NL; |
1973 IObuff[n + 1] = NUL; | 1972 IObuff[n + 1] = NUL; |
1974 } | 1973 } |
1975 if (i < si->sn_prl_ga.ga_len | 1974 if (i < si->sn_prl_ga.ga_len |
1976 && (pp = &PRL_ITEM(si, i))->snp_count > 0) | 1975 && (pp = &PRL_ITEM(si, i))->snp_count > 0) |
4252 linenr_T breakpoint; /* next line with breakpoint or zero */ | 4251 linenr_T breakpoint; /* next line with breakpoint or zero */ |
4253 char_u *fname; /* name of sourced file */ | 4252 char_u *fname; /* name of sourced file */ |
4254 int dbg_tick; /* debug_tick when breakpoint was set */ | 4253 int dbg_tick; /* debug_tick when breakpoint was set */ |
4255 int level; /* top nesting level of sourced file */ | 4254 int level; /* top nesting level of sourced file */ |
4256 #endif | 4255 #endif |
4257 #ifdef FEAT_MBYTE | |
4258 vimconv_T conv; /* type of conversion */ | 4256 vimconv_T conv; /* type of conversion */ |
4259 #endif | |
4260 }; | 4257 }; |
4261 | 4258 |
4262 #ifdef FEAT_EVAL | 4259 #ifdef FEAT_EVAL |
4263 /* | 4260 /* |
4264 * Return the address holding the next breakpoint line for a source cookie. | 4261 * Return the address holding the next breakpoint line for a source cookie. |
4591 } | 4588 } |
4592 } | 4589 } |
4593 # endif | 4590 # endif |
4594 #endif | 4591 #endif |
4595 | 4592 |
4596 #ifdef FEAT_MBYTE | |
4597 cookie.conv.vc_type = CONV_NONE; /* no conversion */ | 4593 cookie.conv.vc_type = CONV_NONE; /* no conversion */ |
4598 | 4594 |
4599 /* Read the first line so we can check for a UTF-8 BOM. */ | 4595 /* Read the first line so we can check for a UTF-8 BOM. */ |
4600 firstline = getsourceline(0, (void *)&cookie, 0); | 4596 firstline = getsourceline(0, (void *)&cookie, 0); |
4601 if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef | 4597 if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef |
4610 { | 4606 { |
4611 vim_free(firstline); | 4607 vim_free(firstline); |
4612 firstline = p; | 4608 firstline = p; |
4613 } | 4609 } |
4614 } | 4610 } |
4615 #endif | |
4616 | 4611 |
4617 /* | 4612 /* |
4618 * Call do_cmdline, which will call getsourceline() to get the lines. | 4613 * Call do_cmdline, which will call getsourceline() to get the lines. |
4619 */ | 4614 */ |
4620 do_cmdline(firstline, getsourceline, (void *)&cookie, | 4615 do_cmdline(firstline, getsourceline, (void *)&cookie, |
4681 # endif | 4676 # endif |
4682 #endif | 4677 #endif |
4683 fclose(cookie.fp); | 4678 fclose(cookie.fp); |
4684 vim_free(cookie.nextline); | 4679 vim_free(cookie.nextline); |
4685 vim_free(firstline); | 4680 vim_free(firstline); |
4686 #ifdef FEAT_MBYTE | |
4687 convert_setup(&cookie.conv, NULL, NULL); | 4681 convert_setup(&cookie.conv, NULL, NULL); |
4688 #endif | |
4689 | 4682 |
4690 if (trigger_source_post) | 4683 if (trigger_source_post) |
4691 apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf); | 4684 apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf); |
4692 | 4685 |
4693 theend: | 4686 theend: |
4922 vim_free(line); | 4915 vim_free(line); |
4923 line = ga.ga_data; | 4916 line = ga.ga_data; |
4924 } | 4917 } |
4925 } | 4918 } |
4926 | 4919 |
4927 #ifdef FEAT_MBYTE | |
4928 if (line != NULL && sp->conv.vc_type != CONV_NONE) | 4920 if (line != NULL && sp->conv.vc_type != CONV_NONE) |
4929 { | 4921 { |
4930 char_u *s; | 4922 char_u *s; |
4931 | 4923 |
4932 /* Convert the encoding of the script line. */ | 4924 /* Convert the encoding of the script line. */ |
4935 { | 4927 { |
4936 vim_free(line); | 4928 vim_free(line); |
4937 line = s; | 4929 line = s; |
4938 } | 4930 } |
4939 } | 4931 } |
4940 #endif | |
4941 | 4932 |
4942 #ifdef FEAT_EVAL | 4933 #ifdef FEAT_EVAL |
4943 /* Did we encounter a breakpoint? */ | 4934 /* Did we encounter a breakpoint? */ |
4944 if (sp->breakpoint != 0 && sp->breakpoint <= sourcing_lnum) | 4935 if (sp->breakpoint != 0 && sp->breakpoint <= sourcing_lnum) |
4945 { | 4936 { |
5192 * Without the multi-byte feature it's simply ignored. | 5183 * Without the multi-byte feature it's simply ignored. |
5193 */ | 5184 */ |
5194 void | 5185 void |
5195 ex_scriptencoding(exarg_T *eap UNUSED) | 5186 ex_scriptencoding(exarg_T *eap UNUSED) |
5196 { | 5187 { |
5197 #ifdef FEAT_MBYTE | |
5198 struct source_cookie *sp; | 5188 struct source_cookie *sp; |
5199 char_u *name; | 5189 char_u *name; |
5200 | 5190 |
5201 if (!getline_equal(eap->getline, eap->cookie, getsourceline)) | 5191 if (!getline_equal(eap->getline, eap->cookie, getsourceline)) |
5202 { | 5192 { |
5217 sp = (struct source_cookie *)getline_cookie(eap->getline, eap->cookie); | 5207 sp = (struct source_cookie *)getline_cookie(eap->getline, eap->cookie); |
5218 convert_setup(&sp->conv, name, p_enc); | 5208 convert_setup(&sp->conv, name, p_enc); |
5219 | 5209 |
5220 if (name != eap->arg) | 5210 if (name != eap->arg) |
5221 vim_free(name); | 5211 vim_free(name); |
5222 #endif | |
5223 } | 5212 } |
5224 | 5213 |
5225 #if defined(FEAT_EVAL) || defined(PROTO) | 5214 #if defined(FEAT_EVAL) || defined(PROTO) |
5226 /* | 5215 /* |
5227 * ":finish": Mark a sourced file as finished. | 5216 * ":finish": Mark a sourced file as finished. |