Commit a7461433 authored by Henry Lee's avatar Henry Lee Committed by Wouter van Oortmerssen

[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
parent 440a70f4
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment