mirror of
https://gitlab.freedesktop.org/uchardet/uchardet.git
synced 2025-12-06 16:56:40 +08:00
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:
parent
4a37dfdf1c
commit
ef0313046b
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user