From 739294f4aaa7734eb73bed785302dc64626c4ff1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 28 Oct 2009 11:25:29 +0100 Subject: [PATCH] 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). --- ChangeLog | 7 +++++++ lib/strftime.c | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32405a9843..7982453a86 100644 --- 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 index 4467415a5e..7d64c15264 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -199,6 +199,8 @@ extern char *tzname[]; #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 @@ extern char *tzname[]; 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), \ -- 2.30.2