Standardize naming conventions #12

Merged
abdelrahman merged 26 commits from naming-conventions into main 2026-06-26 17:17:27 +00:00
4 changed files with 76 additions and 78 deletions
Showing only changes of commit c29466b863 - Show all commits
+18 -20
View File
@@ -8,28 +8,26 @@
#include "../../base/mem/allocator/mem_allocator.h" #include "../../base/mem/allocator/mem_allocator.h"
#include "../../base/strings/str8/str8.h" #include "../../base/strings/str8/str8.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <string.h>
u32 wapp_cpath_join_path(WpStr8 *dst, const WpStr8List *parts) { u32 wpCpathJoinPath(WpStr8 *dst, const WpStr8List *parts) {
if (!dst || !parts) { if (!dst || !parts) {
return CPATH_JOIN_INVALID_ARGS; return WP_CPATH_JOIN_RESULT_INVALID_ARGS;
} }
if (parts->node_count == 0) { if (parts->node_count == 0) {
return CPATH_JOIN_EMPTY_PARTS; return WP_CPATH_JOIN_RESULT_EMPTY_PARTS;
} }
WpStr8 separator = wpStr8Buf(4); WpStr8 separator = wpStr8Buf(4);
wpStr8PushBack(&separator, WAPP_PATH_SEP); wpStr8PushBack(&separator, WP_PATH_SEP);
u64 required_capacity = parts->node_count * separator.size + wpStr8ListTotalSize(parts); u64 required_capacity = parts->node_count * separator.size + wpStr8ListTotalSize(parts);
if (dst->capacity < required_capacity) { if (dst->capacity < required_capacity) {
return CPATH_JOIN_INSUFFICIENT_DST_CAPACITY; return WP_CPATH_JOIN_RESULT_INSUFFICIENT_DST_CAPACITY;
} }
// Handle first node // Handle first node
WpStr8 *first_node = wapp_dbl_list_get(WpStr8, parts, 0); WpStr8 *first_node = wpDblListGet(WpStr8, parts, 0);
wpStr8CopyStr8Capped(dst, first_node); wpStr8CopyStr8Capped(dst, first_node);
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of // NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
@@ -38,7 +36,7 @@ u32 wapp_cpath_join_path(WpStr8 *dst, const WpStr8List *parts) {
u64 node_index = 1; u64 node_index = 1;
b8 running = node_index < parts->node_count; b8 running = node_index < parts->node_count;
while (running) { while (running) {
node = wapp_dbl_list_get(WpStr8, parts, node_index); node = wpDblListGet(WpStr8, parts, node_index);
if (node->size == 0) { if (node->size == 0) {
goto CPATH_JOIN_LOOP_END; goto CPATH_JOIN_LOOP_END;
} }
@@ -46,7 +44,7 @@ u32 wapp_cpath_join_path(WpStr8 *dst, const WpStr8List *parts) {
if (dst->size > 0) { if (dst->size > 0) {
char dst_last = wpStr8Get(dst, dst->size - 1); char dst_last = wpStr8Get(dst, dst->size - 1);
char node_start = wpStr8Get(node, 0); char node_start = wpStr8Get(node, 0);
b8 add_path_sep = dst_last != WAPP_PATH_SEP && node_start != WAPP_PATH_SEP; b8 add_path_sep = dst_last != WP_PATH_SEP && node_start != WP_PATH_SEP;
if (add_path_sep) { if (add_path_sep) {
wpStr8ConcatCapped(dst, &separator); wpStr8ConcatCapped(dst, &separator);
@@ -60,18 +58,18 @@ CPATH_JOIN_LOOP_END:
running = node_index < parts->node_count; running = node_index < parts->node_count;
} }
return CPATH_JOIN_SUCCESS; return WP_CPATH_JOIN_RESULT_SUCCESS;
} }
WpStr8 *dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels) { WpStr8 *_dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels) {
WpStr8 *output = NULL; WpStr8 *output = NULL;
if (!allocator || !path) { if (!allocator || !path) {
goto RETURN_DIRUP; goto RETURN_DIRUP;
} }
b8 absolute = wpStr8Get(path, 0) == WAPP_PATH_SEP; b8 absolute = wpStr8Get(path, 0) == WP_PATH_SEP;
WpStr8 separator = wpStr8Buf(4); WpStr8 separator = wpStr8Buf(4);
wpStr8PushBack(&separator, WAPP_PATH_SEP); wpStr8PushBack(&separator, WP_PATH_SEP);
if (path->size == 0) { if (path->size == 0) {
output = wpStr8AllocBuf(allocator, 16); output = wpStr8AllocBuf(allocator, 16);
@@ -79,7 +77,7 @@ WpStr8 *dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels) {
goto RETURN_DIRUP; goto RETURN_DIRUP;
} }
wpStr8PushBack(output, absolute ? WAPP_PATH_SEP : '.'); wpStr8PushBack(output, absolute ? WP_PATH_SEP : '.');
goto RETURN_DIRUP; goto RETURN_DIRUP;
} }
@@ -88,7 +86,7 @@ WpStr8 *dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels) {
goto RETURN_DIRUP; goto RETURN_DIRUP;
} }
WpAllocator tmp_arena = wapp_mem_arena_allocator_init(MiB(8)); WpAllocator tmp_arena = wpMemArenaAllocatorInit(MiB(8));
if (wpMemAllocatorInvalid(&tmp_arena)) { if (wpMemAllocatorInvalid(&tmp_arena)) {
goto RETURN_DIRUP; goto RETURN_DIRUP;
} }
@@ -104,10 +102,10 @@ WpStr8 *dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels) {
goto LIST_CLEANUP_DIRUP; goto LIST_CLEANUP_DIRUP;
} }
wpStr8PushBack(output, absolute ? WAPP_PATH_SEP : '.'); wpStr8PushBack(output, absolute ? WP_PATH_SEP : '.');
} else { } else {
for (u64 i = 0; i < levels; ++i) { for (u64 i = 0; i < levels; ++i) {
wapp_dbl_list_pop_back(WpStr8, parts); wpDblListPopBack(WpStr8, parts);
} }
u64 alignment = sizeof(void *) * 2; u64 alignment = sizeof(void *) * 2;
@@ -118,7 +116,7 @@ WpStr8 *dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels) {
output = wpStr8AllocBuf(allocator, alloc_size); output = wpStr8AllocBuf(allocator, alloc_size);
if (output) { if (output) {
if (absolute) { if (absolute) {
wpStr8PushBack(output, WAPP_PATH_SEP); wpStr8PushBack(output, WP_PATH_SEP);
} }
WpStr8 *joined = wpStr8Join(&tmp_arena, parts, &separator); WpStr8 *joined = wpStr8Join(&tmp_arena, parts, &separator);
@@ -129,7 +127,7 @@ WpStr8 *dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels) {
} }
LIST_CLEANUP_DIRUP: LIST_CLEANUP_DIRUP:
wapp_mem_arena_allocator_destroy(&tmp_arena); wpMemArenaAllocatorDestroy(&tmp_arena);
RETURN_DIRUP: RETURN_DIRUP:
return output; return output;
+14 -14
View File
@@ -14,29 +14,29 @@ BEGIN_C_LINKAGE
#ifdef WP_PLATFORM_POSIX #ifdef WP_PLATFORM_POSIX
#include <limits.h> #include <limits.h>
#define WAPP_PATH_SEP '/' #define WP_PATH_SEP '/'
#define WAPP_PATH_MAX PATH_MAX #define WP_PATH_MAX PATH_MAX
#elif defined(WP_PLATFORM_WINDOWS) #elif defined(WP_PLATFORM_WINDOWS)
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <Windows.h> #include <Windows.h>
#define WAPP_PATH_SEP '\\' #define WP_PATH_SEP '\\'
#define WAPP_PATH_MAX MAX_PATH #define WP_PATH_MAX MAX_PATH
#else #else
#error "Unrecognised platform" #error "Unrecognised platform"
#endif #endif
#define wapp_cpath_dirname(ALLOCATOR, PATH) dirup(ALLOCATOR, PATH, 1) #define wpCpathDirname(ALLOCATOR, PATH) _dirup(ALLOCATOR, PATH, 1)
#define wapp_cpath_dirup(ALLOCATOR, PATH, COUNT) dirup(ALLOCATOR, PATH, COUNT) #define wpCpathDirup(ALLOCATOR, PATH, COUNT) _dirup(ALLOCATOR, PATH, COUNT)
enum { typedef enum {
CPATH_JOIN_SUCCESS = 0, WP_CPATH_JOIN_RESULT_SUCCESS = 0,
CPATH_JOIN_INVALID_ARGS, WP_CPATH_JOIN_RESULT_INVALID_ARGS,
CPATH_JOIN_EMPTY_PARTS, WP_CPATH_JOIN_RESULT_EMPTY_PARTS,
CPATH_JOIN_INSUFFICIENT_DST_CAPACITY, WP_CPATH_JOIN_RESULT_INSUFFICIENT_DST_CAPACITY,
}; } WpCpathJoinResult;
u32 wapp_cpath_join_path(WpStr8 *dst, const WpStr8List *parts); WpCpathJoinResult wpCpathJoinPath(WpStr8 *dst, const WpStr8List *parts);
WpStr8 *dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels); WpStr8 *_dirup(const WpAllocator *allocator, WpStr8RO *path, u64 levels);
#ifdef WP_PLATFORM_CPP #ifdef WP_PLATFORM_CPP
END_C_LINKAGE END_C_LINKAGE
+22 -22
View File
@@ -13,8 +13,8 @@ WpTestFuncResult test_cpath_join_path(void) {
WpStr8 out = wpStr8Buf(MAIN_BUF_SIZE); WpStr8 out = wpStr8Buf(MAIN_BUF_SIZE);
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE); WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&tmp, "%c", WAPP_PATH_SEP); wpStr8Format(&tmp, "%c", WP_PATH_SEP);
WpStr8List parts = wpDblList(WpStr8); WpStr8List parts = wpDblList(WpStr8);
wpDblListPushBack(WpStr8, &parts, &tmp); wpDblListPushBack(WpStr8, &parts, &tmp);
@@ -27,7 +27,7 @@ WpTestFuncResult test_cpath_join_path(void) {
wpDblListPopFront(WpStr8, &parts); wpDblListPopFront(WpStr8, &parts);
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
wpCpathJoinPath(&out, &parts); wpCpathJoinPath(&out, &parts);
result = result && wpStr8Equal(&out, &expected); result = result && wpStr8Equal(&out, &expected);
@@ -36,27 +36,27 @@ WpTestFuncResult test_cpath_join_path(void) {
wpDblListPopFront(WpStr8, &parts); wpDblListPopFront(WpStr8, &parts);
wpDblListPushFront(WpStr8, &parts, &tmp); wpDblListPushFront(WpStr8, &parts, &tmp);
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpCpathJoinPath(&out, &parts); wpCpathJoinPath(&out, &parts);
result = result && wpStr8Equal(&out, &expected); result = result && wpStr8Equal(&out, &expected);
wpStr8Format(&tmp, "home%c", WAPP_PATH_SEP); wpStr8Format(&tmp, "home%c", WP_PATH_SEP);
wpDblListPopFront(WpStr8, &parts); wpDblListPopFront(WpStr8, &parts);
wpDblListPushFront(WpStr8, &parts, &wpStr8Lit("home")); wpDblListPushFront(WpStr8, &parts, &wpStr8Lit("home"));
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
wpCpathJoinPath(&out, &parts); wpCpathJoinPath(&out, &parts);
result = result && wpStr8Equal(&out, &expected); result = result && wpStr8Equal(&out, &expected);
wpDblListEmpty(WpStr8, &parts); wpDblListEmpty(WpStr8, &parts);
wpStr8Format(&tmp, "%chome", WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome", WP_PATH_SEP);
wpDblListPushBack(WpStr8, &parts, &tmp); wpDblListPushBack(WpStr8, &parts, &tmp);
wpDblListPushBack(WpStr8, &parts, &wpStr8Lit("")); wpDblListPushBack(WpStr8, &parts, &wpStr8Lit(""));
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP); wpStr8Format(&expected, "%chome", WP_PATH_SEP);
wpCpathJoinPath(&out, &parts); wpCpathJoinPath(&out, &parts);
result = result && wpStr8Equal(&out, &expected); result = result && wpStr8Equal(&out, &expected);
@@ -93,8 +93,8 @@ WpTestFuncResult test_cpath_dirname(void) {
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE); WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
// CASE 1 // CASE 1
wpStr8Format(&tmp, "%c", WAPP_PATH_SEP); wpStr8Format(&tmp, "%c", WP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP); wpStr8Format(&expected, "%c", WP_PATH_SEP);
output = wpCpathDirname(&arena, &tmp); output = wpCpathDirname(&arena, &tmp);
result = output != NULL && wpStr8Equal(output, &expected); result = output != NULL && wpStr8Equal(output, &expected);
@@ -110,15 +110,15 @@ WpTestFuncResult test_cpath_dirname(void) {
result = result && output != NULL && wpStr8Equal(output, &expected); result = result && output != NULL && wpStr8Equal(output, &expected);
// CASE 4 // CASE 4
wpStr8Format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome%ctest", WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP); wpStr8Format(&expected, "%chome", WP_PATH_SEP);
output = wpCpathDirname(&arena, &tmp); output = wpCpathDirname(&arena, &tmp);
result = result && output != NULL && wpStr8Equal(output, &expected); result = result && output != NULL && wpStr8Equal(output, &expected);
// CASE 5 // CASE 5
wpStr8Format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome%ctest%c", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP); wpStr8Format(&expected, "%chome", WP_PATH_SEP);
output = wpCpathDirname(&arena, &tmp); output = wpCpathDirname(&arena, &tmp);
result = result && output != NULL && wpStr8Equal(output, &expected); result = result && output != NULL && wpStr8Equal(output, &expected);
@@ -141,35 +141,35 @@ WpTestFuncResult test_cpath_dirup(void) {
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE); WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
// CASE 1 // CASE 1
wpStr8Format(&tmp, "%c", WAPP_PATH_SEP); wpStr8Format(&tmp, "%c", WP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP); wpStr8Format(&expected, "%c", WP_PATH_SEP);
output = wpCpathDirup(&arena, &tmp, 3); output = wpCpathDirup(&arena, &tmp, 3);
result = output != NULL && wpStr8Equal(output, &expected); result = output != NULL && wpStr8Equal(output, &expected);
// CASE 2 // CASE 2
wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP); wpStr8Format(&expected, "%c", WP_PATH_SEP);
output = wpCpathDirup(&arena, &tmp, 3); output = wpCpathDirup(&arena, &tmp, 3);
result = result && output != NULL && wpStr8Equal(output, &expected); result = result && output != NULL && wpStr8Equal(output, &expected);
// CASE 3 // CASE 3
wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
wpStr8CopyCstrCapped(&expected, "."); wpStr8CopyCstrCapped(&expected, ".");
output = wpCpathDirup(&arena, &tmp, 3); output = wpCpathDirup(&arena, &tmp, 3);
result = result && output != NULL && wpStr8Equal(output, &expected); result = result && output != NULL && wpStr8Equal(output, &expected);
// CASE 4 // CASE 4
wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP); wpStr8Format(&expected, "%chome", WP_PATH_SEP);
output = wpCpathDirup(&arena, &tmp, 2); output = wpCpathDirup(&arena, &tmp, 2);
result = result && output != NULL && wpStr8Equal(output, &expected); result = result && output != NULL && wpStr8Equal(output, &expected);
// CASE 5 // CASE 5
wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
wpStr8CopyCstrCapped(&expected, "home"); wpStr8CopyCstrCapped(&expected, "home");
output = wpCpathDirup(&arena, &tmp, 2); output = wpCpathDirup(&arena, &tmp, 2);
+22 -22
View File
@@ -13,8 +13,8 @@ WpTestFuncResult test_cpath_join_path(void) {
WpStr8 out = wpStr8Buf(MAIN_BUF_SIZE); WpStr8 out = wpStr8Buf(MAIN_BUF_SIZE);
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE); WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&tmp, "%c", WAPP_PATH_SEP); wpStr8Format(&tmp, "%c", WP_PATH_SEP);
WpStr8List parts = wpDblList(WpStr8); WpStr8List parts = wpDblList(WpStr8);
@@ -34,7 +34,7 @@ WpTestFuncResult test_cpath_join_path(void) {
wpDblListPopFront(WpStr8, &parts); wpDblListPopFront(WpStr8, &parts);
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
wpCpathJoinPath(&out, &parts); wpCpathJoinPath(&out, &parts);
result = result && wpStr8Equal(&out, &expected); result = result && wpStr8Equal(&out, &expected);
@@ -45,32 +45,32 @@ WpTestFuncResult test_cpath_join_path(void) {
wpDblListPushFront(WpStr8, &parts, &tmp); wpDblListPushFront(WpStr8, &parts, &tmp);
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpCpathJoinPath(&out, &parts); wpCpathJoinPath(&out, &parts);
result = result && wpStr8Equal(&out, &expected); result = result && wpStr8Equal(&out, &expected);
wpStr8Format(&tmp, "home%c", WAPP_PATH_SEP); wpStr8Format(&tmp, "home%c", WP_PATH_SEP);
wpDblListPopFront(WpStr8, &parts); wpDblListPopFront(WpStr8, &parts);
WpStr8 home_2 = wpStr8Lit("home"); WpStr8 home_2 = wpStr8Lit("home");
wpDblListPushFront(WpStr8, &parts, &home_2); wpDblListPushFront(WpStr8, &parts, &home_2);
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
wpCpathJoinPath(&out, &parts); wpCpathJoinPath(&out, &parts);
result = result && wpStr8Equal(&out, &expected); result = result && wpStr8Equal(&out, &expected);
wpDblListEmpty(WpStr8, &parts); wpDblListEmpty(WpStr8, &parts);
wpStr8Format(&tmp, "%chome", WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome", WP_PATH_SEP);
wpDblListPushBack(WpStr8, &parts, &tmp); wpDblListPushBack(WpStr8, &parts, &tmp);
WpStr8 empty = wpStr8Lit(""); WpStr8 empty = wpStr8Lit("");
wpDblListPushBack(WpStr8, &parts, &empty); wpDblListPushBack(WpStr8, &parts, &empty);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP); wpStr8Format(&expected, "%chome", WP_PATH_SEP);
wpCpathJoinPath(&out, &parts); wpCpathJoinPath(&out, &parts);
result = result && wpStr8Equal(&out, &expected); result = result && wpStr8Equal(&out, &expected);
@@ -111,8 +111,8 @@ WpTestFuncResult test_cpath_dirname(void) {
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE); WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
// CASE 1 // CASE 1
wpStr8Format(&tmp, "%c", WAPP_PATH_SEP); wpStr8Format(&tmp, "%c", WP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP); wpStr8Format(&expected, "%c", WP_PATH_SEP);
output = wpCpathDirname(&arena, &tmp); output = wpCpathDirname(&arena, &tmp);
result = output != nullptr && wpStr8Equal(output, &expected); result = output != nullptr && wpStr8Equal(output, &expected);
@@ -130,15 +130,15 @@ WpTestFuncResult test_cpath_dirname(void) {
result = result && output != nullptr && wpStr8Equal(output, &expected); result = result && output != nullptr && wpStr8Equal(output, &expected);
// CASE 4 // CASE 4
wpStr8Format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome%ctest", WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP); wpStr8Format(&expected, "%chome", WP_PATH_SEP);
output = wpCpathDirname(&arena, &tmp); output = wpCpathDirname(&arena, &tmp);
result = result && output != nullptr && wpStr8Equal(output, &expected); result = result && output != nullptr && wpStr8Equal(output, &expected);
// CASE 5 // CASE 5
wpStr8Format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome%ctest%c", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP); wpStr8Format(&expected, "%chome", WP_PATH_SEP);
output = wpCpathDirname(&arena, &tmp); output = wpCpathDirname(&arena, &tmp);
result = result && output != nullptr && wpStr8Equal(output, &expected); result = result && output != nullptr && wpStr8Equal(output, &expected);
@@ -161,35 +161,35 @@ WpTestFuncResult test_cpath_dirup(void) {
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE); WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
// CASE 1 // CASE 1
wpStr8Format(&tmp, "%c", WAPP_PATH_SEP); wpStr8Format(&tmp, "%c", WP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP); wpStr8Format(&expected, "%c", WP_PATH_SEP);
output = wpCpathDirup(&arena, &tmp, 3); output = wpCpathDirup(&arena, &tmp, 3);
result = output != nullptr && wpStr8Equal(output, &expected); result = output != nullptr && wpStr8Equal(output, &expected);
// CASE 2 // CASE 2
wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP); wpStr8Format(&expected, "%c", WP_PATH_SEP);
output = wpCpathDirup(&arena, &tmp, 3); output = wpCpathDirup(&arena, &tmp, 3);
result = result && output != nullptr && wpStr8Equal(output, &expected); result = result && output != nullptr && wpStr8Equal(output, &expected);
// CASE 3 // CASE 3
wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
wpStr8CopyCstrCapped(&expected, "."); wpStr8CopyCstrCapped(&expected, ".");
output = wpCpathDirup(&arena, &tmp, 3); output = wpCpathDirup(&arena, &tmp, 3);
result = result && output != nullptr && wpStr8Equal(output, &expected); result = result && output != nullptr && wpStr8Equal(output, &expected);
// CASE 4 // CASE 4
wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP); wpStr8Format(&expected, "%chome", WP_PATH_SEP);
output = wpCpathDirup(&arena, &tmp, 2); output = wpCpathDirup(&arena, &tmp, 2);
result = result && output != nullptr && wpStr8Equal(output, &expected); result = result && output != nullptr && wpStr8Equal(output, &expected);
// CASE 5 // CASE 5
wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP); wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
wpStr8CopyCstrCapped(&expected, "home"); wpStr8CopyCstrCapped(&expected, "home");
output = wpCpathDirup(&arena, &tmp, 2); output = wpCpathDirup(&arena, &tmp, 2);