From 7c815538ab32eb7265131ea86ea2de1cd301c8ed Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 1 Sep 2012 17:21:32 +0200 Subject: [PATCH] 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. --- src/socket.c | 6 +++--- src/sync.c | 2 +- src/util.c | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/socket.c b/src/socket.c index ca44bb3..f9c8a05 100644 --- a/src/socket.c +++ b/src/socket.c @@ -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; diff --git a/src/sync.c b/src/sync.c index d8c9af8..f951a7c 100644 --- a/src/sync.c +++ b/src/sync.c @@ -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] ); } } diff --git a/src/util.c b/src/util.c index 83b7a76..d3f1638 100644 --- a/src/util.c +++ b/src/util.c @@ -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; } }