eina: strrchr--.
authorillogict <illogict@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 3 Oct 2010 15:08:18 +0000 (15:08 +0000)
committerillogict <illogict@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 3 Oct 2010 15:08:18 +0000 (15:08 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@53000 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eina_module.c

index 4e7a06a..7ae4bdb 100644 (file)
@@ -502,28 +502,32 @@ EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir)
    EINA_SAFETY_ON_NULL_RETURN_VAL(symbol, NULL);
 
    if (dladdr(symbol, &eina_dl))
-      if (strrchr(eina_dl.dli_fname, '/'))
-        {
-           char *path;
-           int l0;
-           int l1;
-           int l2 = 0;
-
-           l0 = strlen(eina_dl.dli_fname);
-           l1 = strlen(strrchr(eina_dl.dli_fname, '/'));
-           if (sub_dir && (*sub_dir != '\0'))
-              l2 = strlen(sub_dir);
-
-           path = malloc(l0 - l1 + l2 + 1);
-           if (path)
-             {
-                memcpy(path, eina_dl.dli_fname, l0 - l1);
-                if (sub_dir && (*sub_dir != '\0'))
-                   memcpy(path + l0 - l1, sub_dir, l2);
-                path[l0 - l1 + l2] = '\0';
-                return path;
-             }
-        }
+     {
+        char *pos = strrchr(eina_dl.dli_fname, '/');
+        if (pos)
+          {
+             char *path;
+             int l0;
+             int l1;
+             int l2 = 0;
+
+             l0 = strlen(eina_dl.dli_fname);
+             l1 = strlen(pos);
+             if (sub_dir && (*sub_dir != '\0'))
+                l2 = strlen(sub_dir);
+
+             path = malloc(l0 - l1 + l2 + 1);
+             if (path)
+               {
+                  memcpy(path, eina_dl.dli_fname, l0 - l1);
+                  if (sub_dir && (*sub_dir != '\0'))
+                     memcpy(path + l0 - l1, sub_dir, l2);
+
+                  path[l0 - l1 + l2] = '\0';
+                  return path;
+               }
+          }
+     }
 
 #endif /* ! HAVE_DLADDR */