summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gen_cmake.c16
-rw-r--r--include/kit.inl.h14
-rw-r--r--source/kit/file.c4
-rw-r--r--source/kit/file.h10
4 files changed, 27 insertions, 17 deletions
diff --git a/gen_cmake.c b/gen_cmake.c
index 0f11407..4ed98de 100644
--- a/gen_cmake.c
+++ b/gen_cmake.c
@@ -205,19 +205,17 @@ int main(int argc, char **argv) {
str_t const targets[] = { SZ("kit"), SZ("kit_test"),
SZ("kit_test_suite") };
- string_t folders[] = { path_norm(SZ("./source/kit"), ALLOC),
- path_norm(SZ("./source/kit_test"), ALLOC),
- path_norm(SZ("./source/test/unittests"),
- ALLOC) };
+ str_t const folders[] = {
+ SZ("." PATH_DELIM "source" PATH_DELIM "kit"),
+ SZ("." PATH_DELIM "source" PATH_DELIM "kit_test"),
+ SZ("." PATH_DELIM "source" PATH_DELIM "test/unittests")
+ };
int ok = 1;
for (ptrdiff_t i = 0; i < sizeof folders / sizeof *folders; i++)
- ok = ok && gen_cmakelists_for(targets[i], WRAP_STR(folders[i]))
- .status == KIT_OK;
-
- for (ptrdiff_t i = 0; i < sizeof folders / sizeof *folders; i++)
- DA_DESTROY(folders[i]);
+ ok = ok &&
+ gen_cmakelists_for(targets[i], folders[i]).status == KIT_OK;
return ok ? 0 : 1;
}
diff --git a/include/kit.inl.h b/include/kit.inl.h
index 287765a..873e0bf 100644
--- a/include/kit.inl.h
+++ b/include/kit.inl.h
@@ -364,10 +364,12 @@ extern "C" {
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
-# define KIT_PATH_DELIM '\\'
+# define KIT_PATH_DELIM_C '\\'
+# define KIT_PATH_DELIM "\\"
# define KIT_ENV_HOME "USERPROFILE"
#else
-# define KIT_PATH_DELIM '/'
+# define KIT_PATH_DELIM_C '/'
+# define KIT_PATH_DELIM "/"
# define KIT_ENV_HOME "HOME"
#endif
@@ -443,6 +445,10 @@ void kit_path_list_destroy(kit_path_list_t list);
# define file_enum_folder kit_file_enum_folder
# define path_list_destroy kit_path_list_destroy
+# define PATH_DELIM_C KIT_PATH_DELIM_C
+# define PATH_DELIM KIT_PATH_DELIM
+# define ENV_HOME KIT_ENV_HOME
+
# define PATH_NONE KIT_PATH_NONE
# define PATH_FILE KIT_PATH_FILE
# define PATH_FOLDER KIT_PATH_FOLDER
@@ -717,7 +723,7 @@ kit_string_t kit_path_norm(kit_str_t const path,
for (i = 0; i < norm.size; i++) {
if (norm.values[i] != '\0') {
if (is_delim(norm.values[i]))
- norm.values[size] = KIT_PATH_DELIM;
+ norm.values[size] = KIT_PATH_DELIM_C;
else
norm.values[size] = norm.values[i];
size++;
@@ -750,7 +756,7 @@ kit_string_t kit_path_join(kit_str_t const left,
return joined;
memcpy(joined.values, left.values, left_size);
- joined.values[left_size] = KIT_PATH_DELIM;
+ joined.values[left_size] = KIT_PATH_DELIM_C;
memcpy(joined.values + left_size + 1, right_values, right_size);
return joined;
diff --git a/source/kit/file.c b/source/kit/file.c
index 9ad4f16..edec2bd 100644
--- a/source/kit/file.c
+++ b/source/kit/file.c
@@ -73,7 +73,7 @@ kit_string_t kit_path_norm(kit_str_t const path,
for (i = 0; i < norm.size; i++) {
if (norm.values[i] != '\0') {
if (is_delim(norm.values[i]))
- norm.values[size] = KIT_PATH_DELIM;
+ norm.values[size] = KIT_PATH_DELIM_C;
else
norm.values[size] = norm.values[i];
size++;
@@ -106,7 +106,7 @@ kit_string_t kit_path_join(kit_str_t const left,
return joined;
memcpy(joined.values, left.values, left_size);
- joined.values[left_size] = KIT_PATH_DELIM;
+ joined.values[left_size] = KIT_PATH_DELIM_C;
memcpy(joined.values + left_size + 1, right_values, right_size);
return joined;
diff --git a/source/kit/file.h b/source/kit/file.h
index a773e02..865e1b8 100644
--- a/source/kit/file.h
+++ b/source/kit/file.h
@@ -10,10 +10,12 @@ extern "C" {
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
-# define KIT_PATH_DELIM '\\'
+# define KIT_PATH_DELIM_C '\\'
+# define KIT_PATH_DELIM "\\"
# define KIT_ENV_HOME "USERPROFILE"
#else
-# define KIT_PATH_DELIM '/'
+# define KIT_PATH_DELIM_C '/'
+# define KIT_PATH_DELIM "/"
# define KIT_ENV_HOME "HOME"
#endif
@@ -89,6 +91,10 @@ void kit_path_list_destroy(kit_path_list_t list);
# define file_enum_folder kit_file_enum_folder
# define path_list_destroy kit_path_list_destroy
+# define PATH_DELIM_C KIT_PATH_DELIM_C
+# define PATH_DELIM KIT_PATH_DELIM
+# define ENV_HOME KIT_ENV_HOME
+
# define PATH_NONE KIT_PATH_NONE
# define PATH_FILE KIT_PATH_FILE
# define PATH_FOLDER KIT_PATH_FOLDER