The checks enforce that list mode will only run on .xz files. The
opt_format is only set during argument parsing and will not change
after. So we only need to check this once instead of every call to
list_file(). Additionally, this will cause the error to be detected
slightly earlier.
if (opt_mode != MODE_COMPRESS)
message_fatal(_("Decompression support was disabled "
"at build time"));
+#else
+ // List mode is only available when decoders are enabled and is
+ // only valid with .xz files.
+ if (opt_mode == MODE_LIST
+ && opt_format != FORMAT_XZ
+ && opt_format != FORMAT_AUTO)
+ message_fatal(_("--list works only on .xz files "
+ "(--format=xz or --format=auto)"));
#endif
#ifdef HAVE_LZIP_DECODER
extern void
list_file(const char *filename)
{
- if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO)
- message_fatal(_("--list works only on .xz files "
- "(--format=xz or --format=auto)"));
-
message_filename(filename);
if (filename == stdin_filename) {