Skip to content

Commit

Permalink
Fix bug causing file transfer status bars to be truncated
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman committed Nov 26, 2020
1 parent 8d9d516 commit 0434ac1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/file_transfers.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ void print_progress_bar(ToxWindow *self, double bps, double pct_done, uint32_t l
return;
}

char pct_str[STR_BUF_SIZE] = {0};
char pct_str[STR_BUF_SIZE];
snprintf(pct_str, sizeof(pct_str), "%.1f%%", pct_done);

char bps_str[STR_BUF_SIZE] = {0};
char bps_str[STR_BUF_SIZE];
bytes_convert_str(bps_str, sizeof(bps_str), bps);

char prog_line[NUM_PROG_MARKS + 1] = {0};
char prog_line[NUM_PROG_MARKS + 1];
prog_line[0] = 0;

int n = pct_done / (100 / NUM_PROG_MARKS);
int i, j;

Expand Down
3 changes: 3 additions & 0 deletions src/line_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,9 @@ void line_info_set(ToxWindow *self, uint32_t id, char *msg)

while (line) {
if (line->id == id) {
size_t new_len = strlen(msg);
line->len = line->len - line->msg_len + new_len;
line->msg_len = new_len;
snprintf(line->msg, sizeof(line->msg), "%s", msg);
return;
}
Expand Down

0 comments on commit 0434ac1

Please sign in to comment.