diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-02-17 17:25:57 +0000 |
---|---|---|
committer | <> | 2015-03-17 16:26:24 +0000 |
commit | 780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch) | |
tree | 598f8b9fa431b228d29897e798de4ac0c1d3d970 /examples/c/csv/code.c | |
parent | 7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff) | |
download | berkeleydb-master.tar.gz |
Diffstat (limited to 'examples/c/csv/code.c')
-rw-r--r-- | examples/c/csv/code.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/c/csv/code.c b/examples/c/csv/code.c index 24aaac81..85c6c792 100644 --- a/examples/c/csv/code.c +++ b/examples/c/csv/code.c @@ -1,7 +1,7 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2005, 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ @@ -26,7 +26,8 @@ int usage(void); * Globals */ FILE *cfp; /* C source file */ -FILE *hfp; /* C source file */ +FILE *ffp; /* CSV file */ +FILE *hfp; /* C header file */ char *progname; /* Program name */ int verbose; /* Verbose flag */ @@ -45,6 +46,8 @@ main(int argc, char *argv[]) else ++progname; + ffp = NULL; + /* Initialize arguments. */ cfile = "csv_local.c"; /* Default header/source files */ hfile = "csv_local.h"; @@ -55,8 +58,8 @@ main(int argc, char *argv[]) case 'c': cfile = optarg; break; - case 'f': - if (freopen(optarg, "r", stdin) == NULL) { + case 'f': /* Required argument */ + if ((ffp = freopen(optarg, "r", stdin)) == NULL) { fprintf(stderr, "%s: %s\n", optarg, strerror(errno)); return (EXIT_FAILURE); @@ -75,7 +78,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (*argv != NULL) + if (*argv != NULL || ffp == NULL) return (usage()); /* Load records from the input file. */ |