From 1c6ea6ff651e4179fd057414274a079a57924d6a Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 20 Jan 2012 12:44:05 +0000 Subject: [PATCH] * Makefile.am: Fix EXTRA_DIST variable * src/bin/Makefile.am: * src/bin/evil_suite.c: * src/lib/evil_libgen.c: * src/lib/evil_util.c: * src/lib/evil_util.h: Add evil_path_is_absolute() API and use it. * src/bin/evil_test_dlfcn.c: * src/bin/evil_test_realpath.c: clean up. SVN revision: 67389 --- legacy/evil/ChangeLog | 16 ++++++++++++++++ legacy/evil/Makefile.am | 5 ++++- legacy/evil/src/bin/Makefile.am | 4 +++- legacy/evil/src/bin/evil_suite.c | 2 ++ legacy/evil/src/bin/evil_test_dlfcn.c | 4 ++-- legacy/evil/src/bin/evil_test_realpath.c | 1 - legacy/evil/src/lib/evil_libgen.c | 12 ++---------- legacy/evil/src/lib/evil_util.c | 20 ++++++++++++++++++++ legacy/evil/src/lib/evil_util.h | 22 ++++++++++++++++++++++ 9 files changed, 71 insertions(+), 15 deletions(-) diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog index 80857745db..85d9569145 100644 --- a/legacy/evil/ChangeLog +++ b/legacy/evil/ChangeLog @@ -1,3 +1,19 @@ +2012-01-20 Vincent Torri + + * Makefile.am: + Fix EXTRA_DIST variable + + * src/bin/Makefile.am: + * src/bin/evil_suite.c: + * src/lib/evil_libgen.c: + * src/lib/evil_util.c: + * src/lib/evil_util.h: + Add evil_path_is_absolute() API and use it. + + * src/bin/evil_test_dlfcn.c: + * src/bin/evil_test_realpath.c: + clean up. + 2011-12-02 Vincent Torri Release Version 1.0.0. diff --git a/legacy/evil/Makefile.am b/legacy/evil/Makefile.am index c4105134b1..6e86f8a3c9 100644 --- a/legacy/evil/Makefile.am +++ b/legacy/evil/Makefile.am @@ -29,7 +29,10 @@ EXTRA_DIST = \ COPYING \ COPYING-PLAIN \ autogen.sh \ -evil.pc.in +evil.pc.in \ +m4/common/efl_attribute.m4 \ +m4/common/efl_doxygen.m4 \ +m4/evil/evil_windows.m4 pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = evil.pc diff --git a/legacy/evil/src/bin/Makefile.am b/legacy/evil/src/bin/Makefile.am index 9b974dc41b..f466365c94 100644 --- a/legacy/evil/src/bin/Makefile.am +++ b/legacy/evil/src/bin/Makefile.am @@ -22,6 +22,7 @@ evil_test_memcpy.c \ evil_test_mkstemp.c \ evil_test_pipe.c \ evil_test_realpath.c \ +evil_test_util.c \ evil_suite.h \ evil_test_dlfcn.h \ evil_test_environment.h \ @@ -30,7 +31,8 @@ evil_test_link.h \ evil_test_memcpy.h \ evil_test_mkstemp.h \ evil_test_pipe.h \ -evil_test_realpath.h +evil_test_realpath.h \ +evil_test_util.h if EVIL_HAVE_WINCE diff --git a/legacy/evil/src/bin/evil_suite.c b/legacy/evil/src/bin/evil_suite.c index 1912715dc6..429959c79a 100644 --- a/legacy/evil/src/bin/evil_suite.c +++ b/legacy/evil/src/bin/evil_suite.c @@ -19,6 +19,7 @@ #include "evil_test_mkstemp.h" #include "evil_test_pipe.h" #include "evil_test_realpath.h" +#include "evil_test_util.h" typedef int(*function)(suite *s); @@ -185,6 +186,7 @@ main(void) { "mkstemp ", test_mkstemp }, { "pipe ", test_pipe }, { "realpath ", test_realpath }, + { "util ", test_util }, /* { "memcpy ", test_memcpy }, */ { NULL, NULL }, }; diff --git a/legacy/evil/src/bin/evil_test_dlfcn.c b/legacy/evil/src/bin/evil_test_dlfcn.c index 47d999dc90..b84a9eb238 100644 --- a/legacy/evil/src/bin/evil_test_dlfcn.c +++ b/legacy/evil/src/bin/evil_test_dlfcn.c @@ -20,7 +20,7 @@ test_dlfcn_test_dlopen(void) { void *handle; - handle = dlopen("libevil-0.dll", 0); + handle = dlopen("libevil-1.dll", 0); if (!handle) return 0; @@ -37,7 +37,7 @@ test_dlfcn_test_dlsym(void) _evil_init sym_init; _evil_shutdwon sym_shutdown; - handle = dlopen("libevil-0.dll", 0); + handle = dlopen("libevil-1.dll", 0); if (!handle) return 0; diff --git a/legacy/evil/src/bin/evil_test_realpath.c b/legacy/evil/src/bin/evil_test_realpath.c index 0821b904cb..01c390f10e 100644 --- a/legacy/evil/src/bin/evil_test_realpath.c +++ b/legacy/evil/src/bin/evil_test_realpath.c @@ -39,6 +39,5 @@ test_realpath_run(suite *s) int test_realpath(suite *s) { - return test_realpath_run(s); } diff --git a/legacy/evil/src/lib/evil_libgen.c b/legacy/evil/src/lib/evil_libgen.c index 3913050237..7e98f74386 100644 --- a/legacy/evil/src/lib/evil_libgen.c +++ b/legacy/evil/src/lib/evil_libgen.c @@ -17,11 +17,7 @@ evil_basename(char *path) size_t length; /* path must begin by "?:\" or "?:/" */ - if ((!path) || - (strlen(path) <= 3) || - ((path[0] < 'a' || path[0] > 'z') && (path[0] < 'A' || path[0] > 'Z')) || - (path[1] != ':') || - ((path[2] != '/') && (path[2] != '\\'))) + if ((!path) || !evil_path_is_absolute(path)) { memcpy(_evil_basename_buf, "C:\\", 4); return _evil_basename_buf; @@ -67,11 +63,7 @@ evil_dirname(char *path) size_t length; /* path must begin by "?:\" or "?:/" */ - if ((!path) || - (strlen(path) <= 3) || - ((path[0] < 'a' || path[0] > 'z') && (path[0] < 'A' || path[0] > 'Z')) || - (path[1] != ':') || - ((path[2] != '/') && (path[2] != '\\'))) + if ((!path) || !evil_path_is_absolute(path)) { memcpy(_evil_dirname_buf, "C:\\", 4); return _evil_dirname_buf; diff --git a/legacy/evil/src/lib/evil_util.c b/legacy/evil/src/lib/evil_util.c index cbf204a5e3..891efd27fa 100644 --- a/legacy/evil/src/lib/evil_util.c +++ b/legacy/evil/src/lib/evil_util.c @@ -216,3 +216,23 @@ evil_homedir_get(void) return homedir; #endif /* ! _WIN32_WCE */ } + +int +evil_path_is_absolute(const char *path) +{ + size_t length; + + if (!path) + return 0; + + length = strlen(path); + if (length < 3) return 0; + + if ((((*path >= 'a') && (*path <= 'z')) || + ((*path >= 'A') && (*path <= 'Z'))) && + (path[1] == ':') && + ((path[2] == '/') || (path[2] == '\\'))) + return 1; + + return 0; +} diff --git a/legacy/evil/src/lib/evil_util.h b/legacy/evil/src/lib/evil_util.h index 0170dd0f2a..c3e9d5eb54 100644 --- a/legacy/evil/src/lib/evil_util.h +++ b/legacy/evil/src/lib/evil_util.h @@ -108,5 +108,27 @@ EAPI const char *evil_tmpdir_get(void); */ EAPI const char *evil_homedir_get(void); +/** + * @brief check if the given path is absolute. + * + * @param path The path to check. + * @return 1 if the given path is absolute, 0 otherwise. + * + * Check if the path @p path is absolute or not. An absolute path must + * begin with a letter (upper or lower case), followed by by the char + * ':', followed by the char '/' or '\'. If @p path is absolute this + * function returns 1, otherwise it returns 0. If @p path is @c NULL, + * it returns 0. + * + * Conformity: Non applicable. + * + * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000, + * Windows XP, Windows CE. + * + * @since 1.1 + * + * @ingroup Evil + */ +EAPI int evil_path_is_absolute(const char *path); #endif /* __EVIL_UTIL_H__ */