Mercurial > vim
comparison src/fileio.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 | 40336d427dd2 |
children | 7fad90423bd2 |
comparison
equal
deleted
inserted
replaced
15839:ed6ecf44dbaf | 15840:734b1928a5aa |
---|---|
5214 { | 5214 { |
5215 STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[dos]") : _("[dos format]")); | 5215 STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[dos]") : _("[dos format]")); |
5216 return TRUE; | 5216 return TRUE; |
5217 } | 5217 } |
5218 #endif | 5218 #endif |
5219 #ifndef USE_CR | |
5220 if (eol_type == EOL_MAC) | 5219 if (eol_type == EOL_MAC) |
5221 { | 5220 { |
5222 STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[mac]") : _("[mac format]")); | 5221 STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[mac]") : _("[mac format]")); |
5223 return TRUE; | 5222 return TRUE; |
5224 } | 5223 } |
5225 #endif | 5224 #ifdef USE_CRNL |
5226 #if defined(USE_CRNL) || defined(USE_CR) | |
5227 if (eol_type == EOL_UNIX) | 5225 if (eol_type == EOL_UNIX) |
5228 { | 5226 { |
5229 STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[unix]") : _("[unix format]")); | 5227 STRCAT(IObuff, shortmess(SHM_TEXT) ? _("[unix]") : _("[unix format]")); |
5230 return TRUE; | 5228 return TRUE; |
5231 } | 5229 } |
6357 char *eof; | 6355 char *eof; |
6358 #define FGETS_SIZE 200 | 6356 #define FGETS_SIZE 200 |
6359 char tbuf[FGETS_SIZE]; | 6357 char tbuf[FGETS_SIZE]; |
6360 | 6358 |
6361 buf[size - 2] = NUL; | 6359 buf[size - 2] = NUL; |
6362 #ifdef USE_CR | |
6363 eof = fgets_cr((char *)buf, size, fp); | |
6364 #else | |
6365 eof = fgets((char *)buf, size, fp); | 6360 eof = fgets((char *)buf, size, fp); |
6366 #endif | |
6367 if (buf[size - 2] != NUL && buf[size - 2] != '\n') | 6361 if (buf[size - 2] != NUL && buf[size - 2] != '\n') |
6368 { | 6362 { |
6369 buf[size - 1] = NUL; /* Truncate the line */ | 6363 buf[size - 1] = NUL; /* Truncate the line */ |
6370 | 6364 |
6371 /* Now throw away the rest of the line: */ | 6365 /* Now throw away the rest of the line: */ |
6372 do | 6366 do |
6373 { | 6367 { |
6374 tbuf[FGETS_SIZE - 2] = NUL; | 6368 tbuf[FGETS_SIZE - 2] = NUL; |
6375 #ifdef USE_CR | |
6376 vim_ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp); | |
6377 #else | |
6378 vim_ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp); | 6369 vim_ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp); |
6379 #endif | |
6380 } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n'); | 6370 } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n'); |
6381 } | 6371 } |
6382 return (eof == NULL); | 6372 return (eof == NULL); |
6383 } | 6373 } |
6384 | |
6385 #if defined(USE_CR) || defined(PROTO) | |
6386 /* | |
6387 * Like vim_fgets(), but accept any line terminator: CR, CR-LF or LF. | |
6388 * Returns TRUE for end-of-file. | |
6389 * Only used for the Mac, because it's much slower than vim_fgets(). | |
6390 */ | |
6391 int | |
6392 tag_fgets(char_u *buf, int size, FILE *fp) | |
6393 { | |
6394 int i = 0; | |
6395 int c; | |
6396 int eof = FALSE; | |
6397 | |
6398 for (;;) | |
6399 { | |
6400 c = fgetc(fp); | |
6401 if (c == EOF) | |
6402 { | |
6403 eof = TRUE; | |
6404 break; | |
6405 } | |
6406 if (c == '\r') | |
6407 { | |
6408 /* Always store a NL for end-of-line. */ | |
6409 if (i < size - 1) | |
6410 buf[i++] = '\n'; | |
6411 c = fgetc(fp); | |
6412 if (c != '\n') /* Macintosh format: single CR. */ | |
6413 ungetc(c, fp); | |
6414 break; | |
6415 } | |
6416 if (i < size - 1) | |
6417 buf[i++] = c; | |
6418 if (c == '\n') | |
6419 break; | |
6420 } | |
6421 buf[i] = NUL; | |
6422 return eof; | |
6423 } | |
6424 #endif | |
6425 | 6374 |
6426 /* | 6375 /* |
6427 * rename() only works if both files are on the same file system, this | 6376 * rename() only works if both files are on the same file system, this |
6428 * function will (attempts to?) copy the file across if rename fails -- webb | 6377 * function will (attempts to?) copy the file across if rename fails -- webb |
6429 * Return -1 for failure, 0 for success. | 6378 * Return -1 for failure, 0 for success. |