if ( ( *format != '%' ) || ( ( rc = _PDCLIB_print( format, &status ) ) == format ) )
{
/* No conversion specifier, print verbatim */
- s[ status.i++ ] = *(format++);
+ if ( status.i < n )
+ {
+ s[ status.i ] = *format;
+ }
+ status.i++;
+ format++;
}
else
{
format = rc;
}
}
- s[ status.i ] = '\0';
+ if ( status.i < n )
+ {
+ s[ status.i ] = '\0';
+ }
va_end( status.arg );
return status.i;
}
#ifdef TEST
#define _PDCLIB_FILEID "stdio/vsnprintf.c"
-#include <_PDCLIB_test.h>
+#define _PDCLIB_STRINGIO
-#include <limits.h>
-#include <stdint.h>
-#include <string.h>
+#include <_PDCLIB_test.h>
static int testprintf( char * s, const char * format, ... )
{
int main( void )
{
char target[100];
-#include "printf_testcases.incl"
+#include "printf_testcases.h"
return TEST_RESULTS;
}