]> git.pld-linux.org Git - packages/vim.git/blob - 6.2.498
- new
[packages/vim.git] / 6.2.498
1 To: vim-dev@vim.org
2 Subject: Patch 6.2.498
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 6.2.498
11 Problem:    Non-latin1 help files are not properly supported.
12 Solution:   Support utf-8 help files and convert them to 'encoding' when
13             needed.
14 Files:      src/fileio.c
15
16
17 *** ../vim-6.2.497/src/fileio.c Tue Apr 20 12:52:53 2004
18 --- src/fileio.c        Sun Apr 25 14:21:50 2004
19 ***************
20 *** 259,264 ****
21 --- 259,266 ----
22   #ifdef FEAT_MBYTE
23       int               can_retry;
24       int               conv_error = FALSE;     /* conversion error detected */
25 +     int               keep_dest_enc = FALSE;  /* don't retry when char doesn't fit
26 +                                          in destination encoding */
27       linenr_T  illegal_byte = 0;       /* line nr with illegal byte */
28       char_u    *tmpname = NULL;        /* name of 'charconvert' output file */
29       int               fio_flags = 0;
30 ***************
31 *** 745,758 ****
32       }
33       else if (curbuf->b_help)
34       {
35         /* Help files are either utf-8 or latin1.  Try utf-8 first, if this
36 !        * fails it must be latin1.  Only do this when 'encoding' is utf-8 to
37 !        * avoid [converted] remarks all the time. */
38         fenc = (char_u *)"latin1";
39 !       if (enc_utf8)
40         {
41             fenc_next = fenc;
42             fenc = (char_u *)"utf-8";
43         }
44         fenc_alloced = FALSE;
45       }
46 --- 747,785 ----
47       }
48       else if (curbuf->b_help)
49       {
50 +       char_u      firstline[80];
51
52         /* Help files are either utf-8 or latin1.  Try utf-8 first, if this
53 !        * fails it must be latin1.
54 !        * Always do this when 'encoding' is "utf-8".  Otherwise only do
55 !        * this when needed to avoid [converted] remarks all the time.
56 !        * It is needed when the first line contains non-ASCII characters.
57 !        * That is only in *.??x files. */
58         fenc = (char_u *)"latin1";
59 !       c = enc_utf8;
60 !       if (!c && !read_stdin && TOLOWER_ASC(fname[STRLEN(fname) - 1]) == 'x')
61 !       {
62 !           /* Read the first line (and a bit more).  Immediately rewind to
63 !            * the start of the file.  If the read() fails "len" is -1. */
64 !           len = vim_read(fd, firstline, 80);
65 !           lseek(fd, (off_t)0L, SEEK_SET);
66 !           for (p = firstline; p < firstline + len; ++p)
67 !               if (*p >= 0x80)
68 !               {
69 !                   c = TRUE;
70 !                   break;
71 !               }
72 !       }
73
74 !       if (c)
75         {
76             fenc_next = fenc;
77             fenc = (char_u *)"utf-8";
78
79 +           /* When the file is utf-8 but a character doesn't fit in
80 +            * 'encoding' don't retry.  In help text editing utf-8 bytes
81 +            * doesn't make sense. */
82 +           keep_dest_enc = TRUE;
83         }
84         fenc_alloced = FALSE;
85       }
86 ***************
87 *** 1534,1540 ****
88                             /* character doesn't fit in latin1, retry with
89                              * another fenc when possible, otherwise just
90                              * report the error. */
91 !                           if (can_retry)
92                                 goto rewind_retry;
93                             *dest = 0xBF;
94                             conv_error = TRUE;
95 --- 1561,1567 ----
96                             /* character doesn't fit in latin1, retry with
97                              * another fenc when possible, otherwise just
98                              * report the error. */
99 !                           if (can_retry && !keep_dest_enc)
100                                 goto rewind_retry;
101                             *dest = 0xBF;
102                             conv_error = TRUE;
103 *** ../vim-6.2.497/src/version.c        Sun Apr 25 14:42:43 2004
104 --- src/version.c       Sun Apr 25 14:44:21 2004
105 ***************
106 *** 639,640 ****
107 --- 639,642 ----
108   {   /* Add new patch number below this line */
109 + /**/
110 +     498,
111   /**/
112
113 -- 
114 Don't Panic!
115                 -- The Hitchhiker's Guide to the Galaxy
116
117  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
118 ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
119 \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
120  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
This page took 0.034302 seconds and 3 git commands to generate.