Skip to content

Commit

Permalink
Merge pull request #735 from lz4/versionOut
Browse files Browse the repository at this point in the history
fix #734 : --version should output to stdout
  • Loading branch information
Cyan4973 committed Jun 25, 2019
2 parents 798301b + baf9b0e commit 9a2a9f2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions programs/lz4cli.c
Expand Up @@ -67,6 +67,7 @@ static int g_lz4c_legacy_commands = 0;
/*-************************************
* Macros
***************************************/
#define DISPLAYOUT(...) fprintf(stdout, __VA_ARGS__)
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
#define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); }
static unsigned displayLevel = 2; /* 0 : no display ; 1: errors only ; 2 : downgradable normal ; 3 : non-downgradable normal; 4 : + information */
Expand Down Expand Up @@ -390,7 +391,7 @@ int main(int argc, const char** argv)
if (!strcmp(argument, "--favor-decSpeed")) { LZ4IO_favorDecSpeed(prefs, 1); continue; }
if (!strcmp(argument, "--verbose")) { displayLevel++; continue; }
if (!strcmp(argument, "--quiet")) { if (displayLevel) displayLevel--; continue; }
if (!strcmp(argument, "--version")) { DISPLAY(WELCOME_MESSAGE); return 0; }
if (!strcmp(argument, "--version")) { DISPLAYOUT(WELCOME_MESSAGE); return 0; }
if (!strcmp(argument, "--help")) { usage_advanced(exeName); goto _cleanup; }
if (!strcmp(argument, "--keep")) { LZ4IO_setRemoveSrcFile(prefs, 0); continue; } /* keep source file (default) */
if (!strcmp(argument, "--rm")) { LZ4IO_setRemoveSrcFile(prefs, 1); continue; }
Expand Down Expand Up @@ -437,7 +438,7 @@ int main(int argc, const char** argv)
switch(argument[0])
{
/* Display help */
case 'V': DISPLAY(WELCOME_MESSAGE); goto _cleanup; /* Version */
case 'V': DISPLAYOUT(WELCOME_MESSAGE); goto _cleanup; /* Version */
case 'h': usage_advanced(exeName); goto _cleanup;
case 'H': usage_longhelp(exeName); goto _cleanup;

Expand Down

0 comments on commit 9a2a9f2

Please sign in to comment.