aboutsummaryrefslogtreecommitdiff
path: root/src/apps
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-03-17 19:32:15 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-03-18 09:35:16 +0100
commit7bb5d00b2172053682b093c15021a1c53f1aafb2 (patch)
tree2934b245b610309cbdd83c562120828a6dd723ba /src/apps
parent0d630d411abc14c0fab1f137dcfe501c0de28883 (diff)
downloadPROJ-7bb5d00b2172053682b093c15021a1c53f1aafb2.tar.gz
PROJ-7bb5d00b2172053682b093c15021a1c53f1aafb2.zip
cs2cs: don't require +to for '{source_crs} {target_crs} filename...' syntax (fixes #2012)
Diffstat (limited to 'src/apps')
-rw-r--r--src/apps/cs2cs.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp
index affd2bec..c99e16e0 100644
--- a/src/apps/cs2cs.cpp
+++ b/src/apps/cs2cs.cpp
@@ -349,23 +349,14 @@ int main(int argc, char **argv) {
exit(0);
}
- // First pass to check if we have "cs2cs [-bla]* <SRC> <DEST>" syntax
- int countNonOptionArg = 0;
+ // First pass to check if we have "cs2cs [-bla]* <SRC> <DEST> [<filename>]" syntax
+ bool isProj4StyleSyntax = false;
for (int i = 1; i < argc; i++) {
- if (argv[i][0] == '-') {
- if (argv[i][1] == 'f' || argv[i][1] == 'e' || argv[i][1] == 'd' ||
- argv[i][1] == 'D' ) {
- i++;
- }
- } else {
- if (strcmp(argv[i], "+to") == 0) {
- countNonOptionArg = -1;
- break;
- }
- countNonOptionArg++;
+ if (argv[i][0] == '+') {
+ isProj4StyleSyntax = true;
+ break;
}
}
- const bool isSrcDestSyntax = (countNonOptionArg == 2);
/* process run line arguments */
while (--argc > 0) { /* collect run line arguments */
@@ -492,11 +483,15 @@ int main(int argc, char **argv) {
}
break;
}
- } else if (isSrcDestSyntax) {
+ } else if (!isProj4StyleSyntax) {
if (fromStr.empty())
fromStr = *argv;
- else
+ else if( toStr.empty() )
toStr = *argv;
+ else {
+ /* assumed to be input file name(s) */
+ eargv[eargc++] = *argv;
+ }
} else if (strcmp(*argv, "+to") == 0) {
have_to_flag = 1;