summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehan <jehan@girinstud.io>2020-04-22 21:05:44 +0200
committerJehan <jehan@girinstud.io>2020-04-22 21:05:44 +0200
commit4a37dfdf1c709520f99e3d408e418c3446673af3 (patch)
treed26c8c04fef3b48f656246863ccb9c36b537b011
parentae7acbd0f234a073e79425f32cb6e792ab15fd68 (diff)
Issue #15: support "--" end-of-option.
-rw-r--r--src/tools/uchardet.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/tools/uchardet.cpp b/src/tools/uchardet.cpp
index b68cb46..e8fface 100644
--- a/src/tools/uchardet.cpp
+++ b/src/tools/uchardet.cpp
@@ -41,6 +41,7 @@
#include <getopt.h>
#include <iostream>
#include <stdio.h>
+#include <string.h>
#ifndef VERSION
#define VERSION "Unknown"
@@ -125,7 +126,8 @@ int main(int argc, char ** argv)
FILE * f = stdin;
int error_seen = 0;
- if (argc < 2)
+ if (argc < 2 ||
+ (argc == 2 && strcmp(argv[1], "--") == 0))
{
// No file arg, use stdin by default
detect(f);
@@ -133,6 +135,10 @@ int main(int argc, char ** argv)
for (int i = 1; i < argc; i++)
{
const char *filename = argv[i];
+
+ if (strcmp(filename, "--") == 0)
+ continue;
+
f = fopen(filename, "r");
if (f == NULL)
{