Also allow uchardet tool to detect encoding of a file named "--".

My previous commit was good except for the very special case of wanting
to analyze a file named "--". This file would be ignored.

With this change, only the first "--" option will be ignored as meaning
"end of option arguments", but any remaining value (another "--"
included) will be considered as a file path.
This commit is contained in:
Jehan 2020-04-22 21:11:23 +02:00
parent 4a37dfdf1c
commit ef0313046b

View File

@ -106,6 +106,7 @@ int main(int argc, char ** argv)
{ "help", no_argument, NULL, 'h' },
{ 0, 0, 0, 0 },
};
bool end_options = false;
static int oc;
while((oc = getopt_long(argc, argv, "vh", longopts, NULL)) != -1)
@ -136,8 +137,11 @@ int main(int argc, char ** argv)
{
const char *filename = argv[i];
if (strcmp(filename, "--") == 0)
if (! end_options && strcmp(filename, "--") == 0)
{
end_options = true;
continue;
}
f = fopen(filename, "r");
if (f == NULL)