fix line wrapping before info messages

unless an info message is explictly marked as a continuation, it must
terminate any pending line (typically the progress information) first.

debug output is not affected, as it is mutually exclusive with info
output, and no debug lines are left unterminated outside clear scopes.
This commit is contained in:
Oswald Buddenhagen 2012-09-01 17:21:32 +02:00
parent 2aae866e80
commit 7c815538ab
3 changed files with 17 additions and 8 deletions

View File

@ -374,7 +374,7 @@ socket_connect( conn_t *sock, void (*cb)( int ok, void *aux ) )
error( "IMAP error: Cannot resolve server '%s'\n", conf->host );
goto bail;
}
info( "ok\n" );
info( "\vok\n" );
addr.sin_addr.s_addr = *((int *)he->h_addr_list[0]);
@ -398,12 +398,12 @@ socket_connect( conn_t *sock, void (*cb)( int ok, void *aux ) )
}
conf_fd( s, 0, POLLOUT );
sock->state = SCK_CONNECTING;
info( "\n" );
info( "\v\n" );
return;
}
}
info( "ok\n" );
info( "\vok\n" );
socket_connected2( sock );
return;

View File

@ -419,7 +419,7 @@ stats( sync_vars_t *svars )
if (l > cols)
buf[t][cols - 1] = '~';
}
infon( "\rM: %.*s S: %.*s", cols, buf[0], cols, buf[1] );
infon( "\v\rM: %.*s S: %.*s", cols, buf[0], cols, buf[1] );
}
}

View File

@ -43,6 +43,17 @@ flushn( void )
}
}
static void
printn( const char *msg, va_list va )
{
if (*msg == '\v')
msg++;
else
flushn();
vprintf( msg, va );
fflush( stdout );
}
void
debug( const char *msg, ... )
{
@ -78,9 +89,8 @@ info( const char *msg, ... )
if (!(DFlags & QUIET)) {
va_start( va, msg );
vprintf( msg, va );
printn( msg, va );
va_end( va );
fflush( stdout );
need_nl = 0;
}
}
@ -92,9 +102,8 @@ infon( const char *msg, ... )
if (!(DFlags & QUIET)) {
va_start( va, msg );
vprintf( msg, va );
printn( msg, va );
va_end( va );
fflush( stdout );
need_nl = 1;
}
}