[GRASS-SVN] r65639 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jul 19 09:53:47 PDT 2015


Author: martinl
Date: 2015-07-19 09:53:47 -0700 (Sun, 19 Jul 2015)
New Revision: 65639

Modified:
   grass/trunk/lib/gis/file_name.c
Log:
libgis: use HOST_DIRSEP in filenames (see #2712)


Modified: grass/trunk/lib/gis/file_name.c
===================================================================
--- grass/trunk/lib/gis/file_name.c	2015-07-19 16:51:22 UTC (rev 65638)
+++ grass/trunk/lib/gis/file_name.c	2015-07-19 16:53:47 UTC (rev 65639)
@@ -17,8 +17,9 @@
 
 #include "gis_local_proto.h"
 
-char *file_name(char *, const char *, const char *,
-                const char *, const char *, const char *);
+static char *file_name(char *, const char *, const char *,
+                       const char *, const char *, const char *);
+static void append_char(char*, char);
 
 /*!
   \brief Builds full path names to GIS data files
@@ -112,37 +113,37 @@
          */
         if (name && *name && G_name_is_fully_qualified(name, xname, xmapset)) {
             pname = xname;
-            sprintf(path, "%s/%s", location, xmapset);
+            sprintf(path, "%s%c%s", location, HOST_DIRSEP, xmapset);
         }
         else if (mapset && *mapset)
-            sprintf(path, "%s/%s", location, mapset);
+            sprintf(path, "%s%c%s", location, HOST_DIRSEP, mapset);
         else
-            sprintf(path, "%s/%s", location, G_mapset());
+            sprintf(path, "%s%c%s", location, HOST_DIRSEP, G_mapset());
         G_free(location);
     }
 
     if (dir && *dir) { /* misc element */
-	strcat(path, "/");
+	append_char(path, HOST_DIRSEP);
 	strcat(path, dir);
 
         if (pname && *pname) {
-            strcat(path, "/");
+            append_char(path, HOST_DIRSEP);
             strcat(path, pname);
         }
 
         if (element && *element) {
-            strcat(path, "/");
+            append_char(path, HOST_DIRSEP);
             strcat(path, element);
         }
     }
     else {
         if (element && *element) {
-            strcat(path, "/");
+            append_char(path, HOST_DIRSEP);
             strcat(path, element);
         }
         
         if (pname && *pname) {
-            strcat(path, "/");
+            append_char(path, HOST_DIRSEP);
             strcat(path, pname);
         }
     }
@@ -151,3 +152,10 @@
     
     return path;
 }
+
+void append_char(char* s, char c)
+{
+        int len = strlen(s);
+        s[len] = c;
+        s[len+1] = '\0';
+}



More information about the grass-commit mailing list