Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/common/lib/libutil apply some do { ... } while (0) so that m...
details: https://anonhg.NetBSD.org/src/rev/16ba9b33f5f6
branches: trunk
changeset: 789133:16ba9b33f5f6
user: mrg <mrg%NetBSD.org@localhost>
date: Thu Aug 08 04:32:43 2013 +0000
description:
apply some do { ... } while (0) so that macros aren't broken,
completing the previous change.
diffstat:
common/lib/libutil/snprintb.c | 58 ++++++++++++++++++++++--------------------
1 files changed, 30 insertions(+), 28 deletions(-)
diffs (100 lines):
diff -r 8c66a91c4f77 -r 16ba9b33f5f6 common/lib/libutil/snprintb.c
--- a/common/lib/libutil/snprintb.c Wed Aug 07 23:48:13 2013 +0000
+++ b/common/lib/libutil/snprintb.c Thu Aug 08 04:32:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: snprintb.c,v 1.11 2013/08/07 23:48:13 pgoyette Exp $ */
+/* $NetBSD: snprintb.c,v 1.12 2013/08/08 04:32:43 mrg Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
# include <sys/cdefs.h>
# if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: snprintb.c,v 1.11 2013/08/07 23:48:13 pgoyette Exp $");
+__RCSID("$NetBSD: snprintb.c,v 1.12 2013/08/08 04:32:43 mrg Exp $");
# endif
# include <sys/types.h>
@@ -51,7 +51,7 @@
# include <errno.h>
# else /* ! _KERNEL */
# include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.11 2013/08/07 23:48:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.12 2013/08/08 04:32:43 mrg Exp $");
# include <sys/param.h>
# include <sys/inttypes.h>
# include <sys/systm.h>
@@ -115,12 +115,12 @@
if ((val == 0) && (ch != '\177'))
goto terminate;
-#define STORE(c) { l_len++; \
+#define STORE(c) do { l_len++; \
if ((size_t)(++t_len) < buflen) \
*bp++ = (c); \
} while ( /* CONSTCOND */ 0)
-#define BACKUP { if (s_bp != NULL) { \
+#define BACKUP do { if (s_bp != NULL) { \
bp = s_bp; s_bp = NULL; \
t_len -= l_len - s_len; \
restart = 1; \
@@ -132,32 +132,34 @@
t_len += v_len; l_len = v_len; bp += v_len; \
} while ( /* CONSTCOND */ 0)
-#define PUTSEP \
- if (l_max > 0 && (size_t)l_len >= l_max) { \
- BACKUP; \
- STORE('<'); \
- } else { \
- /* Remember separator location */ \
- if (l_max > 0 && sep != '<') { \
- s_len = l_len; \
- s_bp = bp; \
- s_fmt = cur_fmt; \
+#define PUTSEP do { \
+ if (l_max > 0 && (size_t)l_len >= l_max) { \
+ BACKUP; \
+ STORE('<'); \
+ } else { \
+ /* Remember separator location */ \
+ if (l_max > 0 && sep != '<') { \
+ s_len = l_len; \
+ s_bp = bp; \
+ s_fmt = cur_fmt; \
+ } \
+ STORE(sep); \
+ restart = 0; \
} \
- STORE(sep); \
- restart = 0; \
- } \
+ } while ( /* CONSTCOND */ 0)
-#define PUTCHR(c) \
- if (l_max > 0 && (size_t)l_len >= (l_max - 1)) { \
- BACKUP; \
- if (restart == 0) { \
+#define PUTCHR(c) do { \
+ if (l_max > 0 && (size_t)l_len >= (l_max - 1)) {\
+ BACKUP; \
+ if (restart == 0) { \
+ STORE(c); \
+ } else \
+ sep = '<'; \
+ } else { \
STORE(c); \
- } else \
- sep = '<'; \
- } else { \
- STORE(c); \
- restart = 0; \
- } \
+ restart = 0; \
+ } \
+ } while ( /* CONSTCOND */ 0)
#define PUTS(s) while ((ch = *(s)++) != 0) { \
PUTCHR(ch); \
Home |
Main Index |
Thread Index |
Old Index