diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog index 192ad13eec..52fba7995a 100644 --- a/legacy/evil/ChangeLog +++ b/legacy/evil/ChangeLog @@ -1,3 +1,20 @@ +2008-09-14 Vincent Torri + + Fix compilation with vc++. Based on patch by Dmitriy Mazovka + + * src/lib/Evil.h: + move typedef's + + * src/lib/evil.c: + remove declaration and include + + * src/lib/evil_stdlib.c: + simplify mkstmp implementation + fix getenv + + * src/lib/evil_unistd.c: + include correct headers for readlink and symlink + 2008-09-13 Vincent Torri * big rework of evil diff --git a/legacy/evil/src/lib/Evil.h b/legacy/evil/src/lib/Evil.h index afc2120ead..ffdae28154 100644 --- a/legacy/evil/src/lib/Evil.h +++ b/legacy/evil/src/lib/Evil.h @@ -68,12 +68,22 @@ extern "C" { #include #include + #ifdef PATH_MAX # undef PATH_MAX #endif /* PATH_MAX */ #define PATH_MAX MAX_PATH + +#ifdef _MSC_VER + +typedef SSIZE_T ssize_t; +typedef unsigned short mode_t; + +#endif /* _MSC_VER */ + + #include "evil_stdlib.h" #include "evil_unistd.h" #include "evil_util.h" @@ -134,13 +144,6 @@ extern "C" { # define F_UNLCK 2 # endif /* ! F_RDLCK */ -#ifdef _MSC_VER - -typedef long ssize_t; -typedef unsigned short mode_t; - -#endif /* _MSC_VER */ - /** * @struct flock * @brief A structure that control the lock of a file descriptor. diff --git a/legacy/evil/src/lib/evil.c b/legacy/evil/src/lib/evil.c index fb90e8ef5e..874e48d912 100644 --- a/legacy/evil/src/lib/evil.c +++ b/legacy/evil/src/lib/evil.c @@ -9,7 +9,6 @@ # include # include # include -# include # include # include #else @@ -38,9 +37,6 @@ #include "Evil.h" -static struct passwd pw; - - #ifndef __CEGCC__ int fcntl(int fd, int cmd, ...) diff --git a/legacy/evil/src/lib/evil_stdlib.c b/legacy/evil/src/lib/evil_stdlib.c index d314938ed8..4d1d136293 100644 --- a/legacy/evil/src/lib/evil_stdlib.c +++ b/legacy/evil/src/lib/evil_stdlib.c @@ -1,5 +1,8 @@ #include +#ifndef __CEGCC__ +# include +#endif /* ! __CEGCC__ */ #ifndef __MINGW32CE__ #include #endif /* ! __MINGW32CE__ */ @@ -126,6 +129,7 @@ setenv(const char *name, char *old_name; char *str; int length; + int res; if (!name || !*name) return -1; @@ -139,7 +143,7 @@ setenv(const char *name, /* if name is already set and overwrite is 0, we exit with success */ old_name = getenv(name); - if (!overwrite && oldname) + if (!overwrite && old_name) return 0; length = strlen(name) + strlen(value) + 2; @@ -156,6 +160,8 @@ setenv(const char *name, res = _putenv(str); free(str); + return res; + #else /* __CEGCC__ || __MINGW32CE__ */ HKEY key; @@ -224,29 +230,22 @@ unsetenv(const char *name) * */ -#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) ) +#ifndef __CEGCC__ int mkstemp(char *template) { int fd; -#ifdef __MINGW32__ if (!_mktemp(template)) return -1; - fd = _sopen(template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _SH_DENYNO, _S_IREAD | _S_IWRITE); -#else - if (_mktemp_s(template, PATH_MAX) != 0) - return -1; - - _sopen_s(&fd, template, _O_RDWR | _O_BINARY | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE); -#endif /* ! __MINGW32__ */ + fd = _open(template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE); return fd; } -#endif /* ! ( __CEGCC__ || __MINGW32CE__ ) */ +#endif /* ! __CEGCC__ */ char * diff --git a/legacy/evil/src/lib/evil_unistd.c b/legacy/evil/src/lib/evil_unistd.c index 54a7999e77..866b15aa8e 100644 --- a/legacy/evil/src/lib/evil_unistd.c +++ b/legacy/evil/src/lib/evil_unistd.c @@ -2,6 +2,12 @@ #include #undef WIN32_LEAN_AND_MEAN +#ifdef _MSC_VER +# include +# include +# include +#endif + #ifdef HAVE_CONFIG_H # include "config.h" #endif /* HAVE_CONFIG_H */