+static void printstr( const char * str, struct _PDCLIB_status_t * status )
+{
+ if ( status->width == 0 || status->flags & E_minus )
+ {
+ // Simple case or left justification
+ while ( str[status->current] &&
+ ( status->prec < 0 || (long)status->current < status->prec ) )
+ {
+ PUT( str[status->current++] );
+ }
+
+ while( status->current < status->width )
+ {
+ PUT( ' ' );
+ status->current++;
+ }
+ } else {
+ // Right justification
+ size_t len = status->prec >= 0 ? strnlen( str, status->prec )
+ : strlen( str );
+ int padding = status->width - len;
+ while((long)status->current < padding)
+ {
+ PUT( ' ' );
+ status->current++;
+ }
+
+ for( size_t i = 0; i != len; i++ )
+ {
+ PUT( str[i] );
+ status->current++;
+ }
+ }
+}
+
+static void printchar( char chr, struct _PDCLIB_status_t * status )
+{
+ if( ! ( status->flags & E_minus ) )
+ {
+ // Right justification
+ for( ; status->current + 1 < status->width; status->current++)
+ {
+ PUT( ' ' );
+ }
+ PUT( chr );
+ status->current++;
+ } else {
+ // Left justification
+ PUT( chr );
+ status->current++;
+
+ for( ; status->current < status->width; status->current++)
+ {
+ PUT( ' ' );
+ }
+ }
+}
+