* mu-cmd-index: fix backspace printing (don't try to modify static str)
This commit is contained in:
@ -134,6 +134,28 @@ index_msg_silent_cb (MuIndexStats* stats, void *user_data)
|
|||||||
return MU_CAUGHT_SIGNAL ? MU_STOP: MU_OK;
|
return MU_CAUGHT_SIGNAL ? MU_STOP: MU_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
backspace (unsigned u)
|
||||||
|
{
|
||||||
|
static gboolean init = FALSE;
|
||||||
|
static char backspace[80];
|
||||||
|
|
||||||
|
if (G_UNLIKELY(!init)) {
|
||||||
|
/* fill with backspaces */
|
||||||
|
int i;
|
||||||
|
for (i = 0; i != sizeof(backspace); ++i)
|
||||||
|
backspace[i] = '\b';
|
||||||
|
init = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
backspace[MIN(u,sizeof(backspace))] = '\0';
|
||||||
|
fputs (backspace, stdout);
|
||||||
|
backspace[u] = '\b';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_stats (MuIndexStats* stats, gboolean clear)
|
print_stats (MuIndexStats* stats, gboolean clear)
|
||||||
{
|
{
|
||||||
@ -143,18 +165,9 @@ print_stats (MuIndexStats* stats, gboolean clear)
|
|||||||
static int i = 0;
|
static int i = 0;
|
||||||
static unsigned len = 0;
|
static unsigned len = 0;
|
||||||
|
|
||||||
if (clear) {
|
if (clear)
|
||||||
/* optimization, this function showed up in profiles */
|
backspace (len);
|
||||||
static char *backspace =
|
|
||||||
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
|
|
||||||
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
|
|
||||||
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
|
|
||||||
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
|
|
||||||
backspace[len] = '\0';
|
|
||||||
fputs (backspace, stdout);
|
|
||||||
backspace[len] = '\b';
|
|
||||||
}
|
|
||||||
|
|
||||||
len = (unsigned)snprintf (output, sizeof(output),
|
len = (unsigned)snprintf (output, sizeof(output),
|
||||||
"%c processing mail; processed: %u; "
|
"%c processing mail; processed: %u; "
|
||||||
"updated/new: %u, cleaned-up: %u",
|
"updated/new: %u, cleaned-up: %u",
|
||||||
|
|||||||
Reference in New Issue
Block a user