mirror of
https://gitlab.freedesktop.org/uchardet/uchardet.git
synced 2025-12-06 16:56:40 +08:00
Issue #15: support "--" end-of-option.
This commit is contained in:
parent
ae7acbd0f2
commit
4a37dfdf1c
@ -41,6 +41,7 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef VERSION
|
#ifndef VERSION
|
||||||
#define VERSION "Unknown"
|
#define VERSION "Unknown"
|
||||||
@ -125,7 +126,8 @@ int main(int argc, char ** argv)
|
|||||||
|
|
||||||
FILE * f = stdin;
|
FILE * f = stdin;
|
||||||
int error_seen = 0;
|
int error_seen = 0;
|
||||||
if (argc < 2)
|
if (argc < 2 ||
|
||||||
|
(argc == 2 && strcmp(argv[1], "--") == 0))
|
||||||
{
|
{
|
||||||
// No file arg, use stdin by default
|
// No file arg, use stdin by default
|
||||||
detect(f);
|
detect(f);
|
||||||
@ -133,6 +135,10 @@ int main(int argc, char ** argv)
|
|||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
const char *filename = argv[i];
|
const char *filename = argv[i];
|
||||||
|
|
||||||
|
if (strcmp(filename, "--") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
f = fopen(filename, "r");
|
f = fopen(filename, "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user