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
This commit is contained in:
Vincent Torri 2015-12-08 13:53:23 +09:00 committed by Jean-Philippe Andre
parent 3e31eda3bd
commit 7782e2388c
28 changed files with 186 additions and 112 deletions

View File

@ -13,6 +13,7 @@ lib/evil/evil_langinfo.h \
lib/evil/evil_locale.h \ lib/evil/evil_locale.h \
lib/evil/evil_macro.h \ lib/evil/evil_macro.h \
lib/evil/evil_macro_pop.h \ lib/evil/evil_macro_pop.h \
lib/evil/evil_macro_wrapper.h \
lib/evil/evil_main.h \ lib/evil/evil_main.h \
lib/evil/evil_stdio.h \ lib/evil/evil_stdio.h \
lib/evil/evil_stdlib.h \ lib/evil/evil_stdlib.h \

View File

@ -2,6 +2,7 @@
# include "config.h" # include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <string.h> #include <string.h>
#include <Evil.h> #include <Evil.h>

View File

@ -2,6 +2,7 @@
# include "config.h" # include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <string.h> #include <string.h>
#include <Evil.h> #include <Evil.h>

View File

@ -2,6 +2,7 @@
# include "config.h" # include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <string.h> #include <string.h>
#include <Evil.h> #include <Evil.h>

View File

@ -100,13 +100,7 @@ extern "C" {
#include <windows.h> #include <windows.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <stdlib.h> #include <sys/stat.h> /* for mkdir in evil_macro_wrapper */
#include <stdio.h>
#include <time.h>
#include <limits.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
typedef unsigned long uid_t; typedef unsigned long uid_t;
@ -125,7 +119,6 @@ typedef unsigned long gid_t;
#include "evil_time.h" #include "evil_time.h"
#include "evil_unistd.h" #include "evil_unistd.h"
#include "evil_util.h" #include "evil_util.h"
#include "evil_macro_pop.h"
#ifndef S_ISDIR #ifndef S_ISDIR
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) # 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_IWUSR _S_IWRITE
#define _S_IRUSR _S_IREAD #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) #define sigsetjmp(Env, Save) setjmp(Env)
#undef EAPI #include "evil_macro_wrapper.h"
#define EAPI #include "evil_macro_pop.h"
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -12,7 +12,8 @@
#include <psapi.h> /* EnumProcessModules(Ex) */ #include <psapi.h> /* EnumProcessModules(Ex) */
#include "Evil.h" #include "evil_macro.h"
#include "evil_util.h"
#include "evil_private.h" #include "evil_private.h"
#include "dlfcn.h" #include "dlfcn.h"

View File

@ -2,10 +2,19 @@
# include "config.h" # include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h>
#include "Evil.h" #ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include "evil_macro.h"
#include "evil_stdio.h"
struct DIR struct DIR

View File

@ -6,8 +6,10 @@
#include <sys/locking.h> #include <sys/locking.h>
#include <winsock2.h> /* for ioctlsocket */ #include <winsock2.h> /* for ioctlsocket */
#include <io.h>
#include "Evil.h" #include "evil_macro.h"
#include "evil_fcntl.h"
/* /*

View File

@ -40,7 +40,6 @@
#include "evil_macro.h" #include "evil_macro.h"
#include "evil_inet.h" #include "evil_inet.h"
#include "evil_private.h"
#ifndef EMSGSIZE #ifndef EMSGSIZE
# define EMSGSIZE WSAEMSGSIZE # define EMSGSIZE WSAEMSGSIZE

View File

@ -89,13 +89,6 @@
*/ */
EAPI int evil_inet_pton(int af, const char *src, void *dst); 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. * @brief Convert IPv4 and IPv6 addresses from binary to text form.
* *
@ -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); 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 */ #endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */

View File

@ -2,7 +2,11 @@
# include "config.h" # include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include "Evil.h" #include <stdlib.h>
#include <string.h>
#include "evil_macro.h"
#include "evil_langinfo.h"
static char * static char *

View File

@ -4,7 +4,8 @@
#include <string.h> #include <string.h>
#include "Evil.h" #include "evil_macro.h"
#include "evil_libgen.h"
char _evil_basename_buf[PATH_MAX]; char _evil_basename_buf[PATH_MAX];
char _evil_dirname_buf[PATH_MAX]; char _evil_dirname_buf[PATH_MAX];

View File

@ -14,7 +14,6 @@
#include "evil_macro.h" #include "evil_macro.h"
#include "evil_locale.h" #include "evil_locale.h"
#include "evil_private.h"
/* /*
* LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME need at least a buffer * LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME need at least a buffer

View File

@ -18,6 +18,8 @@
* @def LC_MESSAGES * @def LC_MESSAGES
* *
* New locale value, based on the one in libintl.h * New locale value, based on the one in libintl.h
*
* @since 1.16
*/ */
#ifdef LC_MESSAGES #ifdef LC_MESSAGES
# undef LC_MESSAGES # undef LC_MESSAGES
@ -43,19 +45,11 @@
* Conformity: Non applicable. * Conformity: Non applicable.
* *
* Supported OS: Windows XP. * Supported OS: Windows XP.
*
* @since 1.16
*/ */
EAPI char *evil_setlocale(int category, const char *locale); EAPI char *evil_setlocale(int category, const char *locale);
/**
* @def setlocale(cat, loc)
*
* Wrapper around evil_setlocale().
*/
#ifdef setlocale /* libintl.h defines setlocale() but always returns "C" */
# undef setlocale
#endif
#define setlocale(cat, loc) evil_setlocale(cat, loc)
/** /**
* @} * @}

View File

@ -64,5 +64,8 @@
#define SCNuPTR "llu" #define SCNuPTR "llu"
#endif /* _WIN64 */ #endif /* _WIN64 */
#undef EAPI
#define EAPI
#endif /* __EVIL_MACRO_POP_H__ */ #endif /* __EVIL_MACRO_POP_H__ */

View File

@ -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

View File

@ -2,13 +2,17 @@
# include <config.h> # include <config.h>
#endif #endif
#include <stdio.h>
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
#endif #endif
#include <winsock2.h> #include <winsock2.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include "Evil.h" #include "evil_macro.h"
#include "evil_unistd.h"
#include "evil_main.h"
#include "evil_private.h" #include "evil_private.h"
@ -18,6 +22,8 @@ extern LONGLONG _evil_time_freq;
extern LONGLONG _evil_time_count; extern LONGLONG _evil_time_count;
extern long _evil_time_second; extern long _evil_time_second;
long _evil_systemtime_to_time(SYSTEMTIME st);
int int
evil_init(void) evil_init(void)
{ {

View File

@ -14,12 +14,6 @@ extern "C" {
# endif # endif
#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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -2,11 +2,13 @@
# include "config.h" # include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include <stdio.h>
#define _POSIX #define _POSIX
#include <io.h> #include <io.h>
#include <lmcons.h> #include <lmcons.h>
#include "Evil.h" #include "evil_macro.h"
#include "pwd.h" #include "pwd.h"

View File

@ -3,8 +3,11 @@
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include <direct.h> #include <direct.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "Evil.h" #include "evil_macro.h"
#include "evil_stdio.h"
#include "evil_private.h" #include "evil_private.h"
#undef rename #undef rename

View File

@ -44,13 +44,6 @@
*/ */
EAPI int evil_rename(const char *src, const char *dst); 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. * @brief Wrap the _mkdir() function on Windows.
* *
@ -64,12 +57,5 @@ EAPI int evil_rename(const char *src, const char *dst);
*/ */
EAPI int evil_mkdir(const char *dirname, mode_t mode); 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__ */ #endif /* __EVIL_STDIO_H__ */

View File

@ -19,7 +19,6 @@
#include "evil_macro.h" #include "evil_macro.h"
#include "evil_stdlib.h" #include "evil_stdlib.h"
#include "evil_private.h"
/* /*
* Environment variable related functions * Environment variable related functions

View File

@ -2,8 +2,12 @@
# include "config.h" # include "config.h"
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include "Evil.h" #include <stdlib.h>
#include "evil_private.h" #include <string.h>
#include <ctype.h>
#include "evil_macro.h"
#include "evil_string.h"
/* /*

View File

@ -7,7 +7,9 @@
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#include "Evil.h" #include "evil_macro.h"
#include "evil_time.h"
#include "evil_macro_wrapper.h"
#include "evil_private.h" #include "evil_private.h"
struct tm * struct tm *

View File

@ -34,16 +34,6 @@
*/ */
EAPI struct tm *evil_localtime_r(const time_t *timep, struct tm *result); 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 . * @brief Convert a string representation of time to a time tm structure .
* *

View File

@ -3,6 +3,7 @@
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include <errno.h> #include <errno.h>
#include <direct.h>
# include <sys/time.h> # include <sys/time.h>
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
@ -11,8 +12,8 @@
#include <winsock2.h> #include <winsock2.h>
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include "Evil.h" #include "evil_macro.h"
#include "evil_private.h" #include "evil_unistd.h"
LONGLONG _evil_time_freq; LONGLONG _evil_time_freq;
@ -20,6 +21,8 @@ LONGLONG _evil_time_count;
long _evil_time_second; long _evil_time_second;
long _evil_systemtime_to_time(SYSTEMTIME st);
long long
_evil_systemtime_to_time(SYSTEMTIME st) _evil_systemtime_to_time(SYSTEMTIME st)
{ {

View File

@ -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); 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 * Sockets and pipe related functions
* *
@ -166,13 +159,6 @@ EAPI void evil_sockets_shutdown(void);
*/ */
EAPI int evil_pipe(int *fds); EAPI int evil_pipe(int *fds);
/**
* @def pipe(fds)
*
* Wrapper around evil_pipe().
*/
#define pipe(fds) evil_pipe(fds)
/** /**
* @} * @}

View File

@ -16,9 +16,11 @@
#include "evil_macro.h" #include "evil_macro.h"
#include "evil_util.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 * wchar_t *
evil_char_to_wchar(const char *text) evil_char_to_wchar(const char *text)
{ {
@ -159,15 +161,15 @@ evil_format_message(long err)
return disp; return disp;
} }
void /* static void */
_evil_error_display(const char *fct, LONG res) /* _evil_error_display(const char *fct, LONG res) */
{ /* { */
char *error; /* char *error; */
error = evil_format_message(res); /* error = evil_format_message(res); */
fprintf(stderr, "[Evil] [%s] ERROR (%ld): %s\n", fct, res, error); /* fprintf(stderr, "[Evil] [%s] ERROR (%ld): %s\n", fct, res, error); */
free(error); /* free(error); */
} /* } */
char * char *
evil_last_error_get(void) evil_last_error_get(void)
@ -178,7 +180,7 @@ evil_last_error_get(void)
return evil_format_message(err); return evil_format_message(err);
} }
void static void
_evil_last_error_display(const char *fct) _evil_last_error_display(const char *fct)
{ {
char *error; char *error;