eina: strrchr--.

SVN revision: 53000
This commit is contained in:
Chidambar Zinnoury 2010-10-03 15:08:18 +00:00
parent 49d3d36bde
commit be17392520
1 changed files with 24 additions and 20 deletions

View 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); EINA_SAFETY_ON_NULL_RETURN_VAL(symbol, NULL);
if (dladdr(symbol, &eina_dl)) if (dladdr(symbol, &eina_dl))
if (strrchr(eina_dl.dli_fname, '/')) {
{ char *pos = strrchr(eina_dl.dli_fname, '/');
char *path; if (pos)
int l0; {
int l1; char *path;
int l2 = 0; int l0;
int l1;
int l2 = 0;
l0 = strlen(eina_dl.dli_fname); l0 = strlen(eina_dl.dli_fname);
l1 = strlen(strrchr(eina_dl.dli_fname, '/')); l1 = strlen(pos);
if (sub_dir && (*sub_dir != '\0')) if (sub_dir && (*sub_dir != '\0'))
l2 = strlen(sub_dir); l2 = strlen(sub_dir);
path = malloc(l0 - l1 + l2 + 1); path = malloc(l0 - l1 + l2 + 1);
if (path) if (path)
{ {
memcpy(path, eina_dl.dli_fname, l0 - l1); memcpy(path, eina_dl.dli_fname, l0 - l1);
if (sub_dir && (*sub_dir != '\0')) if (sub_dir && (*sub_dir != '\0'))
memcpy(path + l0 - l1, sub_dir, l2); memcpy(path + l0 - l1, sub_dir, l2);
path[l0 - l1 + l2] = '\0';
return path; path[l0 - l1 + l2] = '\0';
} return path;
} }
}
}
#endif /* ! HAVE_DLADDR */ #endif /* ! HAVE_DLADDR */