Don't use '-' in option string to getopt().
Using '-' might fail on platforms like FreeBSD. Commit 50a7031
stopped using '-' in the B compiler and ego. I now stop using '-' in
mcg, because I can now check that mcg still works.
This commit is contained in:
parent
04ac91889c
commit
a60738a50d
1 changed files with 12 additions and 9 deletions
|
@ -42,13 +42,14 @@ int main(int argc, char* const argv[])
|
||||||
const char* inputfilename = NULL;
|
const char* inputfilename = NULL;
|
||||||
const char* outputfilename = NULL;
|
const char* outputfilename = NULL;
|
||||||
FILE* output;
|
FILE* output;
|
||||||
|
int i;
|
||||||
|
|
||||||
program_name = argv[0];
|
program_name = argv[0];
|
||||||
|
|
||||||
opterr = 1;
|
opterr = 1;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c = getopt(argc, argv, "-d:D:C:o:");
|
int c = getopt(argc, argv, "d:D:C:o:");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -79,20 +80,22 @@ int main(int argc, char* const argv[])
|
||||||
fatal("already specified an output file");
|
fatal("already specified an output file");
|
||||||
outputfilename = optarg;
|
outputfilename = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (inputfilename)
|
|
||||||
fatal("unexpected argument '%s'", optarg);
|
|
||||||
inputfilename = optarg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = optind; i < argc; i++)
|
||||||
|
{
|
||||||
|
if (inputfilename)
|
||||||
|
fatal("unexpected argument '%s'", argv[i]);
|
||||||
|
inputfilename = argv[i];
|
||||||
|
}
|
||||||
|
|
||||||
symbol_init();
|
symbol_init();
|
||||||
|
|
||||||
if (!EM_open((char*) inputfilename))
|
if (!EM_open((char*) inputfilename))
|
||||||
fatal("couldn't open input '%s': %s",
|
fatal("couldn't open input '%s': %s",
|
||||||
inputfilename ? inputfilename : "<stdin>", EM_error);
|
inputfilename ? inputfilename : "<stdin>", EM_error);
|
||||||
|
|
||||||
if (outputfilename)
|
if (outputfilename)
|
||||||
{
|
{
|
||||||
outputfile = fopen(outputfilename, "w");
|
outputfile = fopen(outputfilename, "w");
|
||||||
|
|
Loading…
Reference in a new issue