* src/lib/evil_libgen.c:

* src/lib/evil_libgen.h:
* src/lib/Makefile.am:
* win32/vs8/libevil.vcproj:
* win32/vs9/libevil.vcproj:
add basename() function.

* src/lib/Evil.h:
add basename() function and comment useless wrappers (for now).

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

* src/lib/evil_util.c:
formatting.

SVN revision: 44251
This commit is contained in:
Vincent Torri 2009-12-07 17:23:41 +00:00
parent cee693572e
commit 9aa679df36
9 changed files with 150 additions and 51 deletions

View File

@ -1,3 +1,21 @@
2009-12-07 Vincent Torri <doursse at users dot sf dot net>
* src/lib/evil_libgen.c:
* src/lib/evil_libgen.h:
* src/lib/Makefile.am:
* win32/vs8/libevil.vcproj:
* win32/vs9/libevil.vcproj:
add basename() function.
* src/lib/Evil.h:
add basename() function and comment useless wrappers (for now).
* src/lib/dlfcn/dlfcn.h:
remove useless include.
* src/lib/evil_util.c:
formatting.
2009-12-06 Vincent Torri <doursse at users dot sf dot net>
* src/lib/evil_string.c:

View File

@ -80,12 +80,31 @@ extern "C" {
#ifdef _MSC_VER
#include <io.h>
# include <io.h>
#define F_OK 0 /* Check for file existence */
#define X_OK 1 /* MS access() doesn't check for execute permission. */
#define W_OK 2 /* Check for write permission */
#define R_OK 4 /* Check for read permission */
# define F_OK 0 /* Check for file existence */
# define X_OK 1 /* MS access() doesn't check for execute permission. */
# define W_OK 2 /* Check for write permission */
# define R_OK 4 /* Check for read permission */
# ifdef S_ISDIR
# undef S_ISDIR
# endif
# ifdef S_ISREG
# undef S_ISREG
# endif
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
# define S_IRUSR _S_IRUSR
# define S_IWUSR _S_IWUSR
# define S_IXUSR _S_IXUSR
# define S_IRGRP S_IRUSR
# define S_IROTH S_IRUSR
# define S_IWGRP S_IWUSR
# define S_IWOTH S_IWUSR
# define S_IXGRP S_IXUSR
# define S_IXOTH S_IXUSR
#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
#define _S_IXUSR _S_IEXEC
@ -102,6 +121,11 @@ typedef signed int int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
# define strdup(s) _strdup(s)
# define unlink(filename) _unlink(filename)
# define fileno(f) _fileno(f)
# define fdopen(fd,m) _fdopen((fd),(m))
#endif /* _MSC_VER */
@ -115,6 +139,7 @@ typedef unsigned long gid_t;
#include "evil_fcntl.h"
#include "evil_langinfo.h"
#include "evil_libgen.h"
#include "evil_main.h"
#include "evil_stdlib.h"
#include "evil_stdio.h"
@ -126,41 +151,18 @@ typedef unsigned long gid_t;
#if defined(__MSDOS__) || defined(__EMX__) || \
(defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__) && !defined(__CEGCC__))
# if defined(_MSC_VER) || defined(__MINGW32__)
# ifdef S_ISDIR
# undef S_ISDIR
# endif
# ifdef S_ISREG
# undef S_ISREG
# endif
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
# define S_IRUSR _S_IRUSR
# define S_IWUSR _S_IWUSR
# define S_IXUSR _S_IXUSR
# define S_IRGRP S_IRUSR
# define S_IROTH S_IRUSR
# define S_IWGRP S_IWUSR
# define S_IWOTH S_IWUSR
# define S_IXGRP S_IXUSR
# define S_IXOTH S_IXUSR
//
//
# define open(path, flag, ...) _open((path), _O_BINARY | (flag), __VA_ARGS__)
# 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 mkdir(p,m) _mkdir(p)
# define access(p,m) _access((p),(m))
# define lstat(f,s) _stat((f),(s))
# define strdup(s) _strdup(s)
# ifndef fileno
# define fileno(f) _fileno(f)
# endif
# define fdopen(fd,m) _fdopen((fd),(m))
# define tzset _tzset
# define hypot(x,y) _hypot((x),(y))
//# 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 mkdir(p,m) _mkdir(p)
//# define access(p,m) _access((p),(m))
//# define lstat(f,s) _stat((f),(s))
//# define tzset _tzset
//# define hypot(x,y) _hypot((x),(y))
# endif
#endif

View File

@ -9,6 +9,7 @@ include_HEADERS = \
Evil.h \
evil_fcntl.h \
evil_langinfo.h \
evil_libgen.h \
evil_main.h \
evil_stdlib.h \
evil_stdio.h \
@ -36,6 +37,7 @@ evil_fcntl.c \
evil_fnmatch.c \
evil_fnmatch_list_of_states.c \
evil_langinfo.c \
evil_libgen.c \
evil_main.c \
evil_mman.c \
evil_pwd.c \

View File

@ -2,12 +2,6 @@
#define __EVIL_DLFCN_H__
#ifdef _MSC_VER
# define _POSIX_
# include <limits.h>
# undef _POSIX_
#endif /* _MSC_VER */
#if defined(__CEGCC__)
# include <sys/syslimits.h>
#else

View File

@ -0,0 +1,42 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <string.h>
#include "Evil.h"
char _evil_basename_buf[PATH_MAX];
char *
evil_basename(char *path)
{
char *p1;
char *p2;
size_t length;
if (!path || !*path)
{
memcpy(_evil_basename_buf, ".", 2);
return _evil_basename_buf;
}
length = strlen(path);
p1 = strdup(path);
if (!p1) return NULL;
p2 = p1;
while (p2)
{
if (*p2 == '/') *p2 = '\\';
p2++;
}
if (p1[length - 1] =='\\') p1[--length] = '\0';
p2 = strrchr(p1, '\\');
if (!p2) memcpy(_evil_basename_buf, p1, length + 1);
else memcpy(_evil_basename_buf, p2 + 1, (p1 + length + 1) - p2);
free(p1);
return _evil_basename_buf;
}

View File

@ -0,0 +1,25 @@
#ifndef __EVIL_LIBGEN_H__
#define __EVIL_LIBGEN_H__
/**
* @file evil_libgen.h
* @brief The file that provides functions ported from Unix in libgen.h.
* @defgroup Evil_Libgen_Group Libgen.h functions.
*
* This header provides functions ported from Unix in libgen.h.
*
* @{
*/
EAPI char *evil_basename(char *path);
#define basename(p) evil_basename(p)
/**
* @}
*/
#endif /* __EVIL_LIBGEN_H__ */

View File

@ -1,3 +1,9 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include "Evil.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -7,12 +13,6 @@
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include "Evil.h"
wchar_t *
evil_char_to_wchar(const char *text)

View File

@ -216,6 +216,10 @@
RelativePath="..\..\src\lib\evil_link_xp.cpp"
>
</File>
<File
RelativePath="..\..\src\lib\evil_libgen.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_main.c"
>
@ -286,6 +290,10 @@
RelativePath="..\..\src\lib\evil_langinfo.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_libgen.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_main.h"
>

View File

@ -215,6 +215,10 @@
RelativePath="..\..\src\lib\evil_link_xp.cpp"
>
</File>
<File
RelativePath="..\..\src\lib\evil_libgen.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_main.c"
>
@ -285,6 +289,10 @@
RelativePath="..\..\src\lib\evil_langinfo.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_libgen.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_main.h"
>