]>
Commit | Line | Data |
---|---|---|
c6060300 MT |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.124 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.124 | |
11 | Problem: When writing a file in binary mode it may be missing the final EOL | |
12 | if a file previously read was missing the EOL. (Kevin Goodsell) | |
13 | Solution: Move the write_no_eol_lnum into the buffer struct. | |
14 | Files: src/structs.h, src/fileio.c, src/globals.h, src/os_unix.c | |
15 | ||
16 | ||
17 | *** ../vim-7.3.123/src/structs.h 2010-10-20 21:22:17.000000000 +0200 | |
18 | --- src/structs.h 2011-02-15 17:06:34.000000000 +0100 | |
19 | *************** | |
20 | *** 1564,1569 **** | |
21 | --- 1564,1572 ---- | |
22 | ||
23 | /* end of buffer options */ | |
24 | ||
25 | + linenr_T b_no_eol_lnum; /* non-zero lnum when last line of next binary | |
26 | + * write should not have an end-of-line */ | |
27 | + | |
28 | int b_start_eol; /* last line had eol when it was read */ | |
29 | int b_start_ffc; /* first char of 'ff' when edit started */ | |
30 | #ifdef FEAT_MBYTE | |
31 | *** ../vim-7.3.123/src/fileio.c 2011-02-09 16:44:45.000000000 +0100 | |
32 | --- src/fileio.c 2011-02-15 17:30:54.000000000 +0100 | |
33 | *************** | |
34 | *** 317,323 **** | |
35 | int using_b_fname; | |
36 | #endif | |
37 | ||
38 | ! write_no_eol_lnum = 0; /* in case it was set by the previous read */ | |
39 | ||
40 | /* | |
41 | * If there is no file name yet, use the one for the read file. | |
42 | --- 317,323 ---- | |
43 | int using_b_fname; | |
44 | #endif | |
45 | ||
46 | ! curbuf->b_no_eol_lnum = 0; /* in case it was set by the previous read */ | |
47 | ||
48 | /* | |
49 | * If there is no file name yet, use the one for the read file. | |
50 | *************** | |
51 | *** 2599,2608 **** | |
52 | ||
53 | /* | |
54 | * Trick: We remember if the last line of the read didn't have | |
55 | ! * an eol for when writing it again. This is required for | |
56 | * ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work. | |
57 | */ | |
58 | ! write_no_eol_lnum = read_no_eol_lnum; | |
59 | ||
60 | /* When reloading a buffer put the cursor at the first line that is | |
61 | * different. */ | |
62 | --- 2599,2609 ---- | |
63 | ||
64 | /* | |
65 | * Trick: We remember if the last line of the read didn't have | |
66 | ! * an eol even when 'binary' is off, for when writing it again with | |
67 | ! * 'binary' on. This is required for | |
68 | * ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work. | |
69 | */ | |
70 | ! curbuf->b_no_eol_lnum = read_no_eol_lnum; | |
71 | ||
72 | /* When reloading a buffer put the cursor at the first line that is | |
73 | * different. */ | |
74 | *************** | |
75 | *** 2650,2662 **** | |
76 | FALSE, NULL, eap); | |
77 | if (msg_scrolled == n) | |
78 | msg_scroll = m; | |
79 | ! #ifdef FEAT_EVAL | |
80 | if (aborting()) /* autocmds may abort script processing */ | |
81 | return FAIL; | |
82 | ! #endif | |
83 | } | |
84 | #endif | |
85 | ||
86 | if (recoverymode && error) | |
87 | return FAIL; | |
88 | return OK; | |
89 | --- 2651,2667 ---- | |
90 | FALSE, NULL, eap); | |
91 | if (msg_scrolled == n) | |
92 | msg_scroll = m; | |
93 | ! # ifdef FEAT_EVAL | |
94 | if (aborting()) /* autocmds may abort script processing */ | |
95 | return FAIL; | |
96 | ! # endif | |
97 | } | |
98 | #endif | |
99 | ||
100 | + /* Reset now, following writes should not omit the EOL. Also, the line | |
101 | + * number will become invalid because of edits. */ | |
102 | + curbuf->b_no_eol_lnum = 0; | |
103 | + | |
104 | if (recoverymode && error) | |
105 | return FAIL; | |
106 | return OK; | |
107 | *************** | |
108 | *** 4560,4566 **** | |
109 | if (end == 0 | |
110 | || (lnum == end | |
111 | && write_bin | |
112 | ! && (lnum == write_no_eol_lnum | |
113 | || (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol)))) | |
114 | { | |
115 | ++lnum; /* written the line, count it */ | |
116 | --- 4565,4571 ---- | |
117 | if (end == 0 | |
118 | || (lnum == end | |
119 | && write_bin | |
120 | ! && (lnum == buf->b_no_eol_lnum | |
121 | || (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol)))) | |
122 | { | |
123 | ++lnum; /* written the line, count it */ | |
124 | *************** | |
125 | *** 5086,5093 **** | |
126 | { | |
127 | aco_save_T aco; | |
128 | ||
129 | - write_no_eol_lnum = 0; /* in case it was set by the previous read */ | |
130 | - | |
131 | /* | |
132 | * Apply POST autocommands. | |
133 | * Careful: The autocommands may call buf_write() recursively! | |
134 | --- 5091,5096 ---- | |
135 | *************** | |
136 | *** 7256,7263 **** | |
137 | write_lnum_adjust(offset) | |
138 | linenr_T offset; | |
139 | { | |
140 | ! if (write_no_eol_lnum != 0) /* only if there is a missing eol */ | |
141 | ! write_no_eol_lnum += offset; | |
142 | } | |
143 | ||
144 | #if defined(TEMPDIRNAMES) || defined(PROTO) | |
145 | --- 7259,7266 ---- | |
146 | write_lnum_adjust(offset) | |
147 | linenr_T offset; | |
148 | { | |
149 | ! if (curbuf->b_no_eol_lnum != 0) /* only if there is a missing eol */ | |
150 | ! curbuf->b_no_eol_lnum += offset; | |
151 | } | |
152 | ||
153 | #if defined(TEMPDIRNAMES) || defined(PROTO) | |
154 | *** ../vim-7.3.123/src/globals.h 2010-12-02 21:43:10.000000000 +0100 | |
155 | --- src/globals.h 2011-02-15 17:06:06.000000000 +0100 | |
156 | *************** | |
157 | *** 1057,1066 **** | |
158 | ; | |
159 | #endif | |
160 | ||
161 | - EXTERN linenr_T write_no_eol_lnum INIT(= 0); /* non-zero lnum when last line | |
162 | - of next binary write should | |
163 | - not have an end-of-line */ | |
164 | - | |
165 | #ifdef FEAT_WINDOWS | |
166 | EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */ | |
167 | EXTERN int postponed_split_flags INIT(= 0); /* args for win_split() */ | |
168 | --- 1057,1062 ---- | |
169 | *** ../vim-7.3.123/src/os_unix.c 2011-02-09 18:47:36.000000000 +0100 | |
170 | --- src/os_unix.c 2011-02-15 17:07:22.000000000 +0100 | |
171 | *************** | |
172 | *** 4245,4251 **** | |
173 | * should not have one. */ | |
174 | if (lnum != curbuf->b_op_end.lnum | |
175 | || !curbuf->b_p_bin | |
176 | ! || (lnum != write_no_eol_lnum | |
177 | && (lnum != | |
178 | curbuf->b_ml.ml_line_count | |
179 | || curbuf->b_p_eol))) | |
180 | --- 4245,4251 ---- | |
181 | * should not have one. */ | |
182 | if (lnum != curbuf->b_op_end.lnum | |
183 | || !curbuf->b_p_bin | |
184 | ! || (lnum != curbuf->b_no_eol_lnum | |
185 | && (lnum != | |
186 | curbuf->b_ml.ml_line_count | |
187 | || curbuf->b_p_eol))) | |
188 | *************** | |
189 | *** 4588,4597 **** | |
190 | { | |
191 | append_ga_line(&ga); | |
192 | /* remember that the NL was missing */ | |
193 | ! write_no_eol_lnum = curwin->w_cursor.lnum; | |
194 | } | |
195 | else | |
196 | ! write_no_eol_lnum = 0; | |
197 | ga_clear(&ga); | |
198 | } | |
199 | ||
200 | --- 4588,4597 ---- | |
201 | { | |
202 | append_ga_line(&ga); | |
203 | /* remember that the NL was missing */ | |
204 | ! curbuf->b_no_eol_lnum = curwin->w_cursor.lnum; | |
205 | } | |
206 | else | |
207 | ! curbuf->b_no_eol_lnum = 0; | |
208 | ga_clear(&ga); | |
209 | } | |
210 | ||
211 | *** ../vim-7.3.123/src/version.c 2011-02-15 16:29:54.000000000 +0100 | |
212 | --- src/version.c 2011-02-15 17:37:38.000000000 +0100 | |
213 | *************** | |
214 | *** 716,717 **** | |
215 | --- 716,719 ---- | |
216 | { /* Add new patch number below this line */ | |
217 | + /**/ | |
218 | + 124, | |
219 | /**/ | |
220 | ||
221 | -- | |
222 | hundred-and-one symptoms of being an internet addict: | |
223 | 270. You are subscribed to a mailing list for every piece of software | |
224 | you use. | |
225 | ||
226 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
227 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
228 | \\\ an exciting new programming language -- http://www.Zimbu.org /// | |
229 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |