Support dash dash (`--`) to mark the rest of the arguments as filenames.
Note this special case (an expected limitation):
```sh
touch a
./xxhsum a --
```
```
ef46db3751d8e999 a
Error: Could not open '--': No such file or directory.
```
When parsing arguments, the first non-option is treated as the start of
a list of file names. However, arguments continue to be parsed, so any
later arguments that look like options will have a dual meaning as an
option and file name. This is unexpected behavior, and here are two
solutions:
- Treat later option-like arguments as options
- Treat later option-like arguments as file names
Go with the latter solution for now because it is easier. The former
solution is preferred because it is more flexible and similar to how
`shasum` parses its arguments.
when state was already used with the same `seed` previously.
This skips secret generation when `seed` remains constant.
Also : improves streaming speed on small data
thanks to lighter memset() during reset().
`xxhsum *` would choke over directory entries.
This is because such a name still `fopen()` correctly,
but then reading its content fails.
This patch detects this situation, and just skip it, with a message.
`xxhsum` will also return an error code 1.
When including into other source code (especially when using cmake or the like)
the declaration of _CRT_SECURE_NO_WARNINGS in `xxhsum.c` can cause a compiler
warning about already defined pre-processor symbols. Wrap the symbol definition
in a check to see if it's already defined and not try to define it again.
The prior code accepted a --check line that ends after the first space
and returned the filename from the prior line. The new code rejects the
line as invalid.
- display binary name without path
- only provide binary name and version by default
- print extended compilation information on benchmark and --version
Printing xxh128sum's help for example would say default algo is xxh64,
which is not correct. Adjust g_defaultAlgo accordingly as well as the
currently selected algorithm.
also : fixed XXH128_withSecret(),
which was messed up with default `kSecret`.
This error remained unnoticed because their was no test for this variant.
Added a test in `xxhsum` checking results of `XXH128_withSecret()`
hidden option for the time being (undocumented)
as it's only an output format,
there is no ability to `-c` check it yet.
The effort was however useful in refactoring `xxhsum` code base.
One advantage of the `--tag` BSD format is
that it's a lot safer to introduce additional formats.
For example, little and big-endian variants can co-exist safely,
since endianess is clearly expressed as part of the algorithm name.
It would also make it possible to introduce XXH3 (later),
even though it's 64-bit, which would be confusing with XXH64.
Also :
added ability to select algorithm by specifying bit width.
Hence :
H0 == H32 ==> XXH32
H1 == H64 ==> XXH64
H2 == H128==> XXH128
For example, `xxhsum -b1 -b2` will benchmark XXH32 in both aligned and unaligned mode.
Also : modified default list,
now only test main variants (XXH32, XXH64, XXH3 and XXH128).
Also : -bi0 makes it possible to generate a very quick (though inaccurate) evaluation.