* Makefile.am:

add autogen.sh in archive distribution

* configure.ac:
remove useless defines
first support of mingw32msvc compiler

* src/lib/Evil.h:
move some macro definitions

* src/lib/Makefile.am:
add evil_(fcntl/langinfo).(c/h) and install pwd.h

* src/lib/dlfcn/dlfcn.h:
remove useless ifdef

* src/lib/evil.c:
comment all code for now. It will be deleted later

* src/lib/evil_fcntl.c:
* src/lib/evil_fcntl.h:
* src/lib/evil_langinfo.c:
* src/lib/evil_langinfo.h:
move fcntl and langinfo related code to their own files

* src/lib/evil_mman.c:
remove useless inclusion

* src/lib/evil_pwd.c:
pw var is not needed with cegcc

* src/lib/evil_stdlib.c:
fix bugs, formatting

* src/lib/evil_unistd.c:
add missing declarations and fix header files

* src/lib/evil_unistd.h:
move pid_t typedef to Evil.h

* src/lib/evil_util.c:
additional include and fix a bug in output

* src/lib/pwd.h:
use EAPI from Evil.h, define struct passwd when not using cegcc

* src/lib/sys/mman.h:
use EAPI from Evil.h

* win32/common/fnmatch.c:
* win32/common/fnmatch.h:
* win32/common/fnmatch_list_of_states.c:
* win32/vs8/evil.sln:
fix and cleanup with vc++ compilation
Based on patch by Dmitriy Mazovka


SVN revision: 35993
This commit is contained in:
Vincent Torri 2008-09-15 06:56:14 +00:00
parent bae73a2b60
commit a7f00b51bc
23 changed files with 465 additions and 362 deletions

View File

@ -1,3 +1,61 @@
2008-09-15 Vincent Torri <doursse at users dot sf dot net>
* Makefile.am:
add autogen.sh in archive distribution
* configure.ac:
remove useless defines
first support of mingw32msvc compiler
* src/lib/Evil.h:
move some macro definitions
* src/lib/Makefile.am:
add evil_(fcntl/langinfo).(c/h) and install pwd.h
* src/lib/dlfcn/dlfcn.h:
remove useless ifdef
* src/lib/evil.c:
comment all code for now. It will be deleted later
* src/lib/evil_fcntl.c:
* src/lib/evil_fcntl.h:
* src/lib/evil_langinfo.c:
* src/lib/evil_langinfo.h:
move fcntl and langinfo related code to their own files
* src/lib/evil_mman.c:
remove useless inclusion
* src/lib/evil_pwd.c:
pw var is not needed with cegcc
* src/lib/evil_stdlib.c:
fix bugs, formatting
* src/lib/evil_unistd.c:
add missing declarations and fix header files
* src/lib/evil_unistd.h:
move pid_t typedef to Evil.h
* src/lib/evil_util.c:
additional include and fix a bug in output
* src/lib/pwd.h:
use EAPI from Evil.h, define struct passwd when not using cegcc
* src/lib/sys/mman.h:
use EAPI from Evil.h
* win32/common/fnmatch.c:
* win32/common/fnmatch.h:
* win32/common/fnmatch_list_of_states.c:
* win32/vs8/evil.sln:
fix and cleanup with vc++ compilation
Based on patch by Dmitriy Mazovka
2008-09-14 Vincent Torri <doursse at users dot sf dot net>
Fix compilation with vc++. Based on patch by Dmitriy Mazovka

View File

@ -24,6 +24,7 @@ EXTRA_DIST = \
COPYING \
COPYING-PLAIN \
Doxyfile \
autogen.sh \
evil.pc.in
pkgconfigdir = $(libdir)/pkgconfig

View File

@ -11,7 +11,7 @@ dnl for each platform.
win32_libs=""
win32_cflags=""
case "$host_os" in
mingw|mingw32)
mingw | mingw32 | mingw32msvc)
win32_libs="-lole32 -luuid -lws2_32"
;;
cegcc)
@ -30,9 +30,7 @@ AC_SUBST(win32_libs)
dnl needed for correct definition of EAPI
AC_DEFINE(EFL_EVIL_BUILD, 1, [Define to mention that evil is built])
AC_DEFINE(EFL_EVIL_MMAN_BUILD, 1, [Define to mention that evil mman is built])
AC_DEFINE(EFL_EVIL_DLFCN_BUILD, 1, [Define to mention that evil dlfcn is built])
AC_DEFINE(EFL_EVIL_PWD_BUILD, 1, [Define to mention that evil pwd is built])
AM_INIT_AUTOMAKE(1.6 dist-bzip2)

View File

@ -76,151 +76,6 @@ extern "C" {
#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"
#ifndef __CEGCC__
# include <sys/types.h>
/**
* @def FD_CLOEXEC
* Specifies that the file descriptor should be closed when an exec()
* function is invoked.
*/
# define FD_CLOEXEC 1
/**
* @def F_SETFD
* Specifies that fcntl() should set the file descriptor flags
* associated with the filedes argument.
*/
/**
* @def F_SETLK
* Specifies that fcntl() should set or clear a file segment lock
* according to the lock description pointed to by the third argument.
*/
/**
* @def F_SETLKW
* Equivalent to F_SETLK except that if a shared or exclusive lock
* is blocked by other locks, the thread shall wait until the request
* can be satisfied.
*/
# define F_SETFD 2
# define F_SETLK 6
# define F_SETLKW 7
/**
* @def F_RDLCK
* Read (or shared) lock
*/
/**
* @def F_WRLCK
* Write (or exclusive) lock
*/
/**
* @def F_UNLCK
* Remove lock
*/
# ifndef F_RDLCK
# define F_RDLCK 0
# define F_WRLCK 1
# define F_UNLCK 2
# endif /* ! F_RDLCK */
/**
* @struct flock
* @brief A structure that control the lock of a file descriptor.
*/
struct flock
{
short int l_type; /**< lock type: read, write, ... */
short int l_whence; /**< type of l_start */
off_t l_start; /**< starting offset */
off_t l_len; /**< 0 means end of the file */
pid_t l_pid; /**< lock owner */
};
/**
* @brief Provide control over file descriptors.
*
* @param fd The file descriptor.
* @param cmd The type of control.
* @return 0 on success, -1 otherwise.
*
* Performs one of various miscellaneous operations on @p fd.
* The operation in question is determined by @p cmd:
*
* - F_SETFD: Set the close-on-exec flag to the value specified
* by the argument after command (only the least significant
* bit is used).
* - F_SETLK and F_SETLKW: used to manage discretionary file locks.
* The third argument must be a pointer to a struct flock (that
* may be overwritten by this call).
*
* This function returns 0 on success, -1 otherwise.
*
* Conformity: None.
*
* Supported OS: Windows Vista, Windows XP or Windows 2000
* Professional.
*
* @ingroup Evil
*/
EAPI int fcntl(int fd, int cmd, ...);
#endif /* ! __CEGCC__ */
typedef int nl_item;
#define __NL_ITEM( CATEGORY, INDEX ) ((CATEGORY << 16) | INDEX)
#define __NL_ITEM_CATEGORY( ITEM ) (ITEM >> 16)
#define __NL_ITEM_INDEX( ITEM ) (ITEM & 0xffff)
enum {
/*
* LC_CTYPE category...
* Character set classification items.
*/
_NL_CTYPE_CODESET = __NL_ITEM( LC_CTYPE, 0 ),
/*
* Dummy entry, to terminate the list.
*/
_NL_ITEM_CLASSIFICATION_END
};
/*
* Define the public aliases for the enumerated classification indices...
*/
# define CODESET _NL_CTYPE_CODESET
EAPI char *nl_langinfo(nl_item index);
#ifndef __CEGCC__
typedef unsigned long uid_t;
typedef unsigned long gid_t;
#endif /* ! __CEGCC__ */
#ifdef _MSC_VER
#define F_OK 0 /* Check for file existence */
@ -233,9 +88,28 @@ typedef unsigned long gid_t;
#define _S_IWUSR _S_IWRITE
#define _S_IRUSR _S_IREAD
typedef int pid_t;
typedef SSIZE_T ssize_t;
typedef unsigned short mode_t;
#endif /* _MSC_VER */
#ifndef __CEGCC__
typedef unsigned long uid_t;
typedef unsigned long gid_t;
#endif /* ! __CEGCC__ */
#include "evil_fcntl.h"
#include "evil_langinfo.h"
#include "evil_stdlib.h"
#include "evil_unistd.h"
#include "evil_util.h"
#if defined(__MSDOS__) || defined(__EMX__) || \
(defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__) && !defined(__CEGCC__))
# if defined(_MSC_VER) || defined(__MINGW32__)

View File

@ -5,11 +5,20 @@ SUBDIRS = . dlfcn
lib_LTLIBRARIES = libevil.la
include_HEADERS = Evil.h evil_stdlib.h evil_unistd.h evil_util.h
nobase_include_HEADERS = sys/mman.h
include_HEADERS = \
Evil.h \
evil_fcntl.h \
evil_langinfo.h \
evil_stdlib.h \
evil_unistd.h \
evil_util.h
nobase_include_HEADERS = pwd.h sys/mman.h
libevil_la_SOURCES = \
evil.c \
evil_fcntl.c \
evil_langinfo.c \
evil_mman.c \
evil_pwd.c \
evil_stdlib.c \

View File

@ -8,7 +8,7 @@
# undef _POSIX_
#endif /* _MSC_VER */
#if defined(__CEGCC__) || defined(__MINGW32CE__)
#if defined(__CEGCC__)
# include <sys/syslimits.h>
#else
# include <limits.h>

View File

@ -1,141 +1,38 @@
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#undef WIN32_LEAN_AND_MEAN
/* #define WIN32_LEAN_AND_MEAN */
/* #include <winsock2.h> */
/* #undef WIN32_LEAN_AND_MEAN */
#include <stdlib.h>
#include <stdio.h>
/* #include <stdlib.h> */
/* #include <stdio.h> */
#ifndef __CEGCC__
# include <errno.h>
# include <sys/locking.h>
# include <io.h>
# include <shlobj.h>
# include <objidl.h>
#else
# include <sys/syslimits.h>
#endif /* __CEGCC__ */
/* #ifndef __CEGCC__ */
/* # include <errno.h> */
/* # include <sys/locking.h> */
/* # include <io.h> */
/* # include <shlobj.h> */
/* # include <objidl.h> */
/* #else */
/* # include <sys/syslimits.h> */
/* #endif /\* __CEGCC__ *\/ */
#ifdef UNICODE
# include <wchar.h>
#endif /* UNICODE */
/* #ifdef UNICODE */
/* # include <wchar.h> */
/* #endif /\* UNICODE *\/ */
#include <sys/types.h>
#include <sys/timeb.h>
#include <fcntl.h>
#include <sys/stat.h>
/* #include <sys/types.h> */
/* #include <sys/timeb.h> */
/* #include <fcntl.h> */
/* #include <sys/stat.h> */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
/* #ifdef HAVE_CONFIG_H */
/* # include "config.h" */
/* #endif /\* HAVE_CONFIG_H *\/ */
#if HAVE___ATTRIBUTE__
# define __UNUSED__ __attribute__((unused))
#else
# define __UNUSED__
#endif /* HAVE___ATTRIBUTE__ */
/* #if HAVE___ATTRIBUTE__ */
/* # define __UNUSED__ __attribute__((unused)) */
/* #else */
/* # define __UNUSED__ */
/* #endif /\* HAVE___ATTRIBUTE__ *\/ */
#include "Evil.h"
/* #include "Evil.h" */
#ifndef __CEGCC__
int fcntl(int fd, int cmd, ...)
{
va_list va;
HANDLE h;
int res = -1;
va_start (va, cmd);
h = (HANDLE)_get_osfhandle(fd);
if (h == INVALID_HANDLE_VALUE)
return -1;
if (cmd == F_SETFD)
{
long flag;
flag = va_arg(va, long);
if (flag == FD_CLOEXEC)
{
if (SetHandleInformation(h, HANDLE_FLAG_INHERIT, 0))
res = 0;
}
}
else if ((cmd == F_SETLK) || (cmd == F_SETLKW))
{
struct flock fl;
off_t length = 0;
long pos;
fl = va_arg(va, struct flock);
if (fl.l_len == 0)
{
length = _lseek(fd, 0L, SEEK_END);
if (length != -1L)
res = 0;
}
fl.l_len = length - fl.l_start - 1;
pos = _lseek(fd, fl.l_start, fl.l_whence);
if (pos != -1L)
res = 0;
if ((fl.l_type == F_RDLCK) || (fl.l_type == F_WRLCK))
{
if (cmd == F_SETLK)
res = _locking(fd, _LK_NBLCK, fl.l_len); /* if cannot be locked, we return immediatly */
else /* F_SETLKW */
res = _locking(fd, _LK_LOCK, fl.l_len); /* otherwise, we try several times */
}
if (fl.l_type == F_UNLCK)
res = _locking(fd, _LK_UNLCK, fl.l_len);
}
va_end(va);
return res;
}
#endif /* ! __CEGCC__ */
static char *
replace(char *prev, char *value)
{
if (value == NULL)
return prev;
if (prev)
free (prev);
return strdup (value);
}
char *
nl_langinfo(nl_item index)
{
static char *result = NULL;
static char *nothing = "";
switch (index)
{
case CODESET:
{
char *p;
result = replace(result, setlocale(LC_CTYPE, NULL));
if ((p = strrchr(result, '.' )) == NULL)
return nothing;
if ((++p - result) > 2)
strcpy(result, "cp");
else
*result = '\0';
strcat(result, p);
return result;
}
}
return nothing;
}

View File

@ -0,0 +1,82 @@
#include <stdio.h>
#ifndef __CEGCC__
# include <sys/locking.h>
#endif /* __CEGCC__ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include "Evil.h"
/*
* port of fcntl function
*
*/
#ifndef __CEGCC__
int fcntl(int fd, int cmd, ...)
{
va_list va;
HANDLE h;
int res = -1;
va_start (va, cmd);
h = (HANDLE)_get_osfhandle(fd);
if (h == INVALID_HANDLE_VALUE)
return -1;
if (cmd == F_SETFD)
{
long flag;
flag = va_arg(va, long);
if (flag == FD_CLOEXEC)
{
if (SetHandleInformation(h, HANDLE_FLAG_INHERIT, 0))
res = 0;
}
}
else if ((cmd == F_SETLK) || (cmd == F_SETLKW))
{
struct flock fl;
off_t length = 0;
long pos;
fl = va_arg(va, struct flock);
if (fl.l_len == 0)
{
length = _lseek(fd, 0L, SEEK_END);
if (length != -1L)
res = 0;
}
fl.l_len = length - fl.l_start - 1;
pos = _lseek(fd, fl.l_start, fl.l_whence);
if (pos != -1L)
res = 0;
if ((fl.l_type == F_RDLCK) || (fl.l_type == F_WRLCK))
{
if (cmd == F_SETLK)
res = _locking(fd, _LK_NBLCK, fl.l_len); /* if cannot be locked, we return immediatly */
else /* F_SETLKW */
res = _locking(fd, _LK_LOCK, fl.l_len); /* otherwise, we try several times */
}
if (fl.l_type == F_UNLCK)
res = _locking(fd, _LK_UNLCK, fl.l_len);
}
va_end(va);
return res;
}
#endif /* ! __CEGCC__ */

View File

@ -0,0 +1,106 @@
#ifndef __EVIL_FCNTL_H__
#define __EVIL_FCNTL_H__
#ifndef __CEGCC__
# include <sys/types.h>
/**
* @def FD_CLOEXEC
* Specifies that the file descriptor should be closed when an exec()
* function is invoked.
*/
# define FD_CLOEXEC 1
/**
* @def F_SETFD
* Specifies that fcntl() should set the file descriptor flags
* associated with the filedes argument.
*/
/**
* @def F_SETLK
* Specifies that fcntl() should set or clear a file segment lock
* according to the lock description pointed to by the third argument.
*/
/**
* @def F_SETLKW
* Equivalent to F_SETLK except that if a shared or exclusive lock
* is blocked by other locks, the thread shall wait until the request
* can be satisfied.
*/
# define F_SETFD 2
# define F_SETLK 6
# define F_SETLKW 7
/**
* @def F_RDLCK
* Read (or shared) lock
*/
/**
* @def F_WRLCK
* Write (or exclusive) lock
*/
/**
* @def F_UNLCK
* Remove lock
*/
# ifndef F_RDLCK
# define F_RDLCK 0
# define F_WRLCK 1
# define F_UNLCK 2
# endif /* ! F_RDLCK */
/**
* @struct flock
* @brief A structure that control the lock of a file descriptor.
*/
struct flock
{
short int l_type; /**< lock type: read, write, ... */
short int l_whence; /**< type of l_start */
off_t l_start; /**< starting offset */
off_t l_len; /**< 0 means end of the file */
pid_t l_pid; /**< lock owner */
};
/**
* @brief Provide control over file descriptors.
*
* @param fd The file descriptor.
* @param cmd The type of control.
* @return 0 on success, -1 otherwise.
*
* Performs one of various miscellaneous operations on @p fd.
* The operation in question is determined by @p cmd:
*
* - F_SETFD: Set the close-on-exec flag to the value specified
* by the argument after command (only the least significant
* bit is used).
* - F_SETLK and F_SETLKW: used to manage discretionary file locks.
* The third argument must be a pointer to a struct flock (that
* may be overwritten by this call).
*
* This function returns 0 on success, -1 otherwise.
*
* Conformity: None.
*
* Supported OS: Windows Vista, Windows XP or Windows 2000
* Professional.
*
* @ingroup Evil
*/
EAPI int fcntl(int fd, int cmd, ...);
#endif /* ! __CEGCC__ */
#endif /* __EVIL_FCNTL_H__ */

View File

@ -0,0 +1,50 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include "Evil.h"
#ifndef __CEGCC__
static char *
replace(char *prev, char *value)
{
if (value == NULL)
return prev;
if (prev)
free (prev);
return strdup (value);
}
char *
nl_langinfo(nl_item index)
{
static char *result = NULL;
static char *nothing = "";
switch (index)
{
case CODESET:
{
char *p;
result = replace(result, setlocale(LC_CTYPE, NULL));
if ((p = strrchr(result, '.' )) == NULL)
return nothing;
if ((++p - result) > 2)
strcpy(result, "cp");
else
*result = '\0';
strcat(result, p);
return result;
}
}
return nothing;
}
#endif /* ! __CEGCC__ */

View File

@ -0,0 +1,39 @@
#ifndef __EVIL_LANGINFO_H__
#define __EVIL_LANGINFO_H__
#ifndef __CEGCC__
#include <locale.h>
typedef int nl_item;
#define __NL_ITEM( CATEGORY, INDEX ) ((CATEGORY << 16) | INDEX)
#define __NL_ITEM_CATEGORY( ITEM ) (ITEM >> 16)
#define __NL_ITEM_INDEX( ITEM ) (ITEM & 0xffff)
enum {
/*
* LC_CTYPE category...
* Character set classification items.
*/
_NL_CTYPE_CODESET = __NL_ITEM( LC_CTYPE, 0 ),
/*
* Dummy entry, to terminate the list.
*/
_NL_ITEM_CLASSIFICATION_END
};
/*
* Define the public aliases for the enumerated classification indices...
*/
# define CODESET _NL_CTYPE_CODESET
EAPI char *nl_langinfo(nl_item index);
#endif /* ! __CEGCC__ */
#endif /*__EVIL_LANGINFO_H__ */

View File

@ -10,8 +10,6 @@
# include <io.h>
#endif /* ! __CEGCC__ */
#include "Evil.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */

View File

@ -7,11 +7,11 @@
#include "pwd.h"
static struct passwd pw;
#ifndef __CEGCC__
static struct passwd pw;
struct passwd *
getpwuid (uid_t uid)
{
@ -39,4 +39,5 @@ getpwuid (uid_t uid)
return &pw;
}
#endif /* ! __CEGCC__ */

View File

@ -26,7 +26,7 @@ _evil_stdlib_error_display(const char *fct,
char *error;
error = evil_format_message(res);
fprintf(stderr, "[Evil] [%s] ERROR: %ld\n", fct, error);
fprintf(stderr, "[Evil] [%s] ERROR: %s\n", fct, error);
free(error);
}
@ -191,11 +191,11 @@ setenv(const char *name,
if (!overwrite && (disposition == REG_OPENED_EXISTING_KEY))
return 0;
if ((res = RegSetValueEx (key,
(LPCWSTR)name,
0, REG_SZ,
value,
strlen(value) + 1)) != ERROR_SUCCESS)
if ((res = RegSetValueEx(key,
(LPCWSTR)name,
0, REG_SZ,
(const BYTE *)value,
strlen(value) + 1)) != ERROR_SUCCESS)
{
_evil_stdlib_error_display("setenv", res);
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
@ -219,7 +219,7 @@ setenv(const char *name,
int
unsetenv(const char *name)
{
setenv(name, NULL, 1);
return setenv(name, NULL, 1);
}
#endif /* ! __CEGCC__ */

View File

@ -2,10 +2,11 @@
#include <winsock2.h>
#undef WIN32_LEAN_AND_MEAN
#ifdef _MSC_VER
# include <shobjidl.h>
#if defined(_MSC_VER) || \
(defined(__MINGW32__) && ! defined(__MINGW32CE__))
# include <shlobj.h>
# include <objidl.h>
# include <errno.h>
# include <shlguid.h>
#endif
#ifdef HAVE_CONFIG_H
@ -31,6 +32,20 @@ getpid(void)
*
*/
#if defined(__CEGCC__) || defined(__MINGW32CE__)
DWORD SHCreateShortcutEx(LPTSTR lpszDir,
LPTSTR lpszTarget,
LPTSTR szShortcut,
LPDWORD lpcbShortcut);
BOOL SHGetShortcutTarget(LPTSTR szShortcut,
LPTSTR szTarget,
int cbMax );
#endif /* __CEGCC__ || __MINGW32CE__ */
/* REMARK: Windows has no symbolic link. */
/* Nevertheless, it can create and read .lnk files */
int

View File

@ -2,13 +2,6 @@
#define __EVIL_UNISTD_H__
#ifdef _MSC_VER
typedef int pid_t;
#endif /* _MSC_VER */
/*
* Process identifer related functions
*

View File

@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -84,7 +85,7 @@ evil_format_message(long err)
return NULL;
snprintf(disp, strlen(str) + strlen("(00000) ") + 1,
"(%5d) %s", err, str);
"(%5ld) %s", err, str);
free(str);

View File

@ -7,28 +7,14 @@
#include <Evil.h>
#ifdef EAPI
# undef EAPI
#endif /* EAPI */
#ifdef _WIN32
# ifdef EFL_EVIL_PWD_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_EVIL_PWD_BUILD */
#endif /* _WIN32 */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __CEGCC__
struct passwd {
char *pw_name; /* user name */
char *pw_passwd; /* encrypted password */
@ -46,6 +32,9 @@ struct passwd {
EAPI struct passwd * getpwuid (uid_t uid);
#endif /* ! __CEGCC__ */
#ifdef __cplusplus
}
#endif

View File

@ -1,22 +1,8 @@
#ifndef __EVIL_SYS_MMAN_H__
#define __EVIL_SYS_MMAN_H__
#include <Evil.h>
#ifdef EAPI
# undef EAPI
#endif /* EAPI */
#ifdef _WIN32
# ifdef EFL_EVIL_MMAN_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_EVIL_MMAN_BUILD */
#endif /* _WIN32 */
#ifdef __cplusplus
extern "C" {

View File

@ -59,12 +59,14 @@ fnmatch_match_class(const char *class,
char c)
{
const size_t complement = fnmatch_complement_class(class + 1);
enum fnmatch_status status;
size_t pos;
if (complement == FNM_SYNTAXERR)
return FNM_SYNTAXERR;
enum fnmatch_status status = fnmatch_not_found;
size_t pos = 1 + complement;
status = fnmatch_not_found;
pos = 1 + complement;
do
pos += fnmatch_match_class_token(&status, class + pos, c);
@ -136,11 +138,12 @@ size_t
fnmatch_check_finals(const char *pattern,
const struct list_of_states *states)
{
for (size_t i = 0; i < states->size; ++i)
size_t i, j;
for (i = 0; i < states->size; ++i)
{
_Bool match = 1;
for (size_t j = states->states[i]; pattern[j]; ++j)
for (j = states->states[i]; pattern[j]; ++j)
if (pattern[j] != '*')
{
match = 0;
@ -158,24 +161,29 @@ fnmatch(const char *pattern,
const char *string,
int flags)
{
struct list_of_states *states;
struct list_of_states *new_states;
_Bool leading = 1;
char* c;
size_t r;
assert(pattern);
assert(string);
struct list_of_states *states =
fnmatch_list_of_states_alloc(2, strlen(pattern));
struct list_of_states *new_states = states + 1;
states = fnmatch_list_of_states_alloc(2, strlen(pattern));
new_states = states + 1;
if (! states)
return FNM_NOMEM;
fnmatch_init_states(states);
_Bool leading = 1;
for (const char* c = string; *c && states->size; ++c)
for (c = string; *c && states->size; ++c)
{
size_t i;
fnmatch_list_of_states_clear(new_states);
for (size_t i = 0; i < states->size; ++i)
for (i = 0; i < states->size; ++i)
{
const size_t pos = states->states[i];
@ -212,7 +220,7 @@ fnmatch(const char *pattern,
leading = *c == '/' && (flags & FNM_PATHNAME);
}
const size_t r = fnmatch_check_finals(pattern, states);
r = fnmatch_check_finals(pattern, states);
fnmatch_list_of_states_free(states < new_states ? states : new_states, 2);
return r;
}

View File

@ -1,5 +1,5 @@
#ifndef _FNMATCH_H
#define _FNMATCH_H
#define _FNMATCH_H
#ifdef EVIL_COMMON_API
# undef EVIL_COMMON_API
@ -37,7 +37,9 @@ extern "C" {
#endif
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
#define FNM_NOMATCH 1
#define FNM_NOMATCH 1
#define FNM_SYNTAXERR 2
#define FNM_NOMEM 3
/* Match STRING against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */

View File

@ -1,7 +1,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "fnmatch_private.h"
@ -16,14 +15,14 @@ fnmatch_list_of_states_alloc(size_t n, size_t pattern_len)
const size_t states_has_size = states_size + has_size;
const size_t struct_size = sizeof (*l) + states_has_size;
uint8_t *states;
uint8_t *has;
unsigned char *states;
unsigned char *has;
size_t i;
if (! (l = malloc(n * struct_size)))
return 0;
states = (uint8_t *) (l + n);
states = (unsigned char *) (l + n);
has = states + states_size;
for (i = 0; i < n; ++i)

View File

@ -4,8 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 9.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libevil", "libevil.vcproj", "{689B4F2B-666D-439F-9BF3-1203D813DE3F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdlfcn", "libdlfcn.vcproj", "{2DAB1902-38E3-4F58-8403-C1BC7C077E1F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmman", "libmman.vcproj", "{799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}"
ProjectSection(ProjectDependencies) = postProject
{689B4F2B-666D-439F-9BF3-1203D813DE3F} = {689B4F2B-666D-439F-9BF3-1203D813DE3F}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -21,10 +22,6 @@ Global
{2DAB1902-38E3-4F58-8403-C1BC7C077E1F}.Debug|Win32.Build.0 = Debug|Win32
{2DAB1902-38E3-4F58-8403-C1BC7C077E1F}.Release|Win32.ActiveCfg = Release|Win32
{2DAB1902-38E3-4F58-8403-C1BC7C077E1F}.Release|Win32.Build.0 = Release|Win32
{799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}.Debug|Win32.ActiveCfg = Debug|Win32
{799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}.Debug|Win32.Build.0 = Debug|Win32
{799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}.Release|Win32.ActiveCfg = Release|Win32
{799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE