1
0
forked from aniani/vim

patch 8.1.0927: USE_CR is never defined

Problem:    USE_CR is never defined.
Solution:   Remove usage of USE_CR. (Ken Takata, closes #3958)
This commit is contained in:
Bram Moolenaar 2019-02-15 21:06:09 +01:00
parent e93e5a504f
commit 0059074008
12 changed files with 29 additions and 224 deletions

View File

@ -3134,9 +3134,8 @@ A jump table for the options with a short description can be found at |Q_op|.
is read. is read.
*'fileformat'* *'ff'* *'fileformat'* *'ff'*
'fileformat' 'ff' string (MS-DOS, MS-Windows, OS/2 default: "dos", 'fileformat' 'ff' string (MS-Windows default: "dos",
Unix default: "unix", Unix, macOS default: "unix")
Macintosh default: "mac")
local to buffer local to buffer
{not in Vi} {not in Vi}
This gives the <EOL> of the current buffer, which is used for This gives the <EOL> of the current buffer, which is used for
@ -3159,9 +3158,8 @@ A jump table for the options with a short description can be found at |Q_op|.
*'fileformats'* *'ffs'* *'fileformats'* *'ffs'*
'fileformats' 'ffs' string (default: 'fileformats' 'ffs' string (default:
Vim+Vi MS-DOS, MS-Windows OS/2: "dos,unix", Vim+Vi MS-Windows: "dos,unix",
Vim Unix: "unix,dos", Vim Unix, macOS: "unix,dos",
Vim Mac: "mac,unix,dos",
Vi Cygwin: "unix,dos", Vi Cygwin: "unix,dos",
Vi others: "") Vi others: "")
global global

View File

@ -90,10 +90,6 @@ static int parse_diff_ed(char_u *line, linenr_T *lnum_orig, long *count_orig, li
static int parse_diff_unified(char_u *line, linenr_T *lnum_orig, long *count_orig, linenr_T *lnum_new, long *count_new); static int parse_diff_unified(char_u *line, linenr_T *lnum_orig, long *count_orig, linenr_T *lnum_new, long *count_new);
static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf); static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf);
#ifndef USE_CR
# define tag_fgets vim_fgets
#endif
/* /*
* Called when deleting or unloading a buffer: No longer make a diff with it. * Called when deleting or unloading a buffer: No longer make a diff with it.
*/ */
@ -996,7 +992,7 @@ check_external_diff(diffio_T *diffio)
for (;;) for (;;)
{ {
/* There must be a line that contains "1c1". */ /* There must be a line that contains "1c1". */
if (tag_fgets(linebuf, LBUFLEN, fd)) if (vim_fgets(linebuf, LBUFLEN, fd))
break; break;
if (STRNCMP(linebuf, "1c1", 3) == 0) if (STRNCMP(linebuf, "1c1", 3) == 0)
ok = TRUE; ok = TRUE;
@ -1604,7 +1600,7 @@ diff_read(
} }
else else
{ {
if (tag_fgets(linebuf, LBUFLEN, fd)) if (vim_fgets(linebuf, LBUFLEN, fd))
break; // end of file break; // end of file
line = linebuf; line = linebuf;
} }
@ -1626,9 +1622,9 @@ diff_read(
else if ((STRNCMP(line, "@@ ", 3) == 0)) else if ((STRNCMP(line, "@@ ", 3) == 0))
diffstyle = DIFF_UNIFIED; diffstyle = DIFF_UNIFIED;
else if ((STRNCMP(line, "--- ", 4) == 0) else if ((STRNCMP(line, "--- ", 4) == 0)
&& (tag_fgets(linebuf, LBUFLEN, fd) == 0) && (vim_fgets(linebuf, LBUFLEN, fd) == 0)
&& (STRNCMP(line, "+++ ", 4) == 0) && (STRNCMP(line, "+++ ", 4) == 0)
&& (tag_fgets(linebuf, LBUFLEN, fd) == 0) && (vim_fgets(linebuf, LBUFLEN, fd) == 0)
&& (STRNCMP(line, "@@ ", 3) == 0)) && (STRNCMP(line, "@@ ", 3) == 0))
diffstyle = DIFF_UNIFIED; diffstyle = DIFF_UNIFIED;
else else

View File

@ -13431,20 +13431,7 @@ get_cmd_output_as_rettv(
else else
{ {
res = get_cmd_output(tv_get_string(&argvars[0]), infile, flags, NULL); res = get_cmd_output(tv_get_string(&argvars[0]), infile, flags, NULL);
#ifdef USE_CR #ifdef USE_CRNL
/* translate <CR> into <NL> */
if (res != NULL)
{
char_u *s;
for (s = res; *s; ++s)
{
if (*s == CAR)
*s = NL;
}
}
#else
# ifdef USE_CRNL
/* translate <CR><NL> into <NL> */ /* translate <CR><NL> into <NL> */
if (res != NULL) if (res != NULL)
{ {
@ -13459,7 +13446,6 @@ get_cmd_output_as_rettv(
} }
*d = NUL; *d = NUL;
} }
# endif
#endif #endif
rettv->vval.v_string = res; rettv->vval.v_string = res;
res = NULL; res = NULL;

View File

@ -1359,7 +1359,7 @@ check_due_timer(void)
did_throw = FALSE; did_throw = FALSE;
current_exception = NULL; current_exception = NULL;
save_vimvars(&vvsave); save_vimvars(&vvsave);
ch_log(NULL, "calling timer callback");
timer->tr_firing = TRUE; timer->tr_firing = TRUE;
timer_callback(timer); timer_callback(timer);
timer->tr_firing = FALSE; timer->tr_firing = FALSE;
@ -4243,7 +4243,7 @@ struct source_cookie
FILE *fp; /* opened file for sourcing */ FILE *fp; /* opened file for sourcing */
char_u *nextline; /* if not NULL: line that was read ahead */ char_u *nextline; /* if not NULL: line that was read ahead */
int finished; /* ":finish" used */ int finished; /* ":finish" used */
#if defined(USE_CRNL) || defined(USE_CR) #ifdef USE_CRNL
int fileformat; /* EOL_UNKNOWN, EOL_UNIX or EOL_DOS */ int fileformat; /* EOL_UNKNOWN, EOL_UNIX or EOL_DOS */
int error; /* TRUE if LF found after CR-LF */ int error; /* TRUE if LF found after CR-LF */
#endif #endif
@ -4465,15 +4465,6 @@ do_source(
cookie.error = FALSE; cookie.error = FALSE;
#endif #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.nextline = NULL;
cookie.finished = FALSE; cookie.finished = FALSE;
@ -4768,59 +4759,6 @@ free_scriptnames(void)
#endif #endif
#if defined(USE_CR) || defined(PROTO)
# if defined(__MSL__) && (__MSL__ >= 22)
/*
* Newer version of the Metrowerks library handle DOS and UNIX files
* without help.
* Test with earlier versions, MSL 2.2 is the library supplied with
* Codewarrior Pro 2.
*/
char *
fgets_cr(char *s, int n, FILE *stream)
{
return fgets(s, n, stream);
}
# else
/*
* 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
#endif
/* /*
* Get one full line from a sourced file. * Get one full line from a sourced file.
* Called by do_cmdline() when it's called from do_source(). * Called by do_cmdline() when it's called from do_source().
@ -4953,9 +4891,6 @@ get_one_sourceline(struct source_cookie *sp)
char_u *buf; char_u *buf;
#ifdef USE_CRNL #ifdef USE_CRNL
int has_cr; /* CR-LF found */ int has_cr; /* CR-LF found */
#endif
#ifdef USE_CR
char_u *scan;
#endif #endif
int have_read = FALSE; int have_read = FALSE;
@ -4973,18 +4908,9 @@ get_one_sourceline(struct source_cookie *sp)
break; break;
buf = (char_u *)ga.ga_data; buf = (char_u *)ga.ga_data;
#ifdef USE_CR if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
if (sp->fileformat == EOL_MAC)
{
if (fgets_cr((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
sp->fp) == NULL) sp->fp) == NULL)
break; break;
}
else
#endif
if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
sp->fp) == NULL)
break;
len = ga.ga_len + (int)STRLEN(buf + ga.ga_len); len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);
#ifdef USE_CRNL #ifdef USE_CRNL
/* Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the /* Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the
@ -4998,34 +4924,6 @@ get_one_sourceline(struct source_cookie *sp)
} }
#endif #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; have_read = TRUE;
ga.ga_len = len; ga.ga_len = len;

View File

@ -5216,14 +5216,12 @@ msg_add_fileformat(int eol_type)
return TRUE; return TRUE;
} }
#endif #endif
#ifndef USE_CR
if (eol_type == EOL_MAC) if (eol_type == EOL_MAC)
{ {
STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[mac]") : _("[mac format]")); STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[mac]") : _("[mac format]"));
return TRUE; return TRUE;
} }
#endif #ifdef USE_CRNL
#if defined(USE_CRNL) || defined(USE_CR)
if (eol_type == EOL_UNIX) if (eol_type == EOL_UNIX)
{ {
STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[unix]") : _("[unix format]")); STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[unix]") : _("[unix format]"));
@ -6359,11 +6357,7 @@ vim_fgets(char_u *buf, int size, FILE *fp)
char tbuf[FGETS_SIZE]; char tbuf[FGETS_SIZE];
buf[size - 2] = NUL; buf[size - 2] = NUL;
#ifdef USE_CR
eof = fgets_cr((char *)buf, size, fp);
#else
eof = fgets((char *)buf, size, fp); eof = fgets((char *)buf, size, fp);
#endif
if (buf[size - 2] != NUL && buf[size - 2] != '\n') if (buf[size - 2] != NUL && buf[size - 2] != '\n')
{ {
buf[size - 1] = NUL; /* Truncate the line */ buf[size - 1] = NUL; /* Truncate the line */
@ -6372,57 +6366,12 @@ vim_fgets(char_u *buf, int size, FILE *fp)
do do
{ {
tbuf[FGETS_SIZE - 2] = NUL; tbuf[FGETS_SIZE - 2] = NUL;
#ifdef USE_CR
vim_ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp);
#else
vim_ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp); vim_ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp);
#endif
} while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n'); } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n');
} }
return (eof == NULL); 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
/* /*
* rename() only works if both files are on the same file system, this * 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 * function will (attempts to?) copy the file across if rename fails -- webb

View File

@ -2590,10 +2590,7 @@ msg_puts_printf(char_u *str, int maxlen)
memcpy(buf, p, n); memcpy(buf, p, n);
if (!info_message) if (!info_message)
buf[n++] = CAR; buf[n++] = CAR;
#ifdef USE_CR buf[n++] = NL;
else
#endif
buf[n++] = NL;
buf[n++] = NUL; buf[n++] = NUL;
if (info_message) // informative message, not an error if (info_message) // informative message, not an error
mch_msg((char *)buf); mch_msg((char *)buf);

View File

@ -6577,11 +6577,7 @@ clip_convert_selection(char_u **str, long_u *len, VimClipboard *cbd)
#ifdef USE_CRNL #ifdef USE_CRNL
p[i++] = '\r'; p[i++] = '\r';
#endif #endif
#ifdef USE_CR
p[i] = '\r';
#else
p[i] = '\n'; p[i] = '\n';
#endif
lnum++; lnum++;
j = -1; j = -1;
} }

View File

@ -50,21 +50,14 @@
# define DFLT_FFS_VI "dos,unix" /* also autodetect in compatible mode */ # define DFLT_FFS_VI "dos,unix" /* also autodetect in compatible mode */
# define DFLT_TEXTAUTO TRUE # define DFLT_TEXTAUTO TRUE
#else #else
# ifdef USE_CR # define DFLT_FF "unix"
# define DFLT_FF "mac" # define DFLT_FFS_VIM "unix,dos"
# define DFLT_FFS_VIM "mac,unix,dos" # ifdef __CYGWIN__
# define DFLT_FFS_VI "mac,unix,dos" # define DFLT_FFS_VI "unix,dos" /* Cygwin always needs file detection */
# define DFLT_TEXTAUTO TRUE # define DFLT_TEXTAUTO TRUE
# else # else
# define DFLT_FF "unix" # define DFLT_FFS_VI ""
# define DFLT_FFS_VIM "unix,dos" # define DFLT_TEXTAUTO FALSE
# ifdef __CYGWIN__
# define DFLT_FFS_VI "unix,dos" /* Cygwin always needs file detection */
# define DFLT_TEXTAUTO TRUE
# else
# define DFLT_FFS_VI ""
# define DFLT_TEXTAUTO FALSE
# endif
# endif # endif
#endif #endif

View File

@ -93,7 +93,6 @@ void ex_scriptnames(exarg_T *eap);
void scriptnames_slash_adjust(void); void scriptnames_slash_adjust(void);
char_u *get_scriptname(scid_T id); char_u *get_scriptname(scid_T id);
void free_scriptnames(void); void free_scriptnames(void);
char *fgets_cr(char *s, int n, FILE *stream);
char_u *getsourceline(int c, void *cookie, int indent); char_u *getsourceline(int c, void *cookie, int indent);
void script_line_start(void); void script_line_start(void);
void script_line_exec(void); void script_line_exec(void);

View File

@ -18,7 +18,6 @@ void shorten_filenames(char_u **fnames, int count);
char_u *modname(char_u *fname, char_u *ext, int prepend_dot); char_u *modname(char_u *fname, char_u *ext, int prepend_dot);
char_u *buf_modname(int shortname, char_u *fname, char_u *ext, int prepend_dot); char_u *buf_modname(int shortname, char_u *fname, char_u *ext, int prepend_dot);
int vim_fgets(char_u *buf, int size, FILE *fp); int vim_fgets(char_u *buf, int size, FILE *fp);
int tag_fgets(char_u *buf, int size, FILE *fp);
int vim_rename(char_u *from, char_u *to); int vim_rename(char_u *from, char_u *to);
int check_timestamps(int focus); int check_timestamps(int focus);
int buf_check_timestamp(buf_T *buf, int focus); int buf_check_timestamp(buf_T *buf, int focus);

View File

@ -1146,14 +1146,6 @@ do_tags(exarg_T *eap UNUSED)
msg_puts("\n>"); 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
#ifdef FEAT_TAG_BINS #ifdef FEAT_TAG_BINS
/* /*
* Compare two strings, for length "len", ignoring case the ASCII way. * Compare two strings, for length "len", ignoring case the ASCII way.
@ -1654,7 +1646,7 @@ find_tags(
/* Adjust the search file offset to the correct position */ /* Adjust the search file offset to the correct position */
search_info.curr_offset_used = search_info.curr_offset; search_info.curr_offset_used = search_info.curr_offset;
vim_fseek(fp, search_info.curr_offset, SEEK_SET); vim_fseek(fp, search_info.curr_offset, SEEK_SET);
eof = tag_fgets(lbuf, LSIZE, fp); eof = vim_fgets(lbuf, LSIZE, fp);
if (!eof && search_info.curr_offset != 0) if (!eof && search_info.curr_offset != 0)
{ {
/* The explicit cast is to work around a bug in gcc 3.4.2 /* The explicit cast is to work around a bug in gcc 3.4.2
@ -1666,13 +1658,13 @@ find_tags(
vim_fseek(fp, search_info.low_offset, SEEK_SET); vim_fseek(fp, search_info.low_offset, SEEK_SET);
search_info.curr_offset = search_info.low_offset; 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 */ /* skip empty and blank lines */
while (!eof && vim_isblankline(lbuf)) while (!eof && vim_isblankline(lbuf))
{ {
search_info.curr_offset = vim_ftell(fp); search_info.curr_offset = vim_ftell(fp);
eof = tag_fgets(lbuf, LSIZE, fp); eof = vim_fgets(lbuf, LSIZE, fp);
} }
if (eof) if (eof)
{ {
@ -1698,7 +1690,7 @@ find_tags(
eof = cs_fgets(lbuf, LSIZE); eof = cs_fgets(lbuf, LSIZE);
else else
#endif #endif
eof = tag_fgets(lbuf, LSIZE, fp); eof = vim_fgets(lbuf, LSIZE, fp);
} while (!eof && vim_isblankline(lbuf)); } while (!eof && vim_isblankline(lbuf));
if (eof) if (eof)
@ -1763,7 +1755,7 @@ line_read_in:
{ {
is_etag = 1; /* in case at the start */ is_etag = 1; /* in case at the start */
state = TS_LINEAR; state = TS_LINEAR;
if (!tag_fgets(ebuf, LSIZE, fp)) if (!vim_fgets(ebuf, LSIZE, fp))
{ {
for (p = ebuf; *p && *p != ','; p++) for (p = ebuf; *p && *p != ','; p++)
; ;

View File

@ -783,6 +783,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
927,
/**/ /**/
926, 926,
/**/ /**/