- Improved default behaviour, added '-' input signifier.
This commit is contained in:
parent
c33df721a6
commit
89300320fe
15
src/main.c
15
src/main.c
@ -35,6 +35,8 @@ main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
System sys;
|
System sys;
|
||||||
|
|
||||||
|
struct arg_file *infile = arg_file0(NULL,NULL,"FILE", "input file ('-' for stdin)");
|
||||||
|
struct arg_file *outfile = arg_file0("o","output","FILE", "output file (default is stdout)");
|
||||||
struct arg_int *traversal = arg_int0 ("t", "traverse", NULL,
|
struct arg_int *traversal = arg_int0 ("t", "traverse", NULL,
|
||||||
"set traversal method, partial order reduction (default is 8)");
|
"set traversal method, partial order reduction (default is 8)");
|
||||||
struct arg_int *match =
|
struct arg_int *match =
|
||||||
@ -67,8 +69,6 @@ main (int argc, char **argv)
|
|||||||
struct arg_lit *help = arg_lit0 (NULL, "help", "print this help and exit");
|
struct arg_lit *help = arg_lit0 (NULL, "help", "print this help and exit");
|
||||||
struct arg_lit *version =
|
struct arg_lit *version =
|
||||||
arg_lit0 (NULL, "version", "print version information and exit");
|
arg_lit0 (NULL, "version", "print version information and exit");
|
||||||
struct arg_file *outfile = arg_file0("o","output","FILE", "output file (stdout)");
|
|
||||||
struct arg_file *infile = arg_file0(NULL,NULL,"FILE", "input file (stdin)");
|
|
||||||
struct arg_end *end = arg_end (30);
|
struct arg_end *end = arg_end (30);
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
infile,
|
infile,
|
||||||
@ -156,14 +156,12 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* special case: uname with no command line options induces brief help */
|
/* special case: uname with no command line options induces brief help */
|
||||||
/*
|
|
||||||
if (argc==1)
|
if (argc==1)
|
||||||
{
|
{
|
||||||
printf("Try '%s --help' for more information.\n",progname);
|
printf("Try '%s --help' for more information.\n",progname);
|
||||||
exitcode=0;
|
exitcode=0;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Arguments have been parsed by argtable,
|
* Arguments have been parsed by argtable,
|
||||||
@ -184,21 +182,26 @@ main (int argc, char **argv)
|
|||||||
/* output */
|
/* output */
|
||||||
if (outfile->count > 0)
|
if (outfile->count > 0)
|
||||||
{
|
{
|
||||||
|
/* try to open */
|
||||||
if (!freopen (outfile->filename[0], "w", stdout))
|
if (!freopen (outfile->filename[0], "w", stdout))
|
||||||
{
|
{
|
||||||
printf("Error at stdout reopen to %s.\n", outfile->filename[0]);
|
printf("Error at stdout reopen to '%s'.\n", outfile->filename[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* input */
|
/* input */
|
||||||
if (infile->count > 0)
|
if (infile->count > 0)
|
||||||
|
{
|
||||||
|
/* check for the single dash */
|
||||||
|
if (strcmp(infile->filename[0],"-"))
|
||||||
{
|
{
|
||||||
if (!freopen (infile->filename[0], "r", stdin))
|
if (!freopen (infile->filename[0], "r", stdin))
|
||||||
{
|
{
|
||||||
printf("Error at stdin reopen to %s.\n", infile->filename[0]);
|
printf("Error at stdin reopen from '%s'.\n", infile->filename[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* handle debug level */
|
/* handle debug level */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
Loading…
Reference in New Issue
Block a user