diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-06-04 05:05:32 +0000 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-06-06 18:04:37 -0400 |
commit | 01ca4600bae9cd1aa5f0cfe4fc4294e7da0b4ee3 (patch) | |
tree | 2b1b77d574347919e38e6876db49e0559fb0d5a9 | |
parent | 1e54b04bc0f68d65f8b751cb07aeb959258751f0 (diff) | |
download | rneovim-01ca4600bae9cd1aa5f0cfe4fc4294e7da0b4ee3.tar.gz rneovim-01ca4600bae9cd1aa5f0cfe4fc4294e7da0b4ee3.tar.bz2 rneovim-01ca4600bae9cd1aa5f0cfe4fc4294e7da0b4ee3.zip |
Remove USE_CR and tag_fgets. #808
These features are only used by legacy Mac OS.
-rw-r--r-- | src/nvim/diff.c | 7 | ||||
-rw-r--r-- | src/nvim/eval.c | 14 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 80 | ||||
-rw-r--r-- | src/nvim/fileio.c | 49 | ||||
-rw-r--r-- | src/nvim/message.c | 3 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 6 | ||||
-rw-r--r-- | src/nvim/tag.c | 15 |
7 files changed, 9 insertions, 165 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index b859871f98..c125b726c4 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -50,9 +50,6 @@ static int diff_a_works = MAYBE; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "diff.c.generated.h" #endif -#ifndef USE_CR -# define tag_fgets vim_fgets -#endif // ifndef USE_CR /// Called when deleting or unloading a buffer: No longer make a diff with it. /// @@ -702,7 +699,7 @@ void ex_diffupdate(exarg_T *eap) for (;;) { // There must be a line that contains "1c1". - if (tag_fgets(linebuf, LBUFLEN, fd)) { + if (vim_fgets(linebuf, LBUFLEN, fd)) { break; } @@ -1209,7 +1206,7 @@ static void diff_read(int idx_orig, int idx_new, char_u *fname) } for (;;) { - if (tag_fgets(linebuf, LBUFLEN, fd)) { + if (vim_fgets(linebuf, LBUFLEN, fd)) { // end of file break; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7408a7926a..31070c1118 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -14086,18 +14086,7 @@ static void f_system(typval_T *argvars, typval_T *rettv) res = get_cmd_output(get_tv_string(&argvars[0]), infile, kShellOptSilent | kShellOptCooked); -#ifdef USE_CR - /* translate <CR> into <NL> */ - if (res != NULL) { - char_u *s; - - for (s = res; *s; ++s) { - if (*s == CAR) - *s = NL; - } - } -#else -# ifdef USE_CRNL +#ifdef USE_CRNL /* translate <CR><NL> into <NL> */ if (res != NULL) { char_u *s, *d; @@ -14110,7 +14099,6 @@ static void f_system(typval_T *argvars, typval_T *rettv) } *d = NUL; } -# endif #endif done: diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 02d8f6f9af..b2b37d9c01 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -94,7 +94,7 @@ struct source_cookie { FILE *fp; /* opened file for sourcing */ char_u *nextline; /* if not NULL: line that was read ahead */ int finished; /* ":finish" used */ -#if defined(USE_CRNL) || defined(USE_CR) +#if defined(USE_CRNL) int fileformat; /* EOL_UNKNOWN, EOL_UNIX or EOL_DOS */ int error; /* TRUE if LF found after CR-LF */ #endif @@ -2520,15 +2520,6 @@ do_source ( cookie.error = FALSE; #endif -#ifdef USE_CR - /* If no automatic file format: Set default to CR. */ - if (*p_ffs == NUL) - cookie.fileformat = EOL_MAC; - else - cookie.fileformat = EOL_UNKNOWN; - cookie.error = FALSE; -#endif - cookie.nextline = NULL; cookie.finished = FALSE; @@ -2755,41 +2746,6 @@ void free_scriptnames(void) # endif -#if defined(USE_CR) || defined(PROTO) -/* - * Version of fgets() which also works for lines ending in a <CR> only - * (Macintosh format). - * For older versions of the Metrowerks library. - * At least CodeWarrior 9 needed this code. - */ -char *fgets_cr(char *s, int n, FILE *stream) -{ - int c = 0; - int char_read = 0; - - while (!feof(stream) && c != '\r' && c != '\n' && char_read < n - 1) { - c = fgetc(stream); - s[char_read++] = c; - /* If the file is in DOS format, we need to skip a NL after a CR. I - * thought it was the other way around, but this appears to work... */ - if (c == '\n') { - c = fgetc(stream); - if (c != '\r') - ungetc(c, stream); - } - } - - s[char_read] = 0; - if (char_read == 0) - return NULL; - - if (feof(stream) && char_read == 1) - return NULL; - - return s; -} -#endif - /* * Get one full line from a sourced file. * Called by do_cmdline() when it's called from do_source(). @@ -2897,9 +2853,6 @@ static char_u *get_one_sourceline(struct source_cookie *sp) #ifdef USE_CRNL int has_cr; /* CR-LF found */ #endif -#ifdef USE_CR - char_u *scan; -#endif int have_read = FALSE; /* use a growarray to store the sourced line */ @@ -2914,13 +2867,6 @@ static char_u *get_one_sourceline(struct source_cookie *sp) ga_grow(&ga, 120); buf = (char_u *)ga.ga_data; -#ifdef USE_CR - if (sp->fileformat == EOL_MAC) { - if (fgets_cr((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, - sp->fp) == NULL) - break; - } else -#endif if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, sp->fp) == NULL) break; @@ -2936,30 +2882,6 @@ static char_u *get_one_sourceline(struct source_cookie *sp) } #endif -#ifdef USE_CR - /* If the read doesn't stop on a new line, and there's - * some CR then we assume a Mac format */ - if (sp->fileformat == EOL_UNKNOWN) { - if (buf[len - 1] != '\n' && vim_strchr(buf, '\r') != NULL) - sp->fileformat = EOL_MAC; - else - sp->fileformat = EOL_UNIX; - } - - if (sp->fileformat == EOL_MAC) { - scan = vim_strchr(buf, '\r'); - - if (scan != NULL) { - *scan = '\n'; - if (*(scan + 1) != 0) { - *(scan + 1) = 0; - fseek(sp->fp, (long)(scan - buf - len + 1), SEEK_CUR); - } - } - len = STRLEN(buf); - } -#endif - have_read = TRUE; ga.ga_len = len; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index d4faafeed6..b3b336073b 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -3844,13 +3844,11 @@ static int msg_add_fileformat(int eol_type) return TRUE; } #endif -#ifndef USE_CR if (eol_type == EOL_MAC) { STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[mac]") : _("[mac format]")); return TRUE; } -#endif -#if defined(USE_CRNL) || defined(USE_CR) +#ifdef USE_CRNL if (eol_type == EOL_UNIX) { STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[unix]") : _("[unix format]")); return TRUE; @@ -4506,64 +4504,19 @@ int vim_fgets(char_u *buf, int size, FILE *fp) char tbuf[FGETS_SIZE]; buf[size - 2] = NUL; -#ifdef USE_CR - eof = fgets_cr((char *)buf, size, fp); -#else eof = fgets((char *)buf, size, fp); -#endif if (buf[size - 2] != NUL && buf[size - 2] != '\n') { buf[size - 1] = NUL; /* Truncate the line */ /* Now throw away the rest of the line: */ do { tbuf[FGETS_SIZE - 2] = NUL; -#ifdef USE_CR - ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp); -#else ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp); -#endif } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n'); } return eof == NULL; } -#if defined(USE_CR) || defined(PROTO) -/* - * Like vim_fgets(), but accept any line terminator: CR, CR-LF or LF. - * Returns TRUE for end-of-file. - * Only used for the Mac, because it's much slower than vim_fgets(). - */ -int tag_fgets(char_u *buf, int size, FILE *fp) -{ - int i = 0; - int c; - int eof = FALSE; - - for (;; ) { - c = fgetc(fp); - if (c == EOF) { - eof = TRUE; - break; - } - if (c == '\r') { - /* Always store a NL for end-of-line. */ - if (i < size - 1) - buf[i++] = '\n'; - c = fgetc(fp); - if (c != '\n') /* Macintosh format: single CR. */ - ungetc(c, fp); - break; - } - if (i < size - 1) - buf[i++] = c; - if (c == '\n') - break; - } - buf[i] = NUL; - return eof; -} -#endif - /* * os_rename() only works if both files are on the same file system, this * function will (attempts to?) copy the file across if rename fails -- webb diff --git a/src/nvim/message.c b/src/nvim/message.c index 42162b9315..41a2345171 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1992,9 +1992,6 @@ static void msg_puts_printf(char_u *str, int maxlen) p = &buf[0]; if (*s == '\n' && !info_message) *p++ = '\r'; -#if defined(USE_CR) && !defined(MACOS_X_UNIX) - else -#endif *p++ = *s; *p = '\0'; if (info_message) /* informative message, not an error */ diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 741ddc750c..55cc892cb0 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -39,15 +39,9 @@ # define DFLT_FFS_VIM "dos,unix" # define DFLT_FFS_VI "dos,unix" /* also autodetect in compatible mode */ #else -# ifdef USE_CR -# define DFLT_FF "mac" -# define DFLT_FFS_VIM "mac,unix,dos" -# define DFLT_FFS_VI "mac,unix,dos" -# else # define DFLT_FF "unix" # define DFLT_FFS_VIM "unix,dos" # define DFLT_FFS_VI "" -# endif #endif diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 4be18b7b34..dad4dd51ce 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -987,13 +987,6 @@ void do_tags(exarg_T *eap) MSG_PUTS("\n>"); } -/* When not using a CR for line separator, use vim_fgets() to read tag lines. - * For the Mac use tag_fgets(). It can handle any line separator, but is much - * slower than vim_fgets(). - */ -#ifndef USE_CR -# define tag_fgets vim_fgets -#endif /* @@ -1355,7 +1348,7 @@ find_tags ( #else fseek(fp, (long)search_info.curr_offset, SEEK_SET); #endif - eof = tag_fgets(lbuf, LSIZE, fp); + eof = vim_fgets(lbuf, LSIZE, fp); if (!eof && search_info.curr_offset != 0) { /* The explicit cast is to work around a bug in gcc 3.4.2 * (repeated below). */ @@ -1369,12 +1362,12 @@ find_tags ( #endif search_info.curr_offset = search_info.low_offset; } - eof = tag_fgets(lbuf, LSIZE, fp); + eof = vim_fgets(lbuf, LSIZE, fp); } /* skip empty and blank lines */ while (!eof && vim_isblankline(lbuf)) { search_info.curr_offset = ftell(fp); - eof = tag_fgets(lbuf, LSIZE, fp); + eof = vim_fgets(lbuf, LSIZE, fp); } if (eof) { /* Hit end of file. Skip backwards. */ @@ -1393,7 +1386,7 @@ find_tags ( if (use_cscope) eof = cs_fgets(lbuf, LSIZE); else - eof = tag_fgets(lbuf, LSIZE, fp); + eof = vim_fgets(lbuf, LSIZE, fp); } while (!eof && vim_isblankline(lbuf)); if (eof) { |