Rework detection of directory separator Use _WIN32 and __CYGWIN__ macros to detect Windows directory separators.
Project: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/commit/7f2cb31d Tree: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/tree/7f2cb31d Diff: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/diff/7f2cb31d Branch: refs/heads/master Commit: 7f2cb31d06aeaf46499785aabfa3eb4bcf9d1b7b Parents: 41d9407 Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Wed Jun 1 21:35:25 2016 +0200 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Thu Jun 2 00:04:18 2016 +0200 ---------------------------------------------------------------------- src/Charmonizer/Probe/DirManip.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/7f2cb31d/src/Charmonizer/Probe/DirManip.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Probe/DirManip.c b/src/Charmonizer/Probe/DirManip.c index c737f22..50e7cdc 100644 --- a/src/Charmonizer/Probe/DirManip.c +++ b/src/Charmonizer/Probe/DirManip.c @@ -119,7 +119,6 @@ chaz_DirManip_try_rmdir(void) { void chaz_DirManip_run(void) { - const char *dir_sep = chaz_OS_dir_sep(); int has_dirent_h = chaz_HeadCheck_check_header("dirent.h"); int has_direct_h = chaz_HeadCheck_check_header("direct.h"); int has_dirent_d_namlen = false; @@ -176,16 +175,13 @@ chaz_DirManip_run(void) { chaz_ConfWriter_add_def("MAKEDIR_MODE_IGNORED", "1"); } - if (strcmp(dir_sep, "\\") == 0) { + if (chaz_CC_has_macro("_WIN32") && !chaz_CC_is_cygwin()) { chaz_ConfWriter_add_def("DIR_SEP", "\"\\\\\""); chaz_ConfWriter_add_def("DIR_SEP_CHAR", "'\\\\'"); } else { - char scratch[5]; - sprintf(scratch, "\"%s\"", dir_sep); - chaz_ConfWriter_add_def("DIR_SEP", scratch); - sprintf(scratch, "'%s'", dir_sep); - chaz_ConfWriter_add_def("DIR_SEP_CHAR", scratch); + chaz_ConfWriter_add_def("DIR_SEP", "\"/\""); + chaz_ConfWriter_add_def("DIR_SEP_CHAR", "'/'"); } /* See whether remove works on directories. */