There's only 9 snprintf() calls. I could simply provide a macro:
#define ADD_TEXT(dest, end, format, ...) \
{ \
int len, max = (end) - (dest); \
len = snprintf((dest), max, (format), __VA_ARGS__); \
if (len > max) \
return; \
(dest) += len; \
}
Then all of the snprintf() calls become simply
ADD_TEXT(cp, ep, <format>, ...);
(Of course, after last use I'd add a #undef ADD_TEXT to clean up...)
+------------------+--------------------------+------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+