i - pointer to number of characters already delivered in this call
n - pointer to maximum number of characters to be delivered in this call
s - the buffer into which the character shall be delivered
- TODO: Overruns.
*/
#define DELIVER( x ) do { if ( status->i < status->n ) { if ( status->stream != NULL ) putc( x, status->stream ); else status->s[status->i] = x; } ++(status->i); } while ( 0 )
if ( ( status->flags & E_alt ) && ( status->base == 16 || status->base == 8 ) )
{
/* Octal / hexadecimal prefix for "%#" conversions */
- preface[ preidx++ ] = '0'; /* TODO: For octal, standard states "extend the precision" */
+ preface[ preidx++ ] = '0';
if ( status->base == 16 )
{
preface[ preidx++ ] = ( status->flags & E_lower ) ? 'x' : 'X';
for ( int i = 0; i < status->width - characters; ++i )
{
DELIVER( ' ' );
- ++(status->this); /* TODO: Probably have to do something so I still know how many zeroes are required, later. */
+ ++(status->this);
}
}
}
if ( ( ! ( status->flags & E_minus ) ) && ( status->flags & E_zero ) )
{
/* If field is not left aligned, and zero padding is requested, do
- so. TODO: This should include precision handling (probably).
+ so.
*/
while ( status->this < status->width )
{
++(status->this);
}
}
+ /* Do the precision padding if necessary. */
for ( int i = 0; i < prec_pads; ++i )
{
DELIVER( '0' );
const char * orig_spec = spec;
if ( *(++spec) == '%' )
{
- return spec;
+ DELIVER( *spec );
+ return ++spec;
}
/* Initializing status structure */
status->flags = 0;