aboutsummaryrefslogtreecommitdiff
path: root/src/apps/cs2cs.cpp
diff options
context:
space:
mode:
authorgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2020-03-18 08:35:46 +0000
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2020-03-18 08:35:46 +0000
commit5c7f901bf35a6b4801cecb6c41cc62be2fdb5c94 (patch)
treebebc72fe639213d002efe6fe64ab3c0ffb25398a /src/apps/cs2cs.cpp
parent2b4037d7a02598ec7747d2d4ad88c41de08f430f (diff)
downloadPROJ-5c7f901bf35a6b4801cecb6c41cc62be2fdb5c94.tar.gz
PROJ-5c7f901bf35a6b4801cecb6c41cc62be2fdb5c94.zip
cs2cs: don't require +to for '{source_crs} {target_crs} filename...' syntax (fixes #2012)
Diffstat (limited to 'src/apps/cs2cs.cpp')
-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 6c85d4aa..4ada83b5 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 */
@@ -485,11 +476,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;