diff options
author | Frank Ch. Eigler <fche@redhat.com> | 2020-03-29 15:10:37 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@redhat.com> | 2020-03-29 15:13:47 -0400 |
commit | 03bb9dbb2d2ee515e3daee94ae1e2d36aeaedec7 (patch) | |
tree | 97cd671ca39abd4ff9b5950215396c35910ca103 /debuginfod/debuginfod-client.c | |
parent | b2035c1148209633fb006c9f384b744944256b77 (diff) | |
download | elfutils-03bb9dbb2d2ee515e3daee94ae1e2d36aeaedec7.tar.gz |
debuginfod-client default_progressfn: formatting fix
The saga of clean $DEBUGINFOD_PROGRESS=1 output continues. Previous
code would sometimes insert a \n (a blank line) into the output
stream, even if the target file was found in a cache and thus the
progressfn was never called. New code sets a client flag to track
this case more precisely.
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Diffstat (limited to 'debuginfod/debuginfod-client.c')
-rw-r--r-- | debuginfod/debuginfod-client.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 043e8aa2..fa017a84 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -89,6 +89,10 @@ struct debuginfod_client int user_agent_set_p; /* affects add_default_headers */ struct curl_slist *headers; + /* Flags the default_progressfn having printed something that + debuginfod_end needs to terminate. */ + int default_progressfn_printed_p; + /* Can contain all other context, like cache_path, server_urls, timeout or other info gotten from environment variables, the handle data, etc. So those don't have to be reparsed and @@ -438,6 +442,7 @@ default_progressfn (debuginfod_client *c, long a, long b) dprintf(STDERR_FILENO, "\rDownloading from %.*s %ld/%ld", len, url, a, b); + c->default_progressfn_printed_p = 1; return 0; } @@ -935,7 +940,10 @@ debuginfod_query_server (debuginfod_client *c, /* general purpose exit */ out: /* Conclude the last \r status line */ - if (c->progressfn == & default_progressfn) + /* Another possibility is to use the ANSI CSI n K EL "Erase in Line" + code. That way, the previously printed messages would be erased, + and without a newline. */ + if (c->default_progressfn_printed_p) dprintf(STDERR_FILENO, "\n"); free (cache_path); |