Don't add tests because it looks like a pain, having to create separate
ones for Unix and Windows systems. Instead, here are some tests in
text:
- Make sure arguments aren't double-interpreted as file names and
options:
```sh
touch a
xxhsum a >x
xxhsum x --check
```
- Interpret `--` as "from now on all arguments are filenames":
```sh
touch a b
xxhsum -- a b
xxhsum a -- b # expect "Could not open '--'"
diff <(./xxhsum |& echo) <(./xxhsum -- |& echo)
```
- Support filenames starting with '-':
```sh
touch -- -foo --check
xxhsum -- -foo
xxhsum -- --check
```
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.