From a7461433c6864b27d16e08c351d5fe109d5b932e Mon Sep 17 00:00:00 2001 From: Henry Lee Date: Fri, 22 Mar 2019 10:23:32 +1100 Subject: [PATCH] [C++] Changes in the flathash program (#5255) * Correct the usage in the flathash program As it is possible to have -- before the occurrence of the first input STRING. * Exit with 1 in the flathash program when an error occurs --- src/flathash.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flathash.cpp b/src/flathash.cpp index 2194e3086..bc3d2df29 100644 --- a/src/flathash.cpp +++ b/src/flathash.cpp @@ -25,7 +25,7 @@ enum OutputFormat { kDecimal, kHexadecimal, kHexadecimal0x }; int main(int argc, char *argv[]) { const char *name = argv[0]; if (argc <= 1) { - printf("%s HASH [OPTION]... STRING... [-- STRING...]\n", name); + printf("%s HASH [OPTION]... [--] STRING...\n", name); printf("Available hashing algorithms:\n"); printf(" 16 bit:\n"); size_t size = sizeof(flatbuffers::kHashFunctions16) / @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) { " -x Output hash in hexadecimal.\n" " -0x Output hash in hexadecimal and prefix with 0x.\n" " -c Append the string to the output in a c-style comment.\n"); - return 0; + return 1; } const char *hash_algorithm = argv[1]; @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) { if (!hash_function16 && !hash_function32 && !hash_function64) { printf("\"%s\" is not a known hash algorithm.\n", hash_algorithm); - return 0; + return 1; } OutputFormat output_format = kHexadecimal;