Bugzilla – Attachment 2942 Details for
Bug 2434
scp can send arbitrary control characters / escape sequences to the terminal
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Simplify population of file name display
0001-Simplify-population-of-file-name-display.patch (text/plain), 1.84 KB, created by
Darren Tucker
on 2017-02-15 16:46:06 AEDT
(
hide
)
Description:
Simplify population of file name display
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2017-02-15 16:46:06 AEDT
Size:
1.84 KB
patch
obsolete
>From 8112491a65d0a5dbaa0a7ee718f98d91a6f30a34 Mon Sep 17 00:00:00 2001 >From: Darren Tucker <dtucker@zip.com.au> >Date: Wed, 15 Feb 2017 14:51:32 +1100 >Subject: [PATCH 1/2] Simplify population of file name display. > >This keeps the padded and/or truncated displayname in its own variable >which will allow later use of non-signal-safe functions like snmprintf >to compose it. >--- > progressmeter.c | 20 +++++--------------- > 1 file changed, 5 insertions(+), 15 deletions(-) > >diff --git a/progressmeter.c b/progressmeter.c >index fe9bf52..4d924c5 100644 >--- a/progressmeter.c >+++ b/progressmeter.c >@@ -119,14 +119,13 @@ format_size(char *buf, int size, off_t bytes) > void > refresh_progress_meter(void) > { >- char buf[MAX_WINSIZE + 1]; >+ char buf[MAX_WINSIZE + 1], displayname[MAX_WINSIZE]; > off_t transferred; > double elapsed, now; > int percent; > off_t bytes_left; > int cur_speed; > int hours, minutes, seconds; >- int i, len; > int file_len; > > transferred = *counter - (cur_pos ? cur_pos : start_pos); >@@ -157,26 +156,17 @@ refresh_progress_meter(void) > bytes_per_second = cur_speed; > > /* filename */ >- buf[0] = '\0'; > file_len = win_size - 35; >- if (file_len > 0) { >- len = snprintf(buf, file_len + 1, "\r%s", file); >- if (len < 0) >- len = 0; >- if (len >= file_len + 1) >- len = file_len; >- for (i = len; i < file_len; i++) >- buf[i] = ' '; >- buf[file_len] = '\0'; >- } >+ displayname[0] = '\0'; >+ if (file_len > 0) >+ snprintf(displayname, file_len, "%*s ", file_len * -1, file); > > /* percent of transfer done */ > if (end_pos == 0 || cur_pos == end_pos) > percent = 100; > else > percent = ((float)cur_pos / end_pos) * 100; >- snprintf(buf + strlen(buf), win_size - strlen(buf), >- " %3d%% ", percent); >+ snprintf(buf, sizeof(buf), "\r%s %3d%% ", displayname, percent); > > /* amount transferred */ > format_size(buf + strlen(buf), win_size - strlen(buf), >-- >2.7.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 2434
:
2678
|
2858
|
2942
|
2943
|
3228