Code

Translations. Spanish translation update by Lucas Vieites (Bug #664501).
[inkscape.git] / src / dir-util.cpp
index b2a7c97f6fcd630a005bc77c8b2a8fdb8feab3b7..67db036281324512c3d54df1155614ed73e7d284 100644 (file)
@@ -1,9 +1,12 @@
-/** \file Some utility functions for filenames. */
+/** @file
+ * @brief Utility functions for filenames
+ */
 
 #define DIR_UTIL_C
 
 #include <errno.h>
-#include <string.h>
+#include <string>
+#include <cstring>
 #include <glib/gutils.h>
 #include <glib/gmem.h>
 #include <glib/gerror.h>
@@ -205,8 +208,8 @@ inkscape_abs2rel (const char *path, const char *base, char *result, const size_t
   for (pp = path, bp = base; *pp && *bp && *pp == *bp; pp++, bp++)
     if (*pp == G_DIR_SEPARATOR)
       branch = pp;
-  if ((*pp == 0 || *pp == G_DIR_SEPARATOR && *(pp + 1) == 0) &&
-      (*bp == 0 || *bp == G_DIR_SEPARATOR && *(bp + 1) == 0))
+  if (((*pp == 0) || ((*pp == G_DIR_SEPARATOR) && (*(pp + 1) == 0))) &&
+      ((*bp == 0) || ((*bp == G_DIR_SEPARATOR) && (*(bp + 1) == 0))))
     {
       rp = result;
       *rp++ = '.';
@@ -217,7 +220,7 @@ inkscape_abs2rel (const char *path, const char *base, char *result, const size_t
       *rp = 0;
       goto finish;
     }
-  if (*pp == 0 && *bp == G_DIR_SEPARATOR || *pp == G_DIR_SEPARATOR && *bp == 0)
+  if (((*pp == 0) && (*bp == G_DIR_SEPARATOR)) || ((*pp == G_DIR_SEPARATOR) && (*bp == 0)))
     branch = pp;
   /* up to root. */
   rp = result;
@@ -249,16 +252,15 @@ erange:
   return (NULL);
 }
 
-void
-prepend_current_dir_if_relative (char **result, const gchar *uri)
+gchar *
+prepend_current_dir_if_relative(gchar const *uri)
 {
        if (!uri) {
-               *(result) = NULL;
-               return;
+               return NULL;
        }
 
-       char *full_path = (char *) g_malloc (1001);
-       char *cwd = g_get_current_dir();
+       gchar *full_path = (gchar *) g_malloc (1001);
+       gchar *cwd = g_get_current_dir();
 
        gsize bytesRead = 0;
        gsize bytesWritten = 0;
@@ -270,9 +272,10 @@ prepend_current_dir_if_relative (char **result, const gchar *uri)
                                                   &error);
 
        inkscape_rel2abs (uri, cwd_utf8, full_path, 1000);
-       *(result) = g_strdup (full_path);
+       gchar *ret = g_strdup (full_path);
        g_free (full_path);
        g_free (cwd);
+       return ret;
 }