1 To: [email protected] |
|
2 Subject: Patch 7.2.050 |
|
3 Fcc: outbox |
|
4 From: Bram Moolenaar <[email protected]> |
|
5 Mime-Version: 1.0 |
|
6 Content-Type: text/plain; charset=ISO-8859-1 |
|
7 Content-Transfer-Encoding: 8bit |
|
8 ------------ |
|
9 |
|
10 Patch 7.2.050 |
|
11 Problem: Warnings for not checking return value of fwrite(). (Chip Campbell) |
|
12 Solution: Use the return value. |
|
13 Files: src/spell.c |
|
14 |
|
15 |
|
16 *** ../vim-7.2.049/src/spell.c Mon Aug 25 04:12:38 2008 |
|
17 --- src/spell.c Thu Nov 20 17:28:01 2008 |
|
18 *************** |
|
19 *** 7926,7931 **** |
|
20 --- 7926,7933 ---- |
|
21 char_u *p; |
|
22 int rr; |
|
23 int retval = OK; |
|
24 + int fwv = 1; /* collect return value of fwrite() to avoid |
|
25 + warnings from picky compiler */ |
|
26 |
|
27 fd = mch_fopen((char *)fname, "w"); |
|
28 if (fd == NULL) |
|
29 *************** |
|
30 *** 7936,7946 **** |
|
31 |
|
32 /* <HEADER>: <fileID> <versionnr> */ |
|
33 /* <fileID> */ |
|
34 ! if (fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd) != 1) |
|
35 ! { |
|
36 ! EMSG(_(e_write)); |
|
37 ! retval = FAIL; |
|
38 ! } |
|
39 putc(VIMSPELLVERSION, fd); /* <versionnr> */ |
|
40 |
|
41 /* |
|
42 --- 7938,7944 ---- |
|
43 |
|
44 /* <HEADER>: <fileID> <versionnr> */ |
|
45 /* <fileID> */ |
|
46 ! fwv &= fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd); |
|
47 putc(VIMSPELLVERSION, fd); /* <versionnr> */ |
|
48 |
|
49 /* |
|
50 *************** |
|
51 *** 7955,7961 **** |
|
52 |
|
53 i = (int)STRLEN(spin->si_info); |
|
54 put_bytes(fd, (long_u)i, 4); /* <sectionlen> */ |
|
55 ! fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */ |
|
56 } |
|
57 |
|
58 /* SN_REGION: <regionname> ... |
|
59 --- 7953,7959 ---- |
|
60 |
|
61 i = (int)STRLEN(spin->si_info); |
|
62 put_bytes(fd, (long_u)i, 4); /* <sectionlen> */ |
|
63 ! fwv &= fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */ |
|
64 } |
|
65 |
|
66 /* SN_REGION: <regionname> ... |
|
67 *************** |
|
68 *** 7966,7972 **** |
|
69 putc(SNF_REQUIRED, fd); /* <sectionflags> */ |
|
70 l = spin->si_region_count * 2; |
|
71 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */ |
|
72 ! fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd); |
|
73 /* <regionname> ... */ |
|
74 regionmask = (1 << spin->si_region_count) - 1; |
|
75 } |
|
76 --- 7964,7970 ---- |
|
77 putc(SNF_REQUIRED, fd); /* <sectionflags> */ |
|
78 l = spin->si_region_count * 2; |
|
79 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */ |
|
80 ! fwv &= fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd); |
|
81 /* <regionname> ... */ |
|
82 regionmask = (1 << spin->si_region_count) - 1; |
|
83 } |
|
84 *************** |
|
85 *** 8016,8022 **** |
|
86 } |
|
87 |
|
88 put_bytes(fd, (long_u)l, 2); /* <folcharslen> */ |
|
89 ! fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */ |
|
90 } |
|
91 |
|
92 /* SN_MIDWORD: <midword> */ |
|
93 --- 8014,8020 ---- |
|
94 } |
|
95 |
|
96 put_bytes(fd, (long_u)l, 2); /* <folcharslen> */ |
|
97 ! fwv &= fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */ |
|
98 } |
|
99 |
|
100 /* SN_MIDWORD: <midword> */ |
|
101 *************** |
|
102 *** 8027,8033 **** |
|
103 |
|
104 i = (int)STRLEN(spin->si_midword); |
|
105 put_bytes(fd, (long_u)i, 4); /* <sectionlen> */ |
|
106 ! fwrite(spin->si_midword, (size_t)i, (size_t)1, fd); /* <midword> */ |
|
107 } |
|
108 |
|
109 /* SN_PREFCOND: <prefcondcnt> <prefcond> ... */ |
|
110 --- 8025,8032 ---- |
|
111 |
|
112 i = (int)STRLEN(spin->si_midword); |
|
113 put_bytes(fd, (long_u)i, 4); /* <sectionlen> */ |
|
114 ! fwv &= fwrite(spin->si_midword, (size_t)i, (size_t)1, fd); |
|
115 ! /* <midword> */ |
|
116 } |
|
117 |
|
118 /* SN_PREFCOND: <prefcondcnt> <prefcond> ... */ |
|
119 *************** |
|
120 *** 8113,8119 **** |
|
121 p = rr == 1 ? ftp->ft_from : ftp->ft_to; |
|
122 l = (int)STRLEN(p); |
|
123 putc(l, fd); |
|
124 ! fwrite(p, l, (size_t)1, fd); |
|
125 } |
|
126 } |
|
127 |
|
128 --- 8112,8118 ---- |
|
129 p = rr == 1 ? ftp->ft_from : ftp->ft_to; |
|
130 l = (int)STRLEN(p); |
|
131 putc(l, fd); |
|
132 ! fwv &= fwrite(p, l, (size_t)1, fd); |
|
133 } |
|
134 } |
|
135 |
|
136 *************** |
|
137 *** 8131,8141 **** |
|
138 /* <sectionlen> */ |
|
139 |
|
140 put_bytes(fd, (long_u)l, 2); /* <sofofromlen> */ |
|
141 ! fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */ |
|
142 |
|
143 l = (int)STRLEN(spin->si_sofoto); |
|
144 put_bytes(fd, (long_u)l, 2); /* <sofotolen> */ |
|
145 ! fwrite(spin->si_sofoto, l, (size_t)1, fd); /* <sofoto> */ |
|
146 } |
|
147 |
|
148 /* SN_WORDS: <word> ... |
|
149 --- 8130,8140 ---- |
|
150 /* <sectionlen> */ |
|
151 |
|
152 put_bytes(fd, (long_u)l, 2); /* <sofofromlen> */ |
|
153 ! fwv &= fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */ |
|
154 |
|
155 l = (int)STRLEN(spin->si_sofoto); |
|
156 put_bytes(fd, (long_u)l, 2); /* <sofotolen> */ |
|
157 ! fwv &= fwrite(spin->si_sofoto, l, (size_t)1, fd); /* <sofoto> */ |
|
158 } |
|
159 |
|
160 /* SN_WORDS: <word> ... |
|
161 *************** |
|
162 *** 8160,8166 **** |
|
163 l = (int)STRLEN(hi->hi_key) + 1; |
|
164 len += l; |
|
165 if (round == 2) /* <word> */ |
|
166 ! fwrite(hi->hi_key, (size_t)l, (size_t)1, fd); |
|
167 --todo; |
|
168 } |
|
169 if (round == 1) |
|
170 --- 8159,8165 ---- |
|
171 l = (int)STRLEN(hi->hi_key) + 1; |
|
172 len += l; |
|
173 if (round == 2) /* <word> */ |
|
174 ! fwv &= fwrite(hi->hi_key, (size_t)l, (size_t)1, fd); |
|
175 --todo; |
|
176 } |
|
177 if (round == 1) |
|
178 *************** |
|
179 *** 8176,8182 **** |
|
180 putc(0, fd); /* <sectionflags> */ |
|
181 l = spin->si_map.ga_len; |
|
182 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */ |
|
183 ! fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd); |
|
184 /* <mapstr> */ |
|
185 } |
|
186 |
|
187 --- 8175,8181 ---- |
|
188 putc(0, fd); /* <sectionflags> */ |
|
189 l = spin->si_map.ga_len; |
|
190 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */ |
|
191 ! fwv &= fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd); |
|
192 /* <mapstr> */ |
|
193 } |
|
194 |
|
195 *************** |
|
196 *** 8232,8241 **** |
|
197 { |
|
198 p = ((char_u **)(spin->si_comppat.ga_data))[i]; |
|
199 putc((int)STRLEN(p), fd); /* <comppatlen> */ |
|
200 ! fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);/* <comppattext> */ |
|
201 } |
|
202 /* <compflags> */ |
|
203 ! fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags), |
|
204 (size_t)1, fd); |
|
205 } |
|
206 |
|
207 --- 8231,8241 ---- |
|
208 { |
|
209 p = ((char_u **)(spin->si_comppat.ga_data))[i]; |
|
210 putc((int)STRLEN(p), fd); /* <comppatlen> */ |
|
211 ! fwv &= fwrite(p, (size_t)STRLEN(p), (size_t)1, fd); |
|
212 ! /* <comppattext> */ |
|
213 } |
|
214 /* <compflags> */ |
|
215 ! fwv &= fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags), |
|
216 (size_t)1, fd); |
|
217 } |
|
218 |
|
219 *************** |
|
220 *** 8259,8265 **** |
|
221 |
|
222 l = (int)STRLEN(spin->si_syllable); |
|
223 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */ |
|
224 ! fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd); /* <syllable> */ |
|
225 } |
|
226 |
|
227 /* end of <SECTIONS> */ |
|
228 --- 8259,8266 ---- |
|
229 |
|
230 l = (int)STRLEN(spin->si_syllable); |
|
231 put_bytes(fd, (long_u)l, 4); /* <sectionlen> */ |
|
232 ! fwv &= fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd); |
|
233 ! /* <syllable> */ |
|
234 } |
|
235 |
|
236 /* end of <SECTIONS> */ |
|
237 *************** |
|
238 *** 8295,8307 **** |
|
239 (void)put_node(fd, tree, 0, regionmask, round == 3); |
|
240 } |
|
241 |
|
242 ! /* Write another byte to check for errors. */ |
|
243 if (putc(0, fd) == EOF) |
|
244 retval = FAIL; |
|
245 |
|
246 if (fclose(fd) == EOF) |
|
247 retval = FAIL; |
|
248 |
|
249 return retval; |
|
250 } |
|
251 |
|
252 --- 8296,8313 ---- |
|
253 (void)put_node(fd, tree, 0, regionmask, round == 3); |
|
254 } |
|
255 |
|
256 ! /* Write another byte to check for errors (file system full). */ |
|
257 if (putc(0, fd) == EOF) |
|
258 retval = FAIL; |
|
259 |
|
260 if (fclose(fd) == EOF) |
|
261 retval = FAIL; |
|
262 |
|
263 + if (fwv != 1) |
|
264 + retval = FAIL; |
|
265 + if (retval == FAIL) |
|
266 + EMSG(_(e_write)); |
|
267 + |
|
268 return retval; |
|
269 } |
|
270 |
|
271 *************** |
|
272 *** 9890,9895 **** |
|
273 --- 9896,9902 ---- |
|
274 char_u *p; |
|
275 int len; |
|
276 int totlen; |
|
277 + int x = 1; /* collect return value of fwrite() */ |
|
278 |
|
279 if (fd != NULL) |
|
280 put_bytes(fd, (long_u)gap->ga_len, 2); /* <prefcondcnt> */ |
|
281 *************** |
|
282 *** 9906,9912 **** |
|
283 if (fd != NULL) |
|
284 { |
|
285 fputc(len, fd); |
|
286 ! fwrite(p, (size_t)len, (size_t)1, fd); |
|
287 } |
|
288 totlen += len; |
|
289 } |
|
290 --- 9913,9919 ---- |
|
291 if (fd != NULL) |
|
292 { |
|
293 fputc(len, fd); |
|
294 ! x &= fwrite(p, (size_t)len, (size_t)1, fd); |
|
295 } |
|
296 totlen += len; |
|
297 } |
|
298 *** ../vim-7.2.049/src/version.c Thu Nov 20 17:09:09 2008 |
|
299 --- src/version.c Fri Nov 28 10:06:13 2008 |
|
300 *************** |
|
301 *** 678,679 **** |
|
302 --- 678,681 ---- |
|
303 { /* Add new patch number below this line */ |
|
304 + /**/ |
|
305 + 50, |
|
306 /**/ |
|
307 |
|
308 -- |
|
309 You got to work at a mill? Lucky! I got sent back to work in the |
|
310 acid-mines for my daily crust of stale bread... which not even the |
|
311 birds would eat. |
|
312 |
|
313 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ |
|
314 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
|
315 \\\ download, build and distribute -- http://www.A-A-P.org /// |
|
316 \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |
|