mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-03 20:04:13 +00:00
[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
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
440a70f4a3
commit
a7461433c6
@@ -25,7 +25,7 @@ enum OutputFormat { kDecimal, kHexadecimal, kHexadecimal0x };
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
const char *name = argv[0];
|
const char *name = argv[0];
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
printf("%s HASH [OPTION]... STRING... [-- STRING...]\n", name);
|
printf("%s HASH [OPTION]... [--] STRING...\n", name);
|
||||||
printf("Available hashing algorithms:\n");
|
printf("Available hashing algorithms:\n");
|
||||||
printf(" 16 bit:\n");
|
printf(" 16 bit:\n");
|
||||||
size_t size = sizeof(flatbuffers::kHashFunctions16) /
|
size_t size = sizeof(flatbuffers::kHashFunctions16) /
|
||||||
@@ -50,7 +50,7 @@ int main(int argc, char *argv[]) {
|
|||||||
" -x Output hash in hexadecimal.\n"
|
" -x Output hash in hexadecimal.\n"
|
||||||
" -0x Output hash in hexadecimal and prefix with 0x.\n"
|
" -0x Output hash in hexadecimal and prefix with 0x.\n"
|
||||||
" -c Append the string to the output in a c-style comment.\n");
|
" -c Append the string to the output in a c-style comment.\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *hash_algorithm = argv[1];
|
const char *hash_algorithm = argv[1];
|
||||||
@@ -64,7 +64,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (!hash_function16 && !hash_function32 && !hash_function64) {
|
if (!hash_function16 && !hash_function32 && !hash_function64) {
|
||||||
printf("\"%s\" is not a known hash algorithm.\n", hash_algorithm);
|
printf("\"%s\" is not a known hash algorithm.\n", hash_algorithm);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputFormat output_format = kHexadecimal;
|
OutputFormat output_format = kHexadecimal;
|
||||||
|
|||||||
Reference in New Issue
Block a user