Explorar o código

libgis: use HOST_DIRSEP in filenames (see https://trac.osgeo.org/grass/ticket/2712)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65639 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa %!s(int64=9) %!d(string=hai) anos
pai
achega
377f7a821c
Modificáronse 1 ficheiros con 18 adicións e 10 borrados
  1. 18 10
      lib/gis/file_name.c

+ 18 - 10
lib/gis/file_name.c

@@ -17,8 +17,9 @@
 
 
 #include "gis_local_proto.h"
 #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
   \brief Builds full path names to GIS data files
@@ -112,37 +113,37 @@ char *file_name(char *path,
          */
          */
         if (name && *name && G_name_is_fully_qualified(name, xname, xmapset)) {
         if (name && *name && G_name_is_fully_qualified(name, xname, xmapset)) {
             pname = xname;
             pname = xname;
-            sprintf(path, "%s/%s", location, xmapset);
+            sprintf(path, "%s%c%s", location, HOST_DIRSEP, xmapset);
         }
         }
         else if (mapset && *mapset)
         else if (mapset && *mapset)
-            sprintf(path, "%s/%s", location, mapset);
+            sprintf(path, "%s%c%s", location, HOST_DIRSEP, mapset);
         else
         else
-            sprintf(path, "%s/%s", location, G_mapset());
+            sprintf(path, "%s%c%s", location, HOST_DIRSEP, G_mapset());
         G_free(location);
         G_free(location);
     }
     }
 
 
     if (dir && *dir) { /* misc element */
     if (dir && *dir) { /* misc element */
-	strcat(path, "/");
+	append_char(path, HOST_DIRSEP);
 	strcat(path, dir);
 	strcat(path, dir);
 
 
         if (pname && *pname) {
         if (pname && *pname) {
-            strcat(path, "/");
+            append_char(path, HOST_DIRSEP);
             strcat(path, pname);
             strcat(path, pname);
         }
         }
 
 
         if (element && *element) {
         if (element && *element) {
-            strcat(path, "/");
+            append_char(path, HOST_DIRSEP);
             strcat(path, element);
             strcat(path, element);
         }
         }
     }
     }
     else {
     else {
         if (element && *element) {
         if (element && *element) {
-            strcat(path, "/");
+            append_char(path, HOST_DIRSEP);
             strcat(path, element);
             strcat(path, element);
         }
         }
         
         
         if (pname && *pname) {
         if (pname && *pname) {
-            strcat(path, "/");
+            append_char(path, HOST_DIRSEP);
             strcat(path, pname);
             strcat(path, pname);
         }
         }
     }
     }
@@ -151,3 +152,10 @@ char *file_name(char *path,
     
     
     return path;
     return path;
 }
 }
+
+void append_char(char* s, char c)
+{
+        int len = strlen(s);
+        s[len] = c;
+        s[len+1] = '\0';
+}