-static int sprints( char * _PDCLIB_restrict dest, const char * _PDCLIB_restrict src, size_t maxsize, size_t * rc )
-{
- size_t len = strlen( src );
- if ( *rc < ( maxsize - len ) )
- {
- strcpy( dest + *rc, src );
- *rc += len;
- return 1;
- }
- else
- {
- return 0;
+/* Assuming presence of s, rc, maxsize.
+ Checks index for valid range, target buffer for sufficient remaining
+ capacity, and copies the locale-specific string (or "?" if index out
+ of range). Returns with zero if buffer capacity insufficient.
+*/
+#define SPRINTSTR( array, index, max ) \
+ { \
+ const char * str = "?"; \
+ if ( index >= 0 && index <= max ) \
+ { \
+ str = array[ index ]; \
+ } \
+ size_t len = strlen( str ); \
+ if ( rc < ( maxsize - len ) ) \
+ { \
+ strcpy( s + rc, str ); \
+ rc += len; \
+ } \
+ else \
+ { \
+ return 0; \
+ } \