Skip to content

Commit

Permalink
Fix reducing bar length crashes on smaller screens
Browse files Browse the repository at this point in the history
The "Copying at..." string can be > reduced length
  • Loading branch information
jarun committed Dec 6, 2020
1 parent a7d942a commit fa08fed
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions advcpmv-0.8-8.32.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
--- coreutils-8.32/src/copy.c 2020-01-01 19:43:12.000000000 +0530
+++ coreutils-8.32-patched/src/copy.c 2020-10-26 19:27:59.398765746 +0530
+++ coreutils-8.32-patched/src/copy.c 2020-12-06 22:25:53.076852462 +0530
@@ -129,6 +129,72 @@
dev_t dev;
};
Expand Down Expand Up @@ -222,7 +222,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
goto fail;

dest_pos = ext_start + n_read;
@@ -1305,6 +1467,70 @@
@@ -1305,6 +1467,71 @@
buf_alloc = xmalloc (buf_size + buf_alignment);
buf = ptr_align (buf_alloc, buf_alignment);

Expand All @@ -233,7 +233,8 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
+ int iBarLength = 80;
+ struct winsize win;
+ if ( ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &win) == 0 && win.ws_col > 0 )
+ iBarLength = win.ws_col;
+ if (win.ws_col > iBarLength) /* String printed may be longer on smaller screens */
+ iBarLength = win.ws_col;
+ /* create rows */
+ int it;
+ for ( it = 0; it < 6; it++ )
Expand Down Expand Up @@ -293,7 +294,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
if (sparse_src)
{
bool normal_copy_required;
@@ -1316,7 +1542,9 @@
@@ -1316,7 +1543,9 @@
if (extent_copy (source_desc, dest_desc, buf, buf_size, hole_size,
src_open_sb.st_size,
make_holes ? x->sparse_mode : SPARSE_NEVER,
Expand All @@ -304,7 +305,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
goto preserve_metadata;

if (! normal_copy_required)
@@ -1328,11 +1556,12 @@
@@ -1328,11 +1557,12 @@

off_t n_read;
bool wrote_hole_at_eof;
Expand All @@ -320,7 +321,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
{
return_val = false;
goto close_src_and_dst_desc;
@@ -1343,6 +1572,14 @@
@@ -1343,6 +1573,14 @@
return_val = false;
goto close_src_and_dst_desc;
}
Expand All @@ -337,7 +338,7 @@ diff -aur coreutils-8.32/src/copy.c coreutils-8.32-patched/src/copy.c
preserve_metadata:
diff -aur coreutils-8.32/src/copy.h coreutils-8.32-patched/src/copy.h
--- coreutils-8.32/src/copy.h 2020-01-01 19:43:12.000000000 +0530
+++ coreutils-8.32-patched/src/copy.h 2020-10-26 19:27:11.298040234 +0530
+++ coreutils-8.32-patched/src/copy.h 2020-12-06 22:24:03.488405684 +0530
@@ -234,6 +234,9 @@
Create destination directories as usual. */
bool symbolic_link;
Expand Down Expand Up @@ -366,7 +367,7 @@ diff -aur coreutils-8.32/src/copy.h coreutils-8.32-patched/src/copy.h
#endif
diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
--- coreutils-8.32/src/cp.c 2020-01-01 19:43:12.000000000 +0530
+++ coreutils-8.32-patched/src/cp.c 2020-10-26 19:27:11.298040234 +0530
+++ coreutils-8.32-patched/src/cp.c 2020-12-06 22:24:03.488405684 +0530
@@ -131,6 +131,7 @@
{"symbolic-link", no_argument, NULL, 's'},
{"target-directory", required_argument, NULL, 't'},
Expand Down Expand Up @@ -531,7 +532,7 @@ diff -aur coreutils-8.32/src/cp.c coreutils-8.32-patched/src/cp.c
break;
diff -aur coreutils-8.32/src/mv.c coreutils-8.32-patched/src/mv.c
--- coreutils-8.32/src/mv.c 2020-01-01 19:43:12.000000000 +0530
+++ coreutils-8.32-patched/src/mv.c 2020-10-26 19:27:11.298040234 +0530
+++ coreutils-8.32-patched/src/mv.c 2020-12-06 22:24:03.488405684 +0530
@@ -66,6 +66,7 @@
{"target-directory", required_argument, NULL, 't'},
{"update", no_argument, NULL, 'u'},
Expand Down

0 comments on commit fa08fed

Please sign in to comment.