Mercurial > vim
diff src/fileio.c @ 301:006e9c8a6a8a v7.0079
updated for version 7.0079
author | vimboss |
---|---|
date | Sat, 04 Jun 2005 22:06:24 +0000 |
parents | 9a1c2a8186b7 |
children | 33c6fb10dd66 |
line wrap: on
line diff
--- a/src/fileio.c +++ b/src/fileio.c @@ -765,6 +765,7 @@ readfile(fname, sfname, from, lines_to_s 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. @@ -774,18 +775,22 @@ readfile(fname, sfname, from, lines_to_s * That is only in *.??x files. */ fenc = (char_u *)"latin1"; c = enc_utf8; - if (!c && !read_stdin && TOLOWER_ASC(fname[STRLEN(fname) - 1]) == '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 = vim_read(fd, firstline, 80); - lseek(fd, (off_t)0L, SEEK_SET); - for (p = firstline; p < firstline + len; ++p) - if (*p >= 0x80) - { - c = TRUE; - break; - } + 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 = vim_read(fd, firstline, 80); + lseek(fd, (off_t)0L, SEEK_SET); + for (p = firstline; p < firstline + len; ++p) + if (*p >= 0x80) + { + c = TRUE; + break; + } + } } if (c)