From: Vincent Torri Date: Tue, 8 Dec 2015 04:53:23 +0000 (+0900) Subject: Evil: fix infinite recursive loop in previous addition of setlocale() in Evil X-Git-Tag: upstream/1.20.0~7969 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7782e2388cded094f6969f0f200da8468c66485d;p=platform%2Fupstream%2Fefl.git Evil: fix infinite recursive loop in previous addition of setlocale() in Evil Summary: setlocale() called itself because it was defined as a #define so remove this #define from evil_locale.h and move it in another header file To avoid future problem, move similar defines to this header file Also clean all the header file mess in Evil Reviewers: cedric Subscribers: jpeg Differential Revision: https://phab.enlightenment.org/D3409 --- diff --git a/src/Makefile_Evil.am b/src/Makefile_Evil.am index 5c27eca..60fc567 100644 --- a/src/Makefile_Evil.am +++ b/src/Makefile_Evil.am @@ -13,6 +13,7 @@ lib/evil/evil_langinfo.h \ lib/evil/evil_locale.h \ lib/evil/evil_macro.h \ lib/evil/evil_macro_pop.h \ +lib/evil/evil_macro_wrapper.h \ lib/evil/evil_main.h \ lib/evil/evil_stdio.h \ lib/evil/evil_stdlib.h \ diff --git a/src/bin/evil/evil_test_link.c b/src/bin/evil/evil_test_link.c index 868e9f2..0aa4966 100644 --- a/src/bin/evil/evil_test_link.c +++ b/src/bin/evil/evil_test_link.c @@ -2,6 +2,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include #include #include diff --git a/src/bin/evil/evil_test_mkstemp.c b/src/bin/evil/evil_test_mkstemp.c index 427dc01..54d9df5 100644 --- a/src/bin/evil/evil_test_mkstemp.c +++ b/src/bin/evil/evil_test_mkstemp.c @@ -2,6 +2,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include #include #include diff --git a/src/bin/evil/evil_test_realpath.c b/src/bin/evil/evil_test_realpath.c index afd92f1..fbc4d1d 100644 --- a/src/bin/evil/evil_test_realpath.c +++ b/src/bin/evil/evil_test_realpath.c @@ -2,6 +2,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include #include #include diff --git a/src/lib/evil/Evil.h b/src/lib/evil/Evil.h index 6a69f7b..c4ee0a1 100644 --- a/src/lib/evil/Evil.h +++ b/src/lib/evil/Evil.h @@ -100,13 +100,7 @@ extern "C" { #include #undef WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#include -#include +#include /* for mkdir in evil_macro_wrapper */ typedef unsigned long uid_t; @@ -125,7 +119,6 @@ typedef unsigned long gid_t; #include "evil_time.h" #include "evil_unistd.h" #include "evil_util.h" -#include "evil_macro_pop.h" #ifndef S_ISDIR # define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) @@ -173,18 +166,10 @@ typedef unsigned long gid_t; #define _S_IWUSR _S_IWRITE #define _S_IRUSR _S_IREAD - /* -# define close(fd) _close(fd) -# define read(fd,buffer,count) _read((fd),(buffer),(count)) -# define write(fd,buffer,count) _write((fd),(buffer),(count)) -# define unlink(filename) _unlink((filename)) -# define lstat(f,s) _stat((f),(s)) - */ - #define sigsetjmp(Env, Save) setjmp(Env) -#undef EAPI -#define EAPI +#include "evil_macro_wrapper.h" +#include "evil_macro_pop.h" #ifdef __cplusplus } diff --git a/src/lib/evil/dlfcn.c b/src/lib/evil/dlfcn.c index 4f3760b..76fbf85 100644 --- a/src/lib/evil/dlfcn.c +++ b/src/lib/evil/dlfcn.c @@ -12,7 +12,8 @@ #include /* EnumProcessModules(Ex) */ -#include "Evil.h" +#include "evil_macro.h" +#include "evil_util.h" #include "evil_private.h" #include "dlfcn.h" diff --git a/src/lib/evil/evil_dirent.c b/src/lib/evil/evil_dirent.c index 6dcfca2..6f6b86a 100644 --- a/src/lib/evil/evil_dirent.c +++ b/src/lib/evil/evil_dirent.c @@ -2,10 +2,19 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include #include #include +#include -#include "Evil.h" +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include +#undef WIN32_LEAN_AND_MEAN + +#include "evil_macro.h" +#include "evil_stdio.h" struct DIR diff --git a/src/lib/evil/evil_fcntl.c b/src/lib/evil/evil_fcntl.c index 118ed17..188e476 100644 --- a/src/lib/evil/evil_fcntl.c +++ b/src/lib/evil/evil_fcntl.c @@ -6,8 +6,10 @@ #include #include /* for ioctlsocket */ +#include -#include "Evil.h" +#include "evil_macro.h" +#include "evil_fcntl.h" /* diff --git a/src/lib/evil/evil_inet.c b/src/lib/evil/evil_inet.c index 05d130c..54cee3d 100644 --- a/src/lib/evil/evil_inet.c +++ b/src/lib/evil/evil_inet.c @@ -40,7 +40,6 @@ #include "evil_macro.h" #include "evil_inet.h" -#include "evil_private.h" #ifndef EMSGSIZE # define EMSGSIZE WSAEMSGSIZE diff --git a/src/lib/evil/evil_inet.h b/src/lib/evil/evil_inet.h index 6858a83..fb4e072 100644 --- a/src/lib/evil/evil_inet.h +++ b/src/lib/evil/evil_inet.h @@ -90,13 +90,6 @@ EAPI int evil_inet_pton(int af, const char *src, void *dst); /** - * @def inet_pton(x,y,z) - * - * Wrapper around evil_inet_pton(). - */ -#define inet_pton(x,y,z) evil_inet_pton(x,y,z) - -/** * @brief Convert IPv4 and IPv6 addresses from binary to text form. * * @param af The address family. @@ -136,13 +129,6 @@ EAPI int evil_inet_pton(int af, const char *src, void *dst); */ EAPI const char *evil_inet_ntop(int af, const char *src, void *dst, size_t size); -/** - * @def inet_ntop(x,y,z,s) - * - * Wrapper around evil_inet_ntop(). - */ -#define inet_ntop(x,y,z,s) evil_inet_ntop(x,y,z,s) - #endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */ diff --git a/src/lib/evil/evil_langinfo.c b/src/lib/evil/evil_langinfo.c index 2cec67a..25a863a 100644 --- a/src/lib/evil/evil_langinfo.c +++ b/src/lib/evil/evil_langinfo.c @@ -2,7 +2,11 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ -#include "Evil.h" +#include +#include + +#include "evil_macro.h" +#include "evil_langinfo.h" static char * diff --git a/src/lib/evil/evil_libgen.c b/src/lib/evil/evil_libgen.c index 779193f..d96ba5b 100644 --- a/src/lib/evil/evil_libgen.c +++ b/src/lib/evil/evil_libgen.c @@ -4,7 +4,8 @@ #include -#include "Evil.h" +#include "evil_macro.h" +#include "evil_libgen.h" char _evil_basename_buf[PATH_MAX]; char _evil_dirname_buf[PATH_MAX]; diff --git a/src/lib/evil/evil_locale.c b/src/lib/evil/evil_locale.c index d243ad8..0a28a5e 100644 --- a/src/lib/evil/evil_locale.c +++ b/src/lib/evil/evil_locale.c @@ -14,7 +14,6 @@ #include "evil_macro.h" #include "evil_locale.h" -#include "evil_private.h" /* * LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME need at least a buffer diff --git a/src/lib/evil/evil_locale.h b/src/lib/evil/evil_locale.h index 6196800..4bf14ec 100644 --- a/src/lib/evil/evil_locale.h +++ b/src/lib/evil/evil_locale.h @@ -18,6 +18,8 @@ * @def LC_MESSAGES * * New locale value, based on the one in libintl.h + * + * @since 1.16 */ #ifdef LC_MESSAGES # undef LC_MESSAGES @@ -43,18 +45,10 @@ * Conformity: Non applicable. * * Supported OS: Windows XP. - */ -EAPI char *evil_setlocale(int category, const char *locale); - -/** - * @def setlocale(cat, loc) * - * Wrapper around evil_setlocale(). + * @since 1.16 */ -#ifdef setlocale /* libintl.h defines setlocale() but always returns "C" */ -# undef setlocale -#endif -#define setlocale(cat, loc) evil_setlocale(cat, loc) +EAPI char *evil_setlocale(int category, const char *locale); /** diff --git a/src/lib/evil/evil_macro_pop.h b/src/lib/evil/evil_macro_pop.h index bad78db..8b998c3 100644 --- a/src/lib/evil/evil_macro_pop.h +++ b/src/lib/evil/evil_macro_pop.h @@ -64,5 +64,8 @@ #define SCNuPTR "llu" #endif /* _WIN64 */ +#undef EAPI +#define EAPI + #endif /* __EVIL_MACRO_POP_H__ */ diff --git a/src/lib/evil/evil_macro_wrapper.h b/src/lib/evil/evil_macro_wrapper.h new file mode 100644 index 0000000..4eea1fa --- /dev/null +++ b/src/lib/evil/evil_macro_wrapper.h @@ -0,0 +1,110 @@ +#ifndef __EVIL_MACRO_WRAPPER_H__ +#define __EVIL_MACRO_WRAPPER_H__ + + +/* + * evil_inet.h + */ + +#if ! (_WIN32_WINNT >= 0x600 /* _WIN32_WINNT_VISTA */) + +/** + * @def inet_pton(x,y,z) + * + * Wrapper around evil_inet_pton(). + */ +#define inet_pton(x,y,z) evil_inet_pton(x,y,z) + +/** + * @def inet_ntop(x,y,z,s) + * + * Wrapper around evil_inet_ntop(). + */ +#define inet_ntop(x,y,z,s) evil_inet_ntop(x,y,z,s) + + +#endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */ + +/* + * evil_locale.h + */ + +/** + * @def setlocale(cat, loc) + * + * Wrapper around evil_setlocale(). + * @since 1.16 + */ +#ifdef setlocale /* libintl.h defines setlocale() but always returns "C" */ +# undef setlocale +#endif +#define setlocale(cat, loc) evil_setlocale(cat, loc) + +/* + * evil_stdio.h + */ + +/** + * @def rename(src, dest) + * + * Wrapper around evil_rename(). + * + * @since 1.8 + */ +#ifdef rename +# undef rename +#endif +#define rename(src, dst) evil_rename(src, dst) + +/** + * @def mkdir(dirname, mode) + * + * Wrapper around evil_mkdir(). + * + * @since 1.15 + */ +#ifdef mkdir +# undef mkdir +#endif +#define mkdir(dirname, mode) evil_mkdir(dirname, mode) + +/* + * evil_time.h + */ + +/** + * @def localtime_r(t, r) + * + * Wrapper around evil_localtime_r(). + */ +#ifdef localtime_r +# undef localtime_r +#endif +#define localtime_r(t, r) evil_localtime_r(t, r) + +/* + * evil_unistd.h + */ + +/** + * @def getcwd(b,s) + * + * Wrapper around evil_getcwd(). + */ +#ifdef getcwd +# undef getcwd +#endif +#define getcwd(b,s) evil_getcwd((b),(s)) + +/** + * @def pipe(fds) + * + * Wrapper around evil_pipe(). + */ +#ifdef pipe +# undef pipe +#endif +#define pipe(fds) evil_pipe(fds) + + +#endif diff --git a/src/lib/evil/evil_main.c b/src/lib/evil/evil_main.c index 79d4e34..2b7ae51 100644 --- a/src/lib/evil/evil_main.c +++ b/src/lib/evil/evil_main.c @@ -2,13 +2,17 @@ # include #endif +#include + #ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN #endif #include #undef WIN32_LEAN_AND_MEAN -#include "Evil.h" +#include "evil_macro.h" +#include "evil_unistd.h" +#include "evil_main.h" #include "evil_private.h" @@ -18,6 +22,8 @@ extern LONGLONG _evil_time_freq; extern LONGLONG _evil_time_count; extern long _evil_time_second; +long _evil_systemtime_to_time(SYSTEMTIME st); + int evil_init(void) { diff --git a/src/lib/evil/evil_private.h b/src/lib/evil/evil_private.h index 0f8b6d1..560b4e2 100644 --- a/src/lib/evil/evil_private.h +++ b/src/lib/evil/evil_private.h @@ -14,12 +14,6 @@ extern "C" { # endif #endif -long _evil_systemtime_to_time(SYSTEMTIME st); - -void _evil_error_display(const char *fct, LONG res); - -void _evil_last_error_display(const char *fct); - #ifdef __cplusplus } #endif diff --git a/src/lib/evil/evil_pwd.c b/src/lib/evil/evil_pwd.c index f53b1d8..bcf9eb3 100644 --- a/src/lib/evil/evil_pwd.c +++ b/src/lib/evil/evil_pwd.c @@ -2,11 +2,13 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include + #define _POSIX #include #include -#include "Evil.h" +#include "evil_macro.h" #include "pwd.h" diff --git a/src/lib/evil/evil_stdio.c b/src/lib/evil/evil_stdio.c index c30f0dc..5919d0c 100644 --- a/src/lib/evil/evil_stdio.c +++ b/src/lib/evil/evil_stdio.c @@ -3,8 +3,11 @@ #endif /* HAVE_CONFIG_H */ #include +#include +#include -#include "Evil.h" +#include "evil_macro.h" +#include "evil_stdio.h" #include "evil_private.h" #undef rename diff --git a/src/lib/evil/evil_stdio.h b/src/lib/evil/evil_stdio.h index f1de75a..1f65609 100644 --- a/src/lib/evil/evil_stdio.h +++ b/src/lib/evil/evil_stdio.h @@ -45,13 +45,6 @@ EAPI int evil_rename(const char *src, const char *dst); /** - * @def rename(src, dest) - * - * Wrapper around evil_rename(). - */ -#define rename(src, dst) evil_rename(src, dst) - -/** * @brief Wrap the _mkdir() function on Windows. * * @param[in] dirname The new dir name. @@ -64,12 +57,5 @@ EAPI int evil_rename(const char *src, const char *dst); */ EAPI int evil_mkdir(const char *dirname, mode_t mode); -/** - * @def mkdir(dirname, mode) - * - * Wrapper around evil_mkdir(). - */ -#define mkdir(dirname, mode) evil_mkdir(dirname, mode) - #endif /* __EVIL_STDIO_H__ */ diff --git a/src/lib/evil/evil_stdlib.c b/src/lib/evil/evil_stdlib.c index c10eafb..bcafb3a 100644 --- a/src/lib/evil/evil_stdlib.c +++ b/src/lib/evil/evil_stdlib.c @@ -19,7 +19,6 @@ #include "evil_macro.h" #include "evil_stdlib.h" -#include "evil_private.h" /* * Environment variable related functions diff --git a/src/lib/evil/evil_string.c b/src/lib/evil/evil_string.c index 12411be..634565b 100644 --- a/src/lib/evil/evil_string.c +++ b/src/lib/evil/evil_string.c @@ -2,8 +2,12 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ -#include "Evil.h" -#include "evil_private.h" +#include +#include +#include + +#include "evil_macro.h" +#include "evil_string.h" /* diff --git a/src/lib/evil/evil_time.c b/src/lib/evil/evil_time.c index 1bd716a..76c5a58 100644 --- a/src/lib/evil/evil_time.c +++ b/src/lib/evil/evil_time.c @@ -7,7 +7,9 @@ #include #include -#include "Evil.h" +#include "evil_macro.h" +#include "evil_time.h" +#include "evil_macro_wrapper.h" #include "evil_private.h" struct tm * diff --git a/src/lib/evil/evil_time.h b/src/lib/evil/evil_time.h index c65115a..34607de 100644 --- a/src/lib/evil/evil_time.h +++ b/src/lib/evil/evil_time.h @@ -35,16 +35,6 @@ EAPI struct tm *evil_localtime_r(const time_t *timep, struct tm *result); /** - * @def localtime_r(t, r) - * - * Wrapper around evil_localtime_r(). - */ -#ifdef localtime_r -# undef localtime_r -#endif -#define localtime_r(t, r) evil_localtime_r(t, r) - -/** * @brief Convert a string representation of time to a time tm structure . * * @param buf The string to convert. diff --git a/src/lib/evil/evil_unistd.c b/src/lib/evil/evil_unistd.c index c75f63f..27f6825 100644 --- a/src/lib/evil/evil_unistd.c +++ b/src/lib/evil/evil_unistd.c @@ -3,6 +3,7 @@ #endif /* HAVE_CONFIG_H */ #include +#include # include #ifndef WIN32_LEAN_AND_MEAN @@ -11,8 +12,8 @@ #include #undef WIN32_LEAN_AND_MEAN -#include "Evil.h" -#include "evil_private.h" +#include "evil_macro.h" +#include "evil_unistd.h" LONGLONG _evil_time_freq; @@ -20,6 +21,8 @@ LONGLONG _evil_time_count; long _evil_time_second; +long _evil_systemtime_to_time(SYSTEMTIME st); + long _evil_systemtime_to_time(SYSTEMTIME st) { diff --git a/src/lib/evil/evil_unistd.h b/src/lib/evil/evil_unistd.h index 013fbf8..dbc6cfe 100644 --- a/src/lib/evil/evil_unistd.h +++ b/src/lib/evil/evil_unistd.h @@ -113,13 +113,6 @@ EAPI ssize_t readlink(const char *path, char *buf, size_t bufsiz); */ EAPI char *evil_getcwd(char *buffer, size_t size); -/** - * @def getcwd(b,s) - * - * Wrapper around evil_getcwd(). - */ -#define getcwd(b,s) evil_getcwd((b),(s)) - /* * Sockets and pipe related functions * @@ -166,13 +159,6 @@ EAPI void evil_sockets_shutdown(void); */ EAPI int evil_pipe(int *fds); -/** - * @def pipe(fds) - * - * Wrapper around evil_pipe(). - */ -#define pipe(fds) evil_pipe(fds) - /** * @} diff --git a/src/lib/evil/evil_util.c b/src/lib/evil/evil_util.c index 0fff26d..00ce36e 100644 --- a/src/lib/evil/evil_util.c +++ b/src/lib/evil/evil_util.c @@ -16,9 +16,11 @@ #include "evil_macro.h" #include "evil_util.h" -#include "evil_private.h" +/* static void _evil_error_display(const char *fct, LONG res); */ +static void _evil_last_error_display(const char *fct); + wchar_t * evil_char_to_wchar(const char *text) { @@ -159,15 +161,15 @@ evil_format_message(long err) return disp; } -void -_evil_error_display(const char *fct, LONG res) -{ - char *error; +/* static void */ +/* _evil_error_display(const char *fct, LONG res) */ +/* { */ +/* char *error; */ - error = evil_format_message(res); - fprintf(stderr, "[Evil] [%s] ERROR (%ld): %s\n", fct, res, error); - free(error); -} +/* error = evil_format_message(res); */ +/* fprintf(stderr, "[Evil] [%s] ERROR (%ld): %s\n", fct, res, error); */ +/* free(error); */ +/* } */ char * evil_last_error_get(void) @@ -178,7 +180,7 @@ evil_last_error_get(void) return evil_format_message(err); } -void +static void _evil_last_error_display(const char *fct) { char *error;