Browse Source

vlib: field.c: normalize path for Windows
+G_str_replace(): input buffer as const
(merge https://trac.osgeo.org/grass/changeset/45538 from relbr64)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@45541 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 years ago
parent
commit
521eb0bae4
3 changed files with 13 additions and 7 deletions
  1. 1 1
      include/gisdefs.h
  2. 4 5
      lib/gis/strings.c
  3. 8 1
      lib/vector/Vlib/field.c

+ 1 - 1
include/gisdefs.h

@@ -577,7 +577,7 @@ int G_snprintf(char *, size_t, const char *, ...)
 int G_strcasecmp(const char *, const char *);
 int G_strcasecmp(const char *, const char *);
 char *G_store(const char *);
 char *G_store(const char *);
 char *G_strchg(char *, char, char);
 char *G_strchg(char *, char, char);
-char *G_str_replace(char *, const char *, const char *);
+char *G_str_replace(const char *, const char *, const char *);
 void G_strip(char *);
 void G_strip(char *);
 char *G_chop(char *);
 char *G_chop(char *);
 void G_str_to_upper(char *);
 void G_str_to_upper(char *);

+ 4 - 5
lib/gis/strings.c

@@ -127,15 +127,14 @@ char *G_strchg(char *bug, char character, char new)
  * G_free (name);
  * G_free (name);
  * \endcode
  * \endcode
  *
  *
- * \param[in,out] buffer main string
- * \param[in] old_str string to replace
- * \param[in] new_str new string
+ * \param buffer input string buffer
+ * \param old_str string to be replaced
+ * \param new_str new string
  *
  *
  * \return the newly allocated string, input buffer is unchanged 
  * \return the newly allocated string, input buffer is unchanged 
  */
  */
-char *G_str_replace(char *buffer, const char *old_str, const char *new_str)
+char *G_str_replace(const char *buffer, const char *old_str, const char *new_str)
 {
 {
-
     char *B, *R;
     char *B, *R;
     const char *N;
     const char *N;
     char *replace;
     char *replace;

+ 8 - 1
lib/vector/Vlib/field.c

@@ -844,8 +844,15 @@ char *Vect_subst_var(const char *in, const struct Map_info *Map)
     G_debug(3, "Vect_subst_var(): in = %s, map = %s, mapset = %s", in,
     G_debug(3, "Vect_subst_var(): in = %s, map = %s, mapset = %s", in,
 	    Map->name, Map->mapset);
 	    Map->name, Map->mapset);
 
 
+#ifdef __MINGW32__
+    char *cin;
+    cin = G_str_replace(in, "/", "\\");
+    strcpy(str, cin);
+    G_free(cin);
+#else
     strcpy(str, in);
     strcpy(str, in);
-
+#endif
+    
     strcpy(buf, str);
     strcpy(buf, str);
     c = (char *)strstr(buf, "$GISDBASE");
     c = (char *)strstr(buf, "$GISDBASE");
     if (c != NULL) {
     if (c != NULL) {