4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Warnings for not checking return value of fwrite(). (Chip Campbell)
12 Solution: Use the return value.
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
24 + int fwv = 1; /* collect return value of fwrite() to avoid
25 + warnings from picky compiler */
27 fd = mch_fopen((char *)fname, "w");
32 /* <HEADER>: <fileID> <versionnr> */
34 ! if (fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd) != 1)
39 putc(VIMSPELLVERSION, fd); /* <versionnr> */
44 /* <HEADER>: <fileID> <versionnr> */
46 ! fwv &= fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd);
47 putc(VIMSPELLVERSION, fd); /* <versionnr> */
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> */
58 /* SN_REGION: <regionname> ...
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> */
66 /* SN_REGION: <regionname> ...
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;
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;
88 put_bytes(fd, (long_u)l, 2); /* <folcharslen> */
89 ! fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */
92 /* SN_MIDWORD: <midword> */
96 put_bytes(fd, (long_u)l, 2); /* <folcharslen> */
97 ! fwv &= fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */
100 /* SN_MIDWORD: <midword> */
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> */
109 /* SN_PREFCOND: <prefcondcnt> <prefcond> ... */
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);
118 /* SN_PREFCOND: <prefcondcnt> <prefcond> ... */
121 p = rr == 1 ? ftp->ft_from : ftp->ft_to;
124 ! fwrite(p, l, (size_t)1, fd);
129 p = rr == 1 ? ftp->ft_from : ftp->ft_to;
132 ! fwv &= fwrite(p, l, (size_t)1, fd);
140 put_bytes(fd, (long_u)l, 2); /* <sofofromlen> */
141 ! fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */
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> */
148 /* SN_WORDS: <word> ...
152 put_bytes(fd, (long_u)l, 2); /* <sofofromlen> */
153 ! fwv &= fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */
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> */
160 /* SN_WORDS: <word> ...
163 l = (int)STRLEN(hi->hi_key) + 1;
165 if (round == 2) /* <word> */
166 ! fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
171 l = (int)STRLEN(hi->hi_key) + 1;
173 if (round == 2) /* <word> */
174 ! fwv &= fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
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);
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);
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> */
203 ! fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
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> */
215 ! fwv &= fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
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> */
227 /* end of <SECTIONS> */
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);
236 /* end of <SECTIONS> */
239 (void)put_node(fd, tree, 0, regionmask, round == 3);
242 ! /* Write another byte to check for errors. */
243 if (putc(0, fd) == EOF)
246 if (fclose(fd) == EOF)
253 (void)put_node(fd, tree, 0, regionmask, round == 3);
256 ! /* Write another byte to check for errors (file system full). */
257 if (putc(0, fd) == EOF)
260 if (fclose(fd) == EOF)
265 + if (retval == FAIL)
277 + int x = 1; /* collect return value of fwrite() */
280 put_bytes(fd, (long_u)gap->ga_len, 2); /* <prefcondcnt> */
286 ! fwrite(p, (size_t)len, (size_t)1, fd);
294 ! x &= fwrite(p, (size_t)len, (size_t)1, fd);
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
303 { /* Add new patch number below this line */
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
313 /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///