full split complete

This commit is contained in:
2025-11-29 14:56:51 -08:00
parent 74637c8e83
commit c2a6a593ef
16 changed files with 2808 additions and 2690 deletions

36
core.c
View File

@@ -1,3 +1,4 @@
#include <sys/stat.h>
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
@@ -9,6 +10,7 @@
#ifdef INCLUDE_STRNSTR
/*
* Find the first occurrence of find in s, where the search is limited to the
* first slen characters of s.
@@ -36,6 +38,40 @@ strnstr(const char *s, const char *find, size_t slen)
#endif
int
path_is_dir(const char *path)
{
struct stat st;
if (path == NULL) {
return 0;
}
if (stat(path, &st) == 0) {
return S_ISDIR(st.st_mode);
}
return 0;
}
size_t
str_lcp2(const char *a, const char *b)
{
size_t i = 0;
if (!a || !b) {
return 0;
}
while (a[i] && b[i] && a[i] == b[i]) {
i++;
}
return i;
}
void
swap_size_t(size_t *first, size_t *second)
{