comparison 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
comparison
equal deleted inserted replaced
300:86cd0a77d2ae 301:006e9c8a6a8a
763 fenc_alloced = FALSE; 763 fenc_alloced = FALSE;
764 } 764 }
765 else if (curbuf->b_help) 765 else if (curbuf->b_help)
766 { 766 {
767 char_u firstline[80]; 767 char_u firstline[80];
768 int fc;
768 769
769 /* Help files are either utf-8 or latin1. Try utf-8 first, if this 770 /* Help files are either utf-8 or latin1. Try utf-8 first, if this
770 * fails it must be latin1. 771 * fails it must be latin1.
771 * Always do this when 'encoding' is "utf-8". Otherwise only do 772 * Always do this when 'encoding' is "utf-8". Otherwise only do
772 * this when needed to avoid [converted] remarks all the time. 773 * this when needed to avoid [converted] remarks all the time.
773 * It is needed when the first line contains non-ASCII characters. 774 * It is needed when the first line contains non-ASCII characters.
774 * That is only in *.??x files. */ 775 * That is only in *.??x files. */
775 fenc = (char_u *)"latin1"; 776 fenc = (char_u *)"latin1";
776 c = enc_utf8; 777 c = enc_utf8;
777 if (!c && !read_stdin && TOLOWER_ASC(fname[STRLEN(fname) - 1]) == 'x') 778 if (!c && !read_stdin)
778 { 779 {
779 /* Read the first line (and a bit more). Immediately rewind to 780 fc = fname[STRLEN(fname) - 1];
780 * the start of the file. If the read() fails "len" is -1. */ 781 if (TOLOWER_ASC(fc) == 'x')
781 len = vim_read(fd, firstline, 80); 782 {
782 lseek(fd, (off_t)0L, SEEK_SET); 783 /* Read the first line (and a bit more). Immediately rewind to
783 for (p = firstline; p < firstline + len; ++p) 784 * the start of the file. If the read() fails "len" is -1. */
784 if (*p >= 0x80) 785 len = vim_read(fd, firstline, 80);
785 { 786 lseek(fd, (off_t)0L, SEEK_SET);
786 c = TRUE; 787 for (p = firstline; p < firstline + len; ++p)
787 break; 788 if (*p >= 0x80)
788 } 789 {
790 c = TRUE;
791 break;
792 }
793 }
789 } 794 }
790 795
791 if (c) 796 if (c)
792 { 797 {
793 fenc_next = fenc; 798 fenc_next = fenc;