Mercurial > vim
comparison src/ex_cmds2.c @ 15840:734b1928a5aa v8.1.0927
patch 8.1.0927: USE_CR is never defined
commit https://github.com/vim/vim/commit/00590740081489db69f43d9f1c0e3f70e29ce6da
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 15 21:06:09 2019 +0100
patch 8.1.0927: USE_CR is never defined
Problem: USE_CR is never defined.
Solution: Remove usage of USE_CR. (Ken Takata, closes https://github.com/vim/vim/issues/3958)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 15 Feb 2019 21:15:07 +0100 |
parents | 536dd2bc5ac9 |
children | 3af565215286 |
comparison
equal
deleted
inserted
replaced
15839:ed6ecf44dbaf | 15840:734b1928a5aa |
---|---|
1357 must_redraw = 0; | 1357 must_redraw = 0; |
1358 trylevel = 0; | 1358 trylevel = 0; |
1359 did_throw = FALSE; | 1359 did_throw = FALSE; |
1360 current_exception = NULL; | 1360 current_exception = NULL; |
1361 save_vimvars(&vvsave); | 1361 save_vimvars(&vvsave); |
1362 | 1362 ch_log(NULL, "calling timer callback"); |
1363 timer->tr_firing = TRUE; | 1363 timer->tr_firing = TRUE; |
1364 timer_callback(timer); | 1364 timer_callback(timer); |
1365 timer->tr_firing = FALSE; | 1365 timer->tr_firing = FALSE; |
1366 | 1366 |
1367 timer_next = timer->tr_next; | 1367 timer_next = timer->tr_next; |
4241 struct source_cookie | 4241 struct source_cookie |
4242 { | 4242 { |
4243 FILE *fp; /* opened file for sourcing */ | 4243 FILE *fp; /* opened file for sourcing */ |
4244 char_u *nextline; /* if not NULL: line that was read ahead */ | 4244 char_u *nextline; /* if not NULL: line that was read ahead */ |
4245 int finished; /* ":finish" used */ | 4245 int finished; /* ":finish" used */ |
4246 #if defined(USE_CRNL) || defined(USE_CR) | 4246 #ifdef USE_CRNL |
4247 int fileformat; /* EOL_UNKNOWN, EOL_UNIX or EOL_DOS */ | 4247 int fileformat; /* EOL_UNKNOWN, EOL_UNIX or EOL_DOS */ |
4248 int error; /* TRUE if LF found after CR-LF */ | 4248 int error; /* TRUE if LF found after CR-LF */ |
4249 #endif | 4249 #endif |
4250 #ifdef FEAT_EVAL | 4250 #ifdef FEAT_EVAL |
4251 linenr_T breakpoint; /* next line with breakpoint or zero */ | 4251 linenr_T breakpoint; /* next line with breakpoint or zero */ |
4463 else | 4463 else |
4464 cookie.fileformat = EOL_UNKNOWN; | 4464 cookie.fileformat = EOL_UNKNOWN; |
4465 cookie.error = FALSE; | 4465 cookie.error = FALSE; |
4466 #endif | 4466 #endif |
4467 | 4467 |
4468 #ifdef USE_CR | |
4469 /* If no automatic file format: Set default to CR. */ | |
4470 if (*p_ffs == NUL) | |
4471 cookie.fileformat = EOL_MAC; | |
4472 else | |
4473 cookie.fileformat = EOL_UNKNOWN; | |
4474 cookie.error = FALSE; | |
4475 #endif | |
4476 | |
4477 cookie.nextline = NULL; | 4468 cookie.nextline = NULL; |
4478 cookie.finished = FALSE; | 4469 cookie.finished = FALSE; |
4479 | 4470 |
4480 #ifdef FEAT_EVAL | 4471 #ifdef FEAT_EVAL |
4481 /* | 4472 /* |
4764 vim_free(SCRIPT_ITEM(i).sn_name); | 4755 vim_free(SCRIPT_ITEM(i).sn_name); |
4765 ga_clear(&script_items); | 4756 ga_clear(&script_items); |
4766 } | 4757 } |
4767 # endif | 4758 # endif |
4768 | 4759 |
4769 #endif | |
4770 | |
4771 #if defined(USE_CR) || defined(PROTO) | |
4772 | |
4773 # if defined(__MSL__) && (__MSL__ >= 22) | |
4774 /* | |
4775 * Newer version of the Metrowerks library handle DOS and UNIX files | |
4776 * without help. | |
4777 * Test with earlier versions, MSL 2.2 is the library supplied with | |
4778 * Codewarrior Pro 2. | |
4779 */ | |
4780 char * | |
4781 fgets_cr(char *s, int n, FILE *stream) | |
4782 { | |
4783 return fgets(s, n, stream); | |
4784 } | |
4785 # else | |
4786 /* | |
4787 * Version of fgets() which also works for lines ending in a <CR> only | |
4788 * (Macintosh format). | |
4789 * For older versions of the Metrowerks library. | |
4790 * At least CodeWarrior 9 needed this code. | |
4791 */ | |
4792 char * | |
4793 fgets_cr(char *s, int n, FILE *stream) | |
4794 { | |
4795 int c = 0; | |
4796 int char_read = 0; | |
4797 | |
4798 while (!feof(stream) && c != '\r' && c != '\n' && char_read < n - 1) | |
4799 { | |
4800 c = fgetc(stream); | |
4801 s[char_read++] = c; | |
4802 /* If the file is in DOS format, we need to skip a NL after a CR. I | |
4803 * thought it was the other way around, but this appears to work... */ | |
4804 if (c == '\n') | |
4805 { | |
4806 c = fgetc(stream); | |
4807 if (c != '\r') | |
4808 ungetc(c, stream); | |
4809 } | |
4810 } | |
4811 | |
4812 s[char_read] = 0; | |
4813 if (char_read == 0) | |
4814 return NULL; | |
4815 | |
4816 if (feof(stream) && char_read == 1) | |
4817 return NULL; | |
4818 | |
4819 return s; | |
4820 } | |
4821 # endif | |
4822 #endif | 4760 #endif |
4823 | 4761 |
4824 /* | 4762 /* |
4825 * Get one full line from a sourced file. | 4763 * Get one full line from a sourced file. |
4826 * Called by do_cmdline() when it's called from do_source(). | 4764 * Called by do_cmdline() when it's called from do_source(). |
4952 int c; | 4890 int c; |
4953 char_u *buf; | 4891 char_u *buf; |
4954 #ifdef USE_CRNL | 4892 #ifdef USE_CRNL |
4955 int has_cr; /* CR-LF found */ | 4893 int has_cr; /* CR-LF found */ |
4956 #endif | 4894 #endif |
4957 #ifdef USE_CR | |
4958 char_u *scan; | |
4959 #endif | |
4960 int have_read = FALSE; | 4895 int have_read = FALSE; |
4961 | 4896 |
4962 /* use a growarray to store the sourced line */ | 4897 /* use a growarray to store the sourced line */ |
4963 ga_init2(&ga, 1, 250); | 4898 ga_init2(&ga, 1, 250); |
4964 | 4899 |
4971 /* make room to read at least 120 (more) characters */ | 4906 /* make room to read at least 120 (more) characters */ |
4972 if (ga_grow(&ga, 120) == FAIL) | 4907 if (ga_grow(&ga, 120) == FAIL) |
4973 break; | 4908 break; |
4974 buf = (char_u *)ga.ga_data; | 4909 buf = (char_u *)ga.ga_data; |
4975 | 4910 |
4976 #ifdef USE_CR | 4911 if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, |
4977 if (sp->fileformat == EOL_MAC) | |
4978 { | |
4979 if (fgets_cr((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, | |
4980 sp->fp) == NULL) | 4912 sp->fp) == NULL) |
4981 break; | 4913 break; |
4982 } | |
4983 else | |
4984 #endif | |
4985 if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, | |
4986 sp->fp) == NULL) | |
4987 break; | |
4988 len = ga.ga_len + (int)STRLEN(buf + ga.ga_len); | 4914 len = ga.ga_len + (int)STRLEN(buf + ga.ga_len); |
4989 #ifdef USE_CRNL | 4915 #ifdef USE_CRNL |
4990 /* Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the | 4916 /* Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the |
4991 * CTRL-Z by its own, or after a NL. */ | 4917 * CTRL-Z by its own, or after a NL. */ |
4992 if ( (len == 1 || (len >= 2 && buf[len - 2] == '\n')) | 4918 if ( (len == 1 || (len >= 2 && buf[len - 2] == '\n')) |
4993 && sp->fileformat == EOL_DOS | 4919 && sp->fileformat == EOL_DOS |
4994 && buf[len - 1] == Ctrl_Z) | 4920 && buf[len - 1] == Ctrl_Z) |
4995 { | 4921 { |
4996 buf[len - 1] = NUL; | 4922 buf[len - 1] = NUL; |
4997 break; | 4923 break; |
4998 } | |
4999 #endif | |
5000 | |
5001 #ifdef USE_CR | |
5002 /* If the read doesn't stop on a new line, and there's | |
5003 * some CR then we assume a Mac format */ | |
5004 if (sp->fileformat == EOL_UNKNOWN) | |
5005 { | |
5006 if (buf[len - 1] != '\n' && vim_strchr(buf, '\r') != NULL) | |
5007 sp->fileformat = EOL_MAC; | |
5008 else | |
5009 sp->fileformat = EOL_UNIX; | |
5010 } | |
5011 | |
5012 if (sp->fileformat == EOL_MAC) | |
5013 { | |
5014 scan = vim_strchr(buf, '\r'); | |
5015 | |
5016 if (scan != NULL) | |
5017 { | |
5018 *scan = '\n'; | |
5019 if (*(scan + 1) != 0) | |
5020 { | |
5021 *(scan + 1) = 0; | |
5022 fseek(sp->fp, (long)(scan - buf - len + 1), SEEK_CUR); | |
5023 } | |
5024 } | |
5025 len = STRLEN(buf); | |
5026 } | 4924 } |
5027 #endif | 4925 #endif |
5028 | 4926 |
5029 have_read = TRUE; | 4927 have_read = TRUE; |
5030 ga.ga_len = len; | 4928 ga.ga_len = len; |