Merge pull request #221 from ib/master

Do not use locale for info output
This commit is contained in:
Con Kolivas 2022-03-09 06:01:41 +11:00 committed by GitHub
commit 80f7d91044
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

24
lrzip.c
View file

@ -1072,7 +1072,7 @@ next_chunk:
print_verbose("Chunk byte width: %d\n", chunk_byte); print_verbose("Chunk byte width: %d\n", chunk_byte);
if (chunk_size) { if (chunk_size) {
chunk_total += chunk_size; chunk_total += chunk_size;
print_verbose("Chunk size: %'"PRId64"\n", chunk_size); print_verbose("Chunk size: %"PRId64"\n", chunk_size);
} }
if (unlikely(chunk_byte && (chunk_byte > 8 || chunk_size < 0))) if (unlikely(chunk_byte && (chunk_byte > 8 || chunk_size < 0)))
failure("Invalid chunk data\n"); failure("Invalid chunk data\n");
@ -1086,7 +1086,7 @@ next_chunk:
return false; return false;
print_verbose("Stream: %d\n", stream); print_verbose("Stream: %d\n", stream);
print_maxverbose("Offset: %'"PRId64"\n", stream_head[stream] + ofs); print_maxverbose("Offset: %"PRId64"\n", stream_head[stream] + ofs);
print_verbose("%s\t%s\t%s\t%16s / %14s", "Block","Comp","Percent","Comp Size", "UComp Size"); print_verbose("%s\t%s\t%s\t%16s / %14s", "Block","Comp","Percent","Comp Size", "UComp Size");
print_maxverbose("%18s : %14s", "Offset", "Head"); print_maxverbose("%18s : %14s", "Offset", "Head");
print_verbose("\n"); print_verbose("\n");
@ -1127,8 +1127,8 @@ next_chunk:
* the future */ * the future */
utotal += u_len; utotal += u_len;
ctotal += c_len; ctotal += c_len;
print_verbose("\t%5.1f%%\t%'16"PRId64" / %'14"PRId64"", percentage(c_len, u_len), c_len, u_len); print_verbose("\t%5.1f%%\t%16"PRId64" / %14"PRId64"", percentage(c_len, u_len), c_len, u_len);
print_maxverbose("%'18"PRId64" : %'14"PRId64"", head_off, last_head); print_maxverbose("%18"PRId64" : %14"PRId64"", head_off, last_head);
print_verbose("\n"); print_verbose("\n");
block++; block++;
} while (last_head); } while (last_head);
@ -1165,7 +1165,7 @@ done:
if (unlikely(ofs > infile_size)) if (unlikely(ofs > infile_size))
failure_goto(("Offset greater than archive size, likely corrupted/truncated archive.\n"), error); failure_goto(("Offset greater than archive size, likely corrupted/truncated archive.\n"), error);
print_output("\nSummary\n=======\n"); print_output("\nSummary\n=======\n");
print_output("File: %s\nlrzip version: %'d.%'d \n\n", infilecopy, print_output("File: %s\nlrzip version: %d.%d \n\n", infilecopy,
control->major_version, control->minor_version); control->major_version, control->minor_version);
if (!expected_size) if (!expected_size)
@ -1173,18 +1173,18 @@ done:
print_verbose(" Stats Percent Compressed / Uncompressed\n -------------------------------------------------------\n"); print_verbose(" Stats Percent Compressed / Uncompressed\n -------------------------------------------------------\n");
/* If we can't show expected size, tailor output for it */ /* If we can't show expected size, tailor output for it */
if (expected_size) { if (expected_size) {
print_verbose(" Rzip: %5.1f%%\t%'16"PRId64" / %'14"PRId64"\n", print_verbose(" Rzip: %5.1f%%\t%16"PRId64" / %14"PRId64"\n",
percentage (utotal, expected_size), percentage (utotal, expected_size),
utotal, expected_size); utotal, expected_size);
print_verbose(" Back end: %5.1f%%\t%'16"PRId64" / %'14"PRId64"\n", print_verbose(" Back end: %5.1f%%\t%16"PRId64" / %14"PRId64"\n",
percentage(ctotal, utotal), percentage(ctotal, utotal),
ctotal, utotal); ctotal, utotal);
print_verbose(" Overall: %5.1f%%\t%'16"PRId64" / %'14"PRId64"\n", print_verbose(" Overall: %5.1f%%\t%16"PRId64" / %14"PRId64"\n",
percentage(ctotal, expected_size), percentage(ctotal, expected_size),
ctotal, expected_size); ctotal, expected_size);
} else { } else {
print_verbose(" Rzip: Unavailable\n"); print_verbose(" Rzip: Unavailable\n");
print_verbose(" Back end: %5.1f%%\t%'16"PRId64" / %'14"PRId64"\n", percentage(ctotal, utotal), ctotal, utotal); print_verbose(" Back end: %5.1f%%\t%16"PRId64" / %14"PRId64"\n", percentage(ctotal, utotal), ctotal, utotal);
print_verbose(" Overall: Unavailable\n"); print_verbose(" Overall: Unavailable\n");
} }
print_verbose("\n"); print_verbose("\n");
@ -1209,12 +1209,12 @@ done:
print_output("\n"); print_output("\n");
if (expected_size) { if (expected_size) {
print_output(" Decompressed file size: %'14"PRIu64"\n", expected_size); print_output(" Decompressed file size: %14"PRIu64"\n", expected_size);
print_output(" Compressed file size: %'14"PRIu64"\n", infile_size); print_output(" Compressed file size: %14"PRIu64"\n", infile_size);
print_output(" Compression ratio: %14.3Lfx\n", cratio); print_output(" Compression ratio: %14.3Lfx\n", cratio);
} else { } else {
print_output(" Decompressed file size: Unavailable\n"); print_output(" Decompressed file size: Unavailable\n");
print_output(" Compressed file size: %'14"PRIu64"\n", infile_size); print_output(" Compressed file size: %14"PRIu64"\n", infile_size);
print_output(" Compression ratio: Unavailable\n"); print_output(" Compression ratio: Unavailable\n");
} }
if (HAS_MD5) { if (HAS_MD5) {

3
main.c
View file

@ -57,7 +57,6 @@
#include "lrzip_core.h" #include "lrzip_core.h"
#include "util.h" #include "util.h"
#include "stream.h" #include "stream.h"
#include <locale.h>
/* needed for CRC routines */ /* needed for CRC routines */
#include "lzma/C/7zCrc.h" #include "lzma/C/7zCrc.h"
@ -320,8 +319,6 @@ int main(int argc, char *argv[])
char *eptr, *av; /* for environment */ char *eptr, *av; /* for environment */
char *endptr = NULL; char *endptr = NULL;
setlocale(LC_ALL, ""); /* for printf features */
control = &base_control; control = &base_control;
initialise_control(control); initialise_control(control);