forked from enlightenment/efl
From: Jérémy Zurcher <jeremy@asynk.ch>
Subject: [E-devel] patch : eina_prefix + elementary_test please find attached a small patch for eina_prefix it prevent segfault when for instance no elm_app_compile_*_dir_set is called prior to elm_app_info_set and another one for elementary/src/bin/test*.c which tends to replace usage of PACKAGE_DATA_DIR with elm_app_data_dir_get SVN revision: 62795
This commit is contained in:
parent
733ac6e274
commit
c5606319d9
|
@ -126,3 +126,8 @@
|
||||||
2011-08-03 Myungjae Lee
|
2011-08-03 Myungjae Lee
|
||||||
|
|
||||||
* Fix eina_share_common_del and eina_share_common_ref to release lock on failure.
|
* Fix eina_share_common_del and eina_share_common_ref to release lock on failure.
|
||||||
|
|
||||||
|
2011-08-25 Jérémy Zurcher
|
||||||
|
|
||||||
|
* Max eina_prefix more robust so it handles null bin and share
|
||||||
|
dirs better etc.
|
||||||
|
|
|
@ -103,7 +103,7 @@ struct _Eina_Prefix
|
||||||
unsigned char env_used : 1;
|
unsigned char env_used : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define STRDUP_REP(x, y) do { if (x) free(x); x = strdup(y); } while (0)
|
#define STRDUP_REP(x, y) do { if (x) free(x); x = NULL; if (y) { x = strdup(y); } } while (0)
|
||||||
#define IF_FREE_NULL(p) do { if (p) { free(p); p = NULL; } } while (0)
|
#define IF_FREE_NULL(p) do { if (p) { free(p); p = NULL; } } while (0)
|
||||||
#define DBG(fmt, args...) do { if (getenv("EINA_PREFIX_DEBUG")) fprintf(stderr, fmt, ##args); } while (0)
|
#define DBG(fmt, args...) do { if (getenv("EINA_PREFIX_DEBUG")) fprintf(stderr, fmt, ##args); } while (0)
|
||||||
|
|
||||||
|
@ -204,8 +204,11 @@ _try_argv(Eina_Prefix *pfx, const char *argv0)
|
||||||
{
|
{
|
||||||
char *path, *p, *cp, *s;
|
char *path, *p, *cp, *s;
|
||||||
int len, lenexe;
|
int len, lenexe;
|
||||||
char buf[PATH_MAX], buf2[PATH_MAX], buf3[PATH_MAX];
|
char *buf, *buf2, *buf3;
|
||||||
|
|
||||||
|
buf = alloca(PATH_MAX);
|
||||||
|
buf2 = alloca(PATH_MAX);
|
||||||
|
buf3 = alloca(PATH_MAX);
|
||||||
DBG("Try argv0 = %s\n", argv0);
|
DBG("Try argv0 = %s\n", argv0);
|
||||||
/* 1. is argv0 abs path? */
|
/* 1. is argv0 abs path? */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -286,9 +289,10 @@ _try_argv(Eina_Prefix *pfx, const char *argv0)
|
||||||
static int
|
static int
|
||||||
_get_env_var(char **var, const char *env, const char *prefix, const char *dir)
|
_get_env_var(char **var, const char *env, const char *prefix, const char *dir)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char *buf;
|
||||||
const char *s = getenv(env);
|
const char *s = getenv(env);
|
||||||
|
|
||||||
|
buf = alloca(PATH_MAX);
|
||||||
DBG("Try env var %s\n", env);
|
DBG("Try env var %s\n", env);
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
|
@ -353,7 +357,7 @@ eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
|
||||||
const char *pkg_data, const char *pkg_locale)
|
const char *pkg_data, const char *pkg_locale)
|
||||||
{
|
{
|
||||||
Eina_Prefix *pfx;
|
Eina_Prefix *pfx;
|
||||||
char *p, buf[4096], *tmp, *magic = NULL;
|
char *p, *buf, *tmp, *magic = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *p1, *p2;
|
const char *p1, *p2;
|
||||||
const char *pkg_bin_p = NULL;
|
const char *pkg_bin_p = NULL;
|
||||||
|
@ -365,6 +369,7 @@ eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
|
||||||
const char *datadir = "share";
|
const char *datadir = "share";
|
||||||
const char *localedir = "share";
|
const char *localedir = "share";
|
||||||
|
|
||||||
|
buf = alloca(PATH_MAX);
|
||||||
DBG("EINA PREFIX: argv0=%s, symbol=%p, magicsharefile=%s, envprefix=%s\n", argv0, symbol, magicsharefile, envprefix);
|
DBG("EINA PREFIX: argv0=%s, symbol=%p, magicsharefile=%s, envprefix=%s\n", argv0, symbol, magicsharefile, envprefix);
|
||||||
pfx = calloc(1, sizeof(Eina_Prefix));
|
pfx = calloc(1, sizeof(Eina_Prefix));
|
||||||
if (!pfx) return NULL;
|
if (!pfx) return NULL;
|
||||||
|
@ -428,32 +433,41 @@ eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
|
||||||
* all with a common prefix that can be relocated
|
* all with a common prefix that can be relocated
|
||||||
*/
|
*/
|
||||||
/* 1. check last common char in bin and lib strings */
|
/* 1. check last common char in bin and lib strings */
|
||||||
for (p1 = pkg_bin, p2 = pkg_lib; *p1 && *p2; p1++, p2++)
|
if ( pkg_bin && pkg_lib )
|
||||||
{
|
{
|
||||||
if (*p1 != *p2)
|
for (p1 = pkg_bin, p2 = pkg_lib; *p1 && *p2; p1++, p2++)
|
||||||
{
|
{
|
||||||
pkg_bin_p = p1;
|
if (*p1 != *p2)
|
||||||
pkg_lib_p = p2;
|
{
|
||||||
break;
|
pkg_bin_p = p1;
|
||||||
}
|
pkg_lib_p = p2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* 1. check last common char in bin and data strings */
|
/* 1. check last common char in bin and data strings */
|
||||||
for (p1 = pkg_bin, p2 = pkg_data; *p1 && *p2; p1++, p2++)
|
if (pkg_bin && pkg_data)
|
||||||
{
|
{
|
||||||
if (*p1 != *p2)
|
for (p1 = pkg_bin, p2 = pkg_data; *p1 && *p2; p1++, p2++)
|
||||||
{
|
{
|
||||||
pkg_data_p = p2;
|
if (*p1 != *p2)
|
||||||
break;
|
{
|
||||||
}
|
pkg_data_p = p2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* 1. check last common char in bin and locale strings */
|
/* 1. check last common char in bin and locale strings */
|
||||||
for (p1 = pkg_bin, p2 = pkg_locale; *p1 && *p2; p1++, p2++)
|
if (pkg_bin && pkg_locale)
|
||||||
{
|
{
|
||||||
if (*p1 != *p2)
|
for (p1 = pkg_bin, p2 = pkg_locale; *p1 && *p2; p1++, p2++)
|
||||||
{
|
{
|
||||||
pkg_locale_p = p2;
|
if (*p1 != *p2)
|
||||||
break;
|
{
|
||||||
}
|
pkg_locale_p = p2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* 2. if all the common string offsets match we compiled with a common prefix */
|
/* 2. if all the common string offsets match we compiled with a common prefix */
|
||||||
if (((pkg_bin_p - pkg_bin) == (pkg_lib_p - pkg_lib))
|
if (((pkg_bin_p - pkg_bin) == (pkg_lib_p - pkg_lib))
|
||||||
|
|
Loading…
Reference in New Issue