Style: Rename string_createcat_cc to string_concat_cc
This commit is contained in:
8
src/io.c
8
src/io.c
@@ -14,10 +14,10 @@ StringView path_concat_ss(StringPool *sp, StringView* a, StringView* b)
|
|||||||
if(b == NULL) DIE("b must be a valid string!");
|
if(b == NULL) DIE("b must be a valid string!");
|
||||||
if(a->len <= 0 || b->len <= 0) DIE("a and b must not be empty! (a:%d, b:%d)", a->len, b->len);
|
if(a->len <= 0 || b->len <= 0) DIE("a and b must not be empty! (a:%d, b:%d)", a->len, b->len);
|
||||||
if(a->buf[a->len - 1] == '/')
|
if(a->buf[a->len - 1] == '/')
|
||||||
return string_createcat_ss(sp, a, b);
|
return string_concat_ss(sp, a, b);
|
||||||
StringView slash = (StringView){.buf = "/", .len = 1};
|
StringView slash = (StringView){.buf = "/", .len = 1};
|
||||||
StringView ts = string_createcat_ss(sp, a, &slash);
|
StringView ts = string_concat_ss(sp, a, &slash);
|
||||||
return string_createcat_ss(sp, &ts, b);
|
return string_concat_ss(sp, &ts, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utilize DFS for recursive directory search.
|
// Utilize DFS for recursive directory search.
|
||||||
@@ -40,7 +40,7 @@ size_t dir_get_recursive(DirOpContext* doc, StringView* p)
|
|||||||
if(de == NULL && errno != 0) DIE("failed to read directory: \"%s\"", p);
|
if(de == NULL && errno != 0) DIE("failed to read directory: \"%s\"", p);
|
||||||
if(de == NULL) break;
|
if(de == NULL) break;
|
||||||
|
|
||||||
if(de->d_type == DT_UNKNOWN) DIE("Filesystem not supported!!");
|
if(de->d_type == DT_UNKNOWN) DIE("Filesystem not supported!!"); // Add support for modern filesystems using stat()
|
||||||
if(de->d_type != DT_DIR && de->d_type != DT_REG) continue;
|
if(de->d_type != DT_DIR && de->d_type != DT_REG) continue;
|
||||||
if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0 || strcmp(de->d_name, ".git") == 0) continue;
|
if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0 || strcmp(de->d_name, ".git") == 0) continue;
|
||||||
|
|
||||||
|
|||||||
11
src/main.c
11
src/main.c
@@ -15,17 +15,16 @@ int main(void)
|
|||||||
Backend b = BACKEND_CONST;
|
Backend b = BACKEND_CONST;
|
||||||
backend_initialize(&b);
|
backend_initialize(&b);
|
||||||
|
|
||||||
Arena a_sp = arena_create(&b, MEM_ARENA_MAX_CAP);
|
Arena a_sp = arena_create(&b, MEM_ARENA_MAX_CAP);
|
||||||
StringPool sp = string_pool_create(&a_sp);
|
StringPool sp = string_pool_create(&a_sp);
|
||||||
|
|
||||||
Arena a_d = arena_create(&b, 1024*1024*5); // 5MB for Discovery
|
Arena a_d = arena_create(&b, 1024*1024*5); // 5MB for Discovery
|
||||||
Discovery d = discovery_create(&a_d, &sp);
|
Discovery d = discovery_create(&a_d, &sp);
|
||||||
discovery_discover(&d);
|
discovery_discover(&d);
|
||||||
|
|
||||||
Arena a_cmd = arena_create(&b, MEM_ARENA_MAX_CAP);
|
|
||||||
|
|
||||||
Configuration sample_config;
|
|
||||||
|
|
||||||
|
Arena a_cmd = arena_create(&b, MEM_ARENA_MAX_CAP);
|
||||||
|
|
||||||
|
Configuration sample_config;
|
||||||
Command cmd = command_create(&a_cmd, &d, &sample_config);
|
Command cmd = command_create(&a_cmd, &d, &sample_config);
|
||||||
command_run(&cmd);
|
command_run(&cmd);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ StringView string_create(StringPool* sp, const char* s, size_t len)
|
|||||||
return (StringView){.buf = buf, .len=len};
|
return (StringView){.buf = buf, .len=len};
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView string_createcat_ss(StringPool* sp, StringView* a, StringView* b)
|
StringView string_concat_ss(StringPool* sp, StringView* a, StringView* b)
|
||||||
{
|
{
|
||||||
if(a == NULL) DIE("a must be a valid C-style string!");
|
if(a == NULL) DIE("a must be a valid C-style string!");
|
||||||
if(b == NULL) DIE("b must be a valid C-style string!");
|
if(b == NULL) DIE("b must be a valid C-style string!");
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ StringPool string_pool_create(Arena* a);
|
|||||||
StringView string_create(StringPool* sp, const char* s, size_t len);
|
StringView string_create(StringPool* sp, const char* s, size_t len);
|
||||||
|
|
||||||
// Ensure that lengths do not contain null term
|
// Ensure that lengths do not contain null term
|
||||||
StringView string_createcat_ss(StringPool* sp, StringView* a, StringView* b);
|
StringView string_concat_ss(StringPool* sp, StringView* a, StringView* b);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user