Rework detection of directory separator
Use _WIN32 and __CYGWIN__ macros to detect Windows directory separators.
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 @@
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_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. */