[gdal-dev] gdal_translate (ProxyMain): Simplified `-gcp' handling.

Ivan Shmakov ivan at theory.asu.ru
Thu Dec 13 00:58:13 EST 2007


	There's no need to check either the CPLStrTod () return value or
	`argv[i + 1][0]' -- only the `endptr' check is required.

--- gdal_translate.cpp.~1~	2007-12-13 10:24:46.000000000 +0600
+++ gdal_translate.cpp	2007-12-13 11:32:31.000000000 +0600
@@ -210,12 +210,12 @@
             pasGCPs[nGCPCount-1].dfGCPX = atof(argv[++i]);
             pasGCPs[nGCPCount-1].dfGCPY = atof(argv[++i]);
             if( argv[i+1] != NULL 
-                && (CPLStrtod(argv[i+1], &endptr) != 0.0 || argv[i+1][0] == '0') )
-            {
-                /* Check that last argument is really a number and not a filename */
-                /* looking like a number (see ticket #863) */
-                if (endptr && *endptr == 0)
-                    pasGCPs[nGCPCount-1].dfGCPZ = atof(argv[++i]);
+                /* Check that last argument is really a number and not
+                 * a filename looking like a number (see ticket #863)
+                 */
+                && (CPLStrtod(argv[i+1], &endptr),
+                    endptr && *endptr == '\0')) {
+                pasGCPs[nGCPCount-1].dfGCPZ = atof(argv[++i]);
             }
 
             /* should set id and info? */



More information about the gdal-dev mailing list