aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-12-31 16:08:31 +0000
committerAndy Williams <andy@andywilliams.me>2017-12-31 16:08:31 +0000
commitd234458dfcd9202c33f75049da6ebdad7888f4c5 (patch)
tree12f6e7584f1faf8e0e1dad1b940b69a31b1be8ba
parentelm_code: Fix usage of basename (diff)
downloadefl-d234458dfcd9202c33f75049da6ebdad7888f4c5.tar.gz
Fix and simpligy windows behaviour.
Author: Vincent Torri
-rw-r--r--src/Makefile_Evil.am1
-rw-r--r--src/bin/edje/edje_cc_out.c1
-rw-r--r--src/lib/ecore_con/ecore_con_local.c1
-rw-r--r--src/lib/ecore_con/ecore_con_url.c1
-rw-r--r--src/lib/ecore_file/ecore_file.c7
-rw-r--r--src/lib/eio/eio_model.c1
-rw-r--r--src/lib/evil/evil_libgen.c100
-rw-r--r--src/lib/evil/evil_libgen.h89
-rw-r--r--src/tests/elementary/elm_code_file_test_load.c2
-rw-r--r--src/tests/evil/evil_suite.c1
-rw-r--r--src/tests/evil/evil_suite.h1
11 files changed, 11 insertions, 194 deletions
diff --git a/src/Makefile_Evil.am b/src/Makefile_Evil.am
index f93b226f9c..39baaef671 100644
--- a/src/Makefile_Evil.am
+++ b/src/Makefile_Evil.am
@@ -126,6 +126,7 @@ tests_evil_evil_suite_SOURCES = \
tests/evil/evil_suite.c \
tests/evil/evil_suite.h \
tests/evil/evil_test_dlfcn.c \
+tests/evil/evil_test_libgen.c \
tests/evil/evil_test_main.c \
tests/evil/evil_test_stdio.c \
tests/evil/evil_test_stdlib.c
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index da36943c4c..63d5a61dd8 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -15,6 +15,7 @@
#include <limits.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <libgen.h>
#include <Ecore_Evas.h>
diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c
index 2e83774ec1..874fd7b2c7 100644
--- a/src/lib/ecore_con/ecore_con_local.c
+++ b/src/lib/ecore_con/ecore_con_local.c
@@ -11,6 +11,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
+#include <libgen.h>
#ifdef HAVE_SYSTEMD
# include <systemd/sd-daemon.h>
diff --git a/src/lib/ecore_con/ecore_con_url.c b/src/lib/ecore_con/ecore_con_url.c
index 39412d7f83..a05866f750 100644
--- a/src/lib/ecore_con/ecore_con_url.c
+++ b/src/lib/ecore_con/ecore_con_url.c
@@ -17,6 +17,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
+#include <libgen.h>
#include "Ecore.h"
#include "ecore_private.h"
diff --git a/src/lib/ecore_file/ecore_file.c b/src/lib/ecore_file/ecore_file.c
index 14c1934853..15d96edb6e 100644
--- a/src/lib/ecore_file/ecore_file.c
+++ b/src/lib/ecore_file/ecore_file.c
@@ -5,11 +5,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-
-#ifndef _MSC_VER
-# include <unistd.h>
-# include <libgen.h>
-#endif
+#include <unistd.h>
+#include <libgen.h>
#ifdef _WIN32
# include <direct.h>
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
index e9b6bfb85a..5ab4deb86f 100644
--- a/src/lib/eio/eio_model.c
+++ b/src/lib/eio/eio_model.c
@@ -3,6 +3,7 @@
#endif
#include <stdint.h>
+#include <libgen.h>
#include <Efl.h>
#include <Eina.h>
diff --git a/src/lib/evil/evil_libgen.c b/src/lib/evil/evil_libgen.c
deleted file mode 100644
index d96ba5bae8..0000000000
--- a/src/lib/evil/evil_libgen.c
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-
-#include "evil_macro.h"
-#include "evil_libgen.h"
-
-char _evil_basename_buf[PATH_MAX];
-char _evil_dirname_buf[PATH_MAX];
-
-char *
-evil_basename(char *path)
-{
- char *p1;
- char *p2;
- size_t length;
-
- /* path must begin by "?:\" or "?:/" */
- if ((!path) || !evil_path_is_absolute(path))
- {
- memcpy(_evil_basename_buf, "C:\\", 4);
- return _evil_basename_buf;
- }
-
- /* '/' --> '\\' */
- length = strlen(path);
- p1 = strdup(path);
- if (!p1)
- {
- memcpy(_evil_basename_buf, "C:\\", 4);
- return _evil_basename_buf;
- }
-
- EVIL_PATH_SEP_UNIX_TO_WIN32(p1);
-
- /* remove trailing backslashes */
- p2 = p1 + (length - 1);
- if (*p2 == '\\')
- {
- while (*p2 == '\\')
- p2--;
- }
- *(p2 + 1) = '\0';
-
- p2 = strrchr(p1, '\\');
- memcpy(_evil_basename_buf, p2 + 1, (p1 + length + 1) - p2);
-
- free(p1);
-
- return _evil_basename_buf;
-}
-
-char *
-evil_dirname(char *path)
-{
- char *p1;
- char *p2;
- size_t length;
-
- /* path must begin by "?:\" or "?:/" */
- if ((!path) || !evil_path_is_absolute(path))
- {
- memcpy(_evil_dirname_buf, "C:\\", 4);
- return _evil_dirname_buf;
- }
-
- /* '/' --> '\\' */
- length = strlen(path);
- p1 = strdup(path);
- if (!p1)
- {
- memcpy(_evil_dirname_buf, "C:\\", 4);
- return _evil_dirname_buf;
- }
- p2 = p1;
- while (*p2)
- {
- if (*p2 == '/') *p2 = '\\';
- p2++;
- }
-
- /* remove trailing backslashes */
- p2 = p1 + (length - 1);
- if (*p2 == '\\')
- {
- while (*p2 == '\\')
- p2--;
- }
- *(p2 + 1) = '\0';
-
- p2 = strrchr(p1, '\\');
- *p2 = '\0';
- memcpy(_evil_dirname_buf, p1, strlen(p1) + 1);
-
- free(p1);
-
- return _evil_dirname_buf;
-}
diff --git a/src/lib/evil/evil_libgen.h b/src/lib/evil/evil_libgen.h
deleted file mode 100644
index b832d620ed..0000000000
--- a/src/lib/evil/evil_libgen.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#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.
- * @ingroup Evil
- *
- * This header provides functions ported from Unix in libgen.h.
- *
- * @{
- */
-
-/**
- * @brief Parse the base name component of a path.
- *
- * @param path The path to parse.
- * @return The component following the final '/'.
- *
- * This function parses @p path and returns its component following
- * the final '\'. Trailing '\' are not taken into account. On Windows
- * XP, @p path must beginning by a drive letter followed by ':/' or
- * ':\', otherwise "C:\" is returned. All characters '/' are replaced by '\'. On
- * error (memory allocation failure), "C:\" is returned, otherwise the
- * component following the final '\' is returned as a statically
- * allocated memory. Hence the returns value must not be freed.
- *
- * Concatenating the string returned by dirname(), a "\", and the
- * string returned by basename() yields a complete pathname.
- *
- * @see evil_dirname()
- * @see dirname()
- *
- * Conformity: Non applicable.
- *
- * Supported OS: Windows XP.
- */
-EAPI char *evil_basename(char *path);
-
-/**
- * @def basename(p)
- *
- * Wrapper around evil_basename().
- */
-#define basename(p) evil_basename(p)
-
-/**
- * @brief Parse the dir name component of a path.
- *
- * @param path The path to parse.
- * @return The component up to, but not including, the final '/'.
- *
- * This function parses @p path and returns its component up to, but
- * not including, the final '/'. Trailing '\' are not taken into
- * account. On Windows XP, @p path must beginning by a drive letter
- * followed by ':/' or ':\', otherwise "C:\" is returned. All
- * characters '/' are replaced by '\'. On error (memory allocation
- * failure), "C:\" is returned, otherwise, the component up to, but
- * not including, the final '/' is returned as a statically allocated
- * memory. Hence the returns value must not be freed.
- *
- * Concatenating the string returned by dirname(), a "\", and the
- * string returned by basename() yields a complete pathname.
- *
- * @see evil_basename()
- * @see basename()
- *
- * Conformity: Non applicable.
- *
- * Supported OS: Windows XP.
- */
-EAPI char *evil_dirname(char *path);
-
-/**
- * @def dirname(p)
- *
- * Wrapper around evil_dirname().
- */
-#define dirname(p) evil_dirname(p)
-
-
-/**
- * @}
- */
-
-
-#endif /* __EVIL_LIBGEN_H__ */
diff --git a/src/tests/elementary/elm_code_file_test_load.c b/src/tests/elementary/elm_code_file_test_load.c
index 30cd30e534..b731f66b0d 100644
--- a/src/tests/elementary/elm_code_file_test_load.c
+++ b/src/tests/elementary/elm_code_file_test_load.c
@@ -2,6 +2,8 @@
# include "elementary_config.h"
#endif
+#include <libgen.h>
+
#define ELM_INTERNAL_API_ARGESFSDFEFC
#include "elm_suite.h"
diff --git a/src/tests/evil/evil_suite.c b/src/tests/evil/evil_suite.c
index d8fc492a9a..454a217e64 100644
--- a/src/tests/evil/evil_suite.c
+++ b/src/tests/evil/evil_suite.c
@@ -34,6 +34,7 @@ static const Efl_Test_Case etc[] = {
/* { "Inet", evil_test_inet }, */
/* { "Langinfo", evil_test_langinfo }, */
/* { "Link", evil_test_link }, */
+ { "Libgen", evil_test_libgen },
{ "Main", evil_test_main },
/* { "Mman", evil_test_mman }, */
/* { "Pwd", evil_test_pwd }, */
diff --git a/src/tests/evil/evil_suite.h b/src/tests/evil/evil_suite.h
index c7220e0b80..20f8d03a60 100644
--- a/src/tests/evil/evil_suite.h
+++ b/src/tests/evil/evil_suite.h
@@ -28,6 +28,7 @@ void evil_test_dlfcn(TCase *tc);
/* void evil_test_inet(TCase *tc); */
/* void evil_test_langinfo(TCase *tc); */
/* void evil_test_link(TCase *tc); */
+void evil_test_libgen(TCase *tc);
void evil_test_main(TCase *tc);
/* void evil_test_mman(TCase *tc); */
/* void evil_test_pwd(TCase *tc); */