aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-04-17 22:02:46 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-04-17 22:02:46 +0200
commitce7cba6d7f36e79d52825215ba7b6848397b0440 (patch)
treecf249b863e9bfa1a6943b91dc293cc38bf71f6a7 /src/nvim/fileio.c
parent7debba9d4295f09bc338a5f0718abdc54d565a56 (diff)
parent2eb9150a4fcb8f43599e5f470cbcb3a12195d910 (diff)
downloadrneovim-ce7cba6d7f36e79d52825215ba7b6848397b0440.tar.gz
rneovim-ce7cba6d7f36e79d52825215ba7b6848397b0440.tar.bz2
rneovim-ce7cba6d7f36e79d52825215ba7b6848397b0440.zip
Merge #6533 'Fix PVS-studio warnings'
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index c1b8203ed1..74fa5aa1de 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -730,43 +730,16 @@ readfile (
fenc = (char_u *)""; /* binary: don't convert */
fenc_alloced = FALSE;
} else if (curbuf->b_help) {
- char_u firstline[80];
- int fc;
-
- /* Help files are either utf-8 or latin1. Try utf-8 first, if this
- * fails it must be latin1.
- * Always do this when 'encoding' is "utf-8". Otherwise only do
- * this when needed to avoid [converted] remarks all the time.
- * It is needed when the first line contains non-ASCII characters.
- * That is only in *.??x files. */
- fenc = (char_u *)"latin1";
- c = enc_utf8;
- if (!c && !read_stdin) {
- fc = fname[STRLEN(fname) - 1];
- if (TOLOWER_ASC(fc) == 'x') {
- /* Read the first line (and a bit more). Immediately rewind to
- * the start of the file. If the read() fails "len" is -1. */
- len = read_eintr(fd, firstline, 80);
- lseek(fd, (off_t)0L, SEEK_SET);
- for (p = firstline; p < firstline + len; ++p)
- if (*p >= 0x80) {
- c = TRUE;
- break;
- }
- }
- }
+ // Help files are either utf-8 or latin1. Try utf-8 first, if this
+ // fails it must be latin1.
+ // It is needed when the first line contains non-ASCII characters.
+ // That is only in *.??x files.
+ fenc_next = (char_u *)"latin1";
+ fenc = (char_u *)"utf-8";
- if (c) {
- fenc_next = fenc;
- fenc = (char_u *)"utf-8";
+ fenc_alloced = false;
- /* When the file is utf-8 but a character doesn't fit in
- * 'encoding' don't retry. In help text editing utf-8 bytes
- * doesn't make sense. */
- if (!enc_utf8)
- keep_dest_enc = TRUE;
- }
- fenc_alloced = FALSE;
+ c = 1;
} else if (*p_fencs == NUL) {
fenc = curbuf->b_p_fenc; /* use format from buffer */
fenc_alloced = FALSE;