lzmainfo: Use tuklib_mbstr_nonprint

This commit is contained in:
Lasse Collin 2024-12-18 14:00:09 +02:00
parent 03111595ee
commit 22a35e64ce
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
3 changed files with 14 additions and 6 deletions

View File

@ -1933,6 +1933,8 @@ if(XZ_TOOL_LZMAINFO AND HAVE_DECODERS)
src/common/sysdefs.h src/common/sysdefs.h
src/common/tuklib_common.h src/common/tuklib_common.h
src/common/tuklib_config.h src/common/tuklib_config.h
src/common/tuklib_mbstr_nonprint.c
src/common/tuklib_mbstr_nonprint.h
src/common/tuklib_exit.c src/common/tuklib_exit.c
src/common/tuklib_exit.h src/common/tuklib_exit.h
src/common/tuklib_gettext.h src/common/tuklib_gettext.h
@ -1957,6 +1959,7 @@ if(XZ_TOOL_LZMAINFO AND HAVE_DECODERS)
endif() endif()
tuklib_progname(lzmainfo) tuklib_progname(lzmainfo)
tuklib_mbstr(lzmainfo)
# NOTE: The translations are in the "xz" domain and the .mo files are # NOTE: The translations are in the "xz" domain and the .mo files are
# installed as part of the "xz" target. # installed as part of the "xz" target.

View File

@ -6,6 +6,7 @@ bin_PROGRAMS = lzmainfo
lzmainfo_SOURCES = \ lzmainfo_SOURCES = \
lzmainfo.c \ lzmainfo.c \
../common/tuklib_progname.c \ ../common/tuklib_progname.c \
../common/tuklib_mbstr_nonprint.c \
../common/tuklib_exit.c ../common/tuklib_exit.c
if COND_W32 if COND_W32

View File

@ -17,6 +17,7 @@
#include "getopt.h" #include "getopt.h"
#include "tuklib_gettext.h" #include "tuklib_gettext.h"
#include "tuklib_progname.h" #include "tuklib_progname.h"
#include "tuklib_mbstr_nonprint.h"
#include "tuklib_exit.h" #include "tuklib_exit.h"
#ifdef TUKLIB_DOSLIKE #ifdef TUKLIB_DOSLIKE
@ -108,7 +109,8 @@ lzmainfo(const char *name, FILE *f)
uint8_t buf[13]; uint8_t buf[13];
const size_t size = fread(buf, 1, sizeof(buf), f); const size_t size = fread(buf, 1, sizeof(buf), f);
if (size != 13) { if (size != 13) {
fprintf(stderr, "%s: %s: %s\n", progname, name, fprintf(stderr, "%s: %s: %s\n", progname,
tuklib_mask_nonprint(name),
ferror(f) ? strerror(errno) ferror(f) ? strerror(errno)
: _("File is too small to be a .lzma file")); : _("File is too small to be a .lzma file"));
return true; return true;
@ -122,7 +124,8 @@ lzmainfo(const char *name, FILE *f)
break; break;
case LZMA_OPTIONS_ERROR: case LZMA_OPTIONS_ERROR:
fprintf(stderr, "%s: %s: %s\n", progname, name, fprintf(stderr, "%s: %s: %s\n", progname,
tuklib_mask_nonprint(name),
_("Not a .lzma file")); _("Not a .lzma file"));
return true; return true;
@ -146,7 +149,7 @@ lzmainfo(const char *name, FILE *f)
// this output and we don't want to break that when people move // this output and we don't want to break that when people move
// from LZMA Utils to XZ Utils. // from LZMA Utils to XZ Utils.
if (f != stdin) if (f != stdin)
printf("%s\n", name); printf("%s\n", tuklib_mask_nonprint(name));
printf("Uncompressed size: "); printf("Uncompressed size: ");
if (uncompressed_size == UINT64_MAX) if (uncompressed_size == UINT64_MAX)
@ -205,7 +208,8 @@ main(int argc, char **argv)
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
fprintf(stderr, "%s: %s: %s\n", fprintf(stderr, "%s: %s: %s\n",
progname, progname,
argv[optind], tuklib_mask_nonprint(
argv[optind]),
strerror(errno)); strerror(errno));
continue; continue;
} }