Selaa lähdekoodia

v.out.ogr: fix OGR_list_write_drivers()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@45181 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 vuotta sitten
vanhempi
commit
a43016026c
1 muutettua tiedostoa jossa 15 lisäystä ja 12 poistoa
  1. 15 12
      vector/v.out.ogr/list.c

+ 15 - 12
vector/v.out.ogr/list.c

@@ -14,20 +14,23 @@ char *OGR_list_write_drivers(void)
     /* Open OGR DSN */
     OGRRegisterAll();
     G_debug(2, "driver count = %d", OGRGetDriverCount());
-    drn = -1;
+    drn = 0;
     for (i = 0; i < OGRGetDriverCount(); i++) {
 	/* only fetch read/write drivers */
-	if (OGR_Dr_TestCapability(OGRGetDriver(i), ODrCCreateDataSource)) {
-	    Ogr_driver = OGRGetDriver(i);
-	    G_debug(2, "driver %d/%d : %s", i, OGRGetDriverCount(),
-		    OGR_Dr_GetName(Ogr_driver));
-	    /* chg white space to underscore in OGR driver names */
-	    sprintf(buf, "%s", OGR_Dr_GetName(Ogr_driver));
-	    G_strchg(buf, ' ', '_');
-	    strcat(OGRdrivers, buf);
-	    if (i < OGRGetDriverCount() - 1)
-		strcat(OGRdrivers, ",");
-	}
+	if (!OGR_Dr_TestCapability(OGRGetDriver(i), ODrCCreateDataSource))
+	    continue;
+	
+	if (drn)
+	    strcat(OGRdrivers, ",");
+	
+	Ogr_driver = OGRGetDriver(i);
+	G_debug(2, "driver %d/%d : %s", i, OGRGetDriverCount(),
+		OGR_Dr_GetName(Ogr_driver));
+	/* chg white space to underscore in OGR driver names */
+	sprintf(buf, "%s", OGR_Dr_GetName(Ogr_driver));
+	G_strchg(buf, ' ', '_');
+	strcat(OGRdrivers, buf);
+	drn++;
     }
     G_debug(2, "all drivers: %s", OGRdrivers);