fix whitespace

This commit is contained in:
Michael Wehr
2021-12-22 13:48:56 +01:00
parent 9d614d1883
commit d337f35f5b

View File

@@ -1,41 +1,41 @@
diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
--- coreutils-9.0/src/copy.c 2021-09-24 07:31:05.000000000 -0400 --- coreutils-9.0/src/copy.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/copy.c 2021-10-27 21:33:32.299248300 -0400 +++ coreutils-9.0-patched/src/copy.c 2021-12-22 13:44:23.687642989 +0100
@@ -129,6 +129,70 @@ @@ -129,6 +129,70 @@
dev_t dev; dev_t dev;
}; };
+struct progress_status { +struct progress_status {
+ int iCountDown; + int iCountDown;
+ char ** cProgressField; + char ** cProgressField;
+ struct timeval last_time; + struct timeval last_time;
+ int last_size, iBarLength; + int last_size, iBarLength;
+ struct stat src_open_sb; + struct stat src_open_sb;
+}; +};
+ +
+/* Begin progress Mod*/ +/* Begin progress Mod*/
+static void file_progress_bar ( char * _cDest, int _iBarLength, long _lProgress, long _lTotal ) +static void file_progress_bar ( char * _cDest, int _iBarLength, long _lProgress, long _lTotal )
+{ +{
+ double dPercent = (double) _lProgress / (double) _lTotal * 100.f; + double dPercent = (double) _lProgress / (double) _lTotal * 100.f;
+ sprintf( _cDest + ( _iBarLength - 6), "%4.1f", dPercent ); + sprintf( _cDest + ( _iBarLength - 6), "%4.1f", dPercent );
+ _cDest[_iBarLength - 2] = ' '; + _cDest[_iBarLength - 2] = ' ';
+ +
+ int i; + int i;
+ for ( i=1; i<=_iBarLength - 9; i++) + for ( i=1; i<=_iBarLength - 9; i++)
+ { + {
+ if ( dPercent > (double) (i-1) / (_iBarLength - 10) * 100.f ) + if ( dPercent > (double) (i-1) / (_iBarLength - 10) * 100.f )
+ { + {
+ _cDest[i] = '='; + _cDest[i] = '=';
+ } + }
+ else + else
+ { + {
+ _cDest[i] = ' '; + _cDest[i] = ' ';
+ } + }
+ } + }
+ for ( i=1; i<_iBarLength - 9; i++) + for ( i=1; i<_iBarLength - 9; i++)
+ { + {
+ if ( ( _cDest[i+1] == ' ' ) && ( _cDest[i] == '=' ) ) + if ( ( _cDest[i+1] == ' ' ) && ( _cDest[i] == '=' ) )
+ _cDest[i] = '>' ; + _cDest[i] = '>' ;
+ } + }
+} +}
+ +
@@ -95,7 +95,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
+ /* BEGIN progress mod */ + /* BEGIN progress mod */
+ /* update countdown */ + /* update countdown */
+ s_progress->iCountDown--; + s_progress->iCountDown--;
+ char * sProgressBar = s_progress->cProgressField[5]; + char * sProgressBar = s_progress->cProgressField[5];
+ if ( s_progress->iCountDown < 0 ) + if ( s_progress->iCountDown < 0 )
+ s_progress->iCountDown = 100; + s_progress->iCountDown = 100;
+ +
@@ -153,7 +153,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
+ s_progress->cProgressField[4][s_progress->iBarLength - 21 + fs_len] = ' '; + s_progress->cProgressField[4][s_progress->iBarLength - 21 + fs_len] = ' ';
+ +
+ /* print the field */ + /* print the field */
+ int it; + int it;
+ for ( it = g_iTotalFiles>1 ? 0 : 3; it < 6; it++ ) + for ( it = g_iTotalFiles>1 ? 0 : 3; it < 6; it++ )
+ { + {
+ printf ( "\033[K%s\n", s_progress->cProgressField[it] ); + printf ( "\033[K%s\n", s_progress->cProgressField[it] );
@@ -332,14 +332,14 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
if (x->preserve_timestamps) if (x->preserve_timestamps)
diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h
--- coreutils-9.0/src/copy.h 2021-09-24 07:31:05.000000000 -0400 --- coreutils-9.0/src/copy.h 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/copy.h 2021-10-27 21:33:32.299248300 -0400 +++ coreutils-9.0-patched/src/copy.h 2021-12-22 13:37:29.730204394 +0100
@@ -236,6 +236,9 @@ @@ -236,6 +236,9 @@
Create destination directories as usual. */ Create destination directories as usual. */
bool symbolic_link; bool symbolic_link;
+ /* If true, draw a nice progress bar on screen */ + /* If true, draw a nice progress bar on screen */
+ bool progress_bar; + bool progress_bar;
+ +
/* If true, do not copy a nondirectory that has an existing destination /* If true, do not copy a nondirectory that has an existing destination
with the same or newer modification time. */ with the same or newer modification time. */
@@ -357,12 +357,12 @@ diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h
+__attribute__((__common__)) struct timeval g_oStartTime; +__attribute__((__common__)) struct timeval g_oStartTime;
+__attribute__((__common__)) int g_iTotalFiles; +__attribute__((__common__)) int g_iTotalFiles;
+__attribute__((__common__)) bool progress; +__attribute__((__common__)) bool progress;
+/* END OF PROGRESS MOD */ +/* END OF PROGRESS MOD */
+ +
#endif #endif
diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
--- coreutils-9.0/src/cp.c 2021-09-24 07:31:05.000000000 -0400 --- coreutils-9.0/src/cp.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/cp.c 2021-10-27 21:22:08.913768100 -0400 +++ coreutils-9.0-patched/src/cp.c 2021-12-22 13:38:59.519244777 +0100
@@ -131,6 +131,7 @@ @@ -131,6 +131,7 @@
{"symbolic-link", no_argument, NULL, 's'}, {"symbolic-link", no_argument, NULL, 's'},
{"target-directory", required_argument, NULL, 't'}, {"target-directory", required_argument, NULL, 't'},
@@ -405,16 +405,16 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
+ iFiles = n_files - 1; + iFiles = n_files - 1;
+ int j; + int j;
+ +
+ /* how many files are we copying */ + /* how many files are we copying */
+ char command[1024]; + char command[1024];
+ sprintf( command, "find \"%s\" -type f | wc -l", file[0]); + sprintf( command, "find \"%s\" -type f | wc -l", file[0]);
+ FILE *fp ; + FILE *fp ;
+ char output[1024]; + char output[1024];
+ fp = popen(command,"r"); + fp = popen(command,"r");
+ if ( fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL) + if ( fp == NULL || fgets(output, sizeof(output)-1, fp) == NULL)
+ printf("failed to run find.\n"); + printf("failed to run find.\n");
+ else + else
+ g_iTotalFiles = atoi( output ) ; + g_iTotalFiles = atoi( output );
+ +
+ for (j = 0; j < iFiles; j++) + for (j = 0; j < iFiles; j++)
+ { + {
@@ -520,9 +520,9 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
x.unlink_dest_after_failed_open = true; x.unlink_dest_after_failed_open = true;
break; break;
+ case 'g': + case 'g':
+ progress = true; + progress = true;
+ break; + break;
+ +
case 'H': case 'H':
x.dereference = DEREF_COMMAND_LINE_ARGUMENTS; x.dereference = DEREF_COMMAND_LINE_ARGUMENTS;
@@ -538,8 +538,8 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
? xget_version (_("backup type"), ? xget_version (_("backup type"),
version_control_string) version_control_string)
diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
--- coreutils-9.0/src/mv.c 2021-09-24 07:31:05.000000000 -0400 --- coreutils-9.0/src/mv.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/mv.c 2021-10-27 21:33:32.299248300 -0400 +++ coreutils-9.0-patched/src/mv.c 2021-12-22 13:37:58.306524898 +0100
@@ -66,6 +66,7 @@ @@ -66,6 +66,7 @@
{"target-directory", required_argument, NULL, 't'}, {"target-directory", required_argument, NULL, 't'},
{"update", no_argument, NULL, 'u'}, {"update", no_argument, NULL, 'u'},
@@ -656,8 +656,8 @@ diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
case 'v': case 'v':
x.verbose = true; x.verbose = true;
break; break;
+ case 'g': + case 'g':
+ progress = true; + progress = true;
+ break; + break;
case 'S': case 'S':
make_backups = true; make_backups = true;