aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-12-06 06:19:54 -0500
committerB. Watson <urchlay@slackware.uk>2025-12-06 06:19:54 -0500
commit36fb57d1b9f52c61615cc202eb01b92044b7d145 (patch)
treed73c84d4ff623ed1902ea03561a428eb096f4144
parentf9049f5f3e5e6fbd922e2f5575b45ec1e9c336ea (diff)
downloadalftools-36fb57d1b9f52c61615cc202eb01b92044b7d145.tar.gz
alf: percent().
-rw-r--r--src/alf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/alf.c b/src/alf.c
index c3e721c..4144d65 100644
--- a/src/alf.c
+++ b/src/alf.c
@@ -180,6 +180,10 @@ void convert_eols(void) {
}
}
+int percent(unsigned int out, unsigned int in) {
+ return 100 - (int)((float)out / (float)in * 100.0);
+}
+
void crunch_file(const char *filename_arg) {
strncpy(in_filename, filename_arg, PATH_MAX);
@@ -242,8 +246,7 @@ void crunch_file(const char *filename_arg) {
if(opt_verbose) {
printf(" %u/%u (%d%%)\n",
- input_len, output_len,
- 100 - (int)((float)output_len / (float)input_len * 100.0));
+ input_len, output_len, percent(output_len, input_len));
}
total_in += input_len;
@@ -351,7 +354,7 @@ int main(int argc, char **argv) {
printf("Compressed %d file%s: ", file_count, file_count == 1 ? "" : "s");
printf("%u/%u (%d%%)\n",
total_in, total_out,
- 100 - (int)((float)total_out / (float)total_in * 100.0));
+ percent(total_out, total_in));
print_elapsed_time();
if(backup_msg) {
printf("Backed up old '%s' to '%s~'.\n", out_filename, out_filename);