[GRASS-SVN] r62326 - in grass/branches/releasebranch_7_0: . vector/v.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Oct 21 10:50:08 PDT 2014


Author: martinl
Date: 2014-10-21 10:50:08 -0700 (Tue, 21 Oct 2014)
New Revision: 62326

Modified:
   grass/branches/releasebranch_7_0/
   grass/branches/releasebranch_7_0/vector/v.in.ogr/main.c
Log:
v.in.ogr: fix driver_name usage (can be NULL)
          (merge r62325 from trunk)



Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
   - /grass/trunk:61280,62141,62144,62269,62271,62276,62288,62300,62305,62310
   + /grass/trunk:61280,62141,62144,62269,62271,62276,62288,62300,62305,62310,62325

Modified: grass/branches/releasebranch_7_0/vector/v.in.ogr/main.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.in.ogr/main.c	2014-10-21 17:45:15 UTC (rev 62325)
+++ grass/branches/releasebranch_7_0/vector/v.in.ogr/main.c	2014-10-21 17:50:08 UTC (rev 62326)
@@ -344,16 +344,16 @@
 
     driver_name = db_get_default_driver_name();
 
-    if (strcmp(driver_name, "pg") == 0)
+    if (driver_name && strcmp(driver_name, "pg") == 0)
 	datetime_type = "timestamp";
-    else if (strcmp(driver_name, "dbf") == 0)
+    else if (driver_name && strcmp(driver_name, "dbf") == 0)
 	datetime_type = "varchar(22)";
     else
 	datetime_type = "datetime";
 
     /* dsn is 'PG:', check default connection settings */
     dsn = NULL;
-    if (strcmp(driver_name, "pg") == 0 &&
+    if (driver_name && strcmp(driver_name, "pg") == 0 &&
         G_strcasecmp(param.dsn->answer, "PG:") == 0) {
         const char *dbname;
         dbConnection conn;
@@ -433,12 +433,12 @@
 
     /* check encoding for given driver */
     if (param.encoding->answer) {
-        const char *driver_name;
+        const char *ogr_driver;
 
-        driver_name = OGR_Dr_GetName(OGR_DS_GetDriver(Ogr_ds));
-        if (strcmp(driver_name, "ESRI Shapefile") != 0 &&
-            strcmp(driver_name, "DXF") != 0)
-            G_warning(_("Encoding value not supported by OGR driver <%s>"), driver_name);
+        ogr_driver = OGR_Dr_GetName(OGR_DS_GetDriver(Ogr_ds));
+        if (strcmp(ogr_driver, "ESRI Shapefile") != 0 &&
+            strcmp(ogr_driver, "DXF") != 0)
+            G_warning(_("Encoding value not supported by OGR driver <%s>"), ogr_driver);
     }
 
     /* make a list of available layers */



More information about the grass-commit mailing list