# HG changeset patch # User Jim Meyering # Date 1256725529 -3600 # Node ID 5b7b0b8645f11520e9f481663bd943902bfc842f # Parent bd01eb4a71461ea6ea7e925aa3aa6d999e1ea262 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). diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2009-10-28 Jim Meyering + 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). + fprintftime: remove stray semicolon from previous change * lib/strftime.c (cpy) [FPRINTFTIME]: Remove trailing semicolon. diff --git a/lib/strftime.c b/lib/strftime.c --- a/lib/strftime.c +++ b/lib/strftime.c @@ -199,6 +199,8 @@ #if FPRINTFTIME # define cpy(n, s) \ add ((n), \ + do \ + { \ if (to_lowcase) \ fwrite_lowcase (p, (s), _n); \ else if (to_uppcase) \ @@ -211,8 +213,11 @@ is intended to be consistent with the one from ISO C, \ which permits failure due to ENOMEM *without* setting the \ stream's error indicator. */ \ - ignore_value (fwrite ((s), _n, 1, p))) \ - } + ignore_value (fwrite ((s), _n, 1, p)); \ + } \ + } \ + while (0) \ + ) #else # define cpy(n, s) \ add ((n), \