* src/lib/evil_libgen.c:
authorVincent Torri <vincent.torri@gmail.com>
Mon, 7 Dec 2009 17:23:41 +0000 (17:23 +0000)
committerVincent Torri <vincent.torri@gmail.com>
Mon, 7 Dec 2009 17:23:41 +0000 (17:23 +0000)
* 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

legacy/evil/ChangeLog
legacy/evil/src/lib/Evil.h
legacy/evil/src/lib/Makefile.am
legacy/evil/src/lib/dlfcn/dlfcn.h
legacy/evil/src/lib/evil_libgen.c [new file with mode: 0644]
legacy/evil/src/lib/evil_libgen.h [new file with mode: 0644]
legacy/evil/src/lib/evil_util.c
legacy/evil/win32/vs8/libevil.vcproj
legacy/evil/win32/vs9/libevil.vcproj

index 6d902aa..db795fd 100644 (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:
index 2940382..5e08baa 100644 (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
index 75ea3ff..e0b3892 100644 (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 \
index 3badaae..b7b4c9e 100644 (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
diff --git a/legacy/evil/src/lib/evil_libgen.c b/legacy/evil/src/lib/evil_libgen.c
new file mode 100644 (file)
index 0000000..dd43d46
--- /dev/null
@@ -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;
+}
diff --git a/legacy/evil/src/lib/evil_libgen.h b/legacy/evil/src/lib/evil_libgen.h
new file mode 100644 (file)
index 0000000..c252b2f
--- /dev/null
@@ -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__ */
index fa6f83b..e39f6c1 100644 (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)
index 37924ad..0b6ec4b 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath="..\..\src\lib\evil_libgen.c"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\src\lib\evil_main.c"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath="..\..\src\lib\evil_libgen.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\src\lib\evil_main.h"
                                >
                        </File>
index 0ff2f98..403e93b 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\src\lib\evil_libgen.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\..\src\lib\evil_main.c"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\..\src\lib\evil_libgen.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\..\src\lib\evil_main.h"\r
                                >\r
                        </File>\r