diff options
| author | Thomas Knudsen <busstoptaktik@users.noreply.github.com> | 2017-12-18 16:37:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-18 16:37:44 +0100 |
| commit | 9eb17155ba7fe7d11110ae7e20416af0b5016750 (patch) | |
| tree | c117bc76810a03e40f51e86114b97b59caa52bc0 /src/optargpm.h | |
| parent | 5bd4aef074ed3d9041e252be53fd2810ec40a02f (diff) | |
| download | PROJ-9eb17155ba7fe7d11110ae7e20416af0b5016750.tar.gz PROJ-9eb17155ba7fe7d11110ae7e20416af0b5016750.zip | |
Remove superfluous element free_format from OPTARGPM object (#716)
Fixes #699
Diffstat (limited to 'src/optargpm.h')
| -rw-r--r-- | src/optargpm.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/optargpm.h b/src/optargpm.h index 97755cdb..d464b5a9 100644 --- a/src/optargpm.h +++ b/src/optargpm.h @@ -216,7 +216,6 @@ struct OPTARGS { FILE *input; int input_index; int record_index; - int free_format; /* plus-style specs replaced by free format */ const char *progname; /* argv[0], stripped from /path/to, if present */ char flaglevel[21]; /* if flag -f is specified n times, its optarg pointer is set to flaglevel + n */ char *optarg[256]; /* optarg[(int) 'f'] holds a pointer to the argument of option "-f" */ @@ -415,6 +414,7 @@ const char *opt_strip_path (const char *full_name) { /* split command line options into options/flags ("-" style), projdefs ("+" style) and input file args */ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, const char **longflags, const char **longkeys) { int i, j; + int free_format; OPTARGS *o; o = (OPTARGS *) calloc (1, sizeof(OPTARGS)); @@ -424,12 +424,6 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, o->argc = argc; o->argv = argv; o->progname = opt_strip_path (argv[0]); - o->free_format = 0; - - /* Is free format in use, instead of plus-style? */ - for (i = 1; i < argc; i++) - if (0==strcmp ("--", argv[i])) - o->free_format = i; /* Reset all flags */ for (i = 0; i < (int) strlen (flags); i++) @@ -588,11 +582,20 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, /* Process all '+'-style options, starting from where '-'-style processing ended */ o->pargv = argv + i; - if (o->free_format) { - o->pargc = o->free_format - (o->margc + 1); - o->fargc = argc - (o->free_format + 1); + + /* Is free format in use, instead of plus-style? */ + for (free_format = 0, j = 1; j < argc; j++) { + if (0==strcmp ("--", argv[j])) { + free_format = j; + break; + } + } + + if (free_format) { + o->pargc = free_format - (o->margc + 1); + o->fargc = argc - (free_format + 1); if (0 != o->fargc) - o->fargv = argv + o->free_format + 1; + o->fargv = argv + free_format + 1; return o; } |
