Mercurial > hg > octave-kai > gnulib-hg
comparison lib/strftime.c @ 12206:5b7b0b8645f1
fprintftime: wrap macro code argument in "do {...} while(0)"
* lib/strftime.c (cpy) [FPRINTFTIME]: The second argument to the
cpy macro must be a statement that can be followed by a semicolon.
Now that the else clause contains a comment and is hence longer
than one line, I require curly braces. That in turn requires
that we wrap this code block in the standard do...while(0).
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Wed, 28 Oct 2009 11:25:29 +0100 |
parents | bd01eb4a7146 |
children | 37417e58ec13 |
comparison
equal
deleted
inserted
replaced
12205:bd01eb4a7146 | 12206:5b7b0b8645f1 |
---|---|
197 #endif | 197 #endif |
198 | 198 |
199 #if FPRINTFTIME | 199 #if FPRINTFTIME |
200 # define cpy(n, s) \ | 200 # define cpy(n, s) \ |
201 add ((n), \ | 201 add ((n), \ |
202 do \ | |
203 { \ | |
202 if (to_lowcase) \ | 204 if (to_lowcase) \ |
203 fwrite_lowcase (p, (s), _n); \ | 205 fwrite_lowcase (p, (s), _n); \ |
204 else if (to_uppcase) \ | 206 else if (to_uppcase) \ |
205 fwrite_uppcase (p, (s), _n); \ | 207 fwrite_uppcase (p, (s), _n); \ |
206 else \ | 208 else \ |
209 fact that technically, that may not be valid: the fwrite \ | 211 fact that technically, that may not be valid: the fwrite \ |
210 specification in POSIX 2008 defers to that of fputc, which \ | 212 specification in POSIX 2008 defers to that of fputc, which \ |
211 is intended to be consistent with the one from ISO C, \ | 213 is intended to be consistent with the one from ISO C, \ |
212 which permits failure due to ENOMEM *without* setting the \ | 214 which permits failure due to ENOMEM *without* setting the \ |
213 stream's error indicator. */ \ | 215 stream's error indicator. */ \ |
214 ignore_value (fwrite ((s), _n, 1, p))) \ | 216 ignore_value (fwrite ((s), _n, 1, p)); \ |
215 } | 217 } \ |
218 } \ | |
219 while (0) \ | |
220 ) | |
216 #else | 221 #else |
217 # define cpy(n, s) \ | 222 # define cpy(n, s) \ |
218 add ((n), \ | 223 add ((n), \ |
219 if (to_lowcase) \ | 224 if (to_lowcase) \ |
220 memcpy_lowcase (p, (s), _n LOCALE_ARG); \ | 225 memcpy_lowcase (p, (s), _n LOCALE_ARG); \ |