<commit_before>#include <string.h>
#include <stdio.h>

/* Ensures portable headers are included such as inline. */
#include "config.h"
#include "fileio.h"

/* `strnlen` not widely supported. */
static inline size_t pstrnlen(const char *s, size_t max_len)
{
    const char *end = memchr (s, 0, max_len);
    return end ? (size_t)(end - s) : max_len;
}
#undef strnlen
#define strnlen pstrnlen

char *fb_copy_path_n(const char *path, size_t len)
{
    size_t n;
    char *s;

    n = strnlen(path, len);
    if ((s = malloc(n + 1))) {
        memcpy(s, path, n);
        s[n] = '\0';
    }
    return s;
}

char *fb_copy_path(const char *path)
{
    size_t n;
    char *s;

    n = strlen(path);
    if ((s = malloc(n + 1))) {
        memcpy(s, path, n);
        s[n] = '\0';
    }
    return s;
}

size_t fb_chomp(const char *path, size_t len, const char *ext)
{
    size_t ext_len = ext ? strlen(ext) : 0;
    if (len > ext_len && 0 == strncmp(path + len - ext_len, ext, ext_len)) {
        len -= ext_len;
    }
    return len;
}

char *fb_create_join_path(const char *prefix, size_t prefix_len,
        const char *suffix, size_t suffix_len, const char *ext, int path_sep)
{
    char *path;
    int ext_len = ext ? strlen(ext) : 0;
    int n;

    if (!prefix ||
            (suffix_len > 0 && (suffix[0] == '/' || suffix[0] == '\\')) ||
            (suffix_len > 1 && suffix[1] == ':')) {
        prefix_len = 0;
    }
    if (path_sep && (prefix_len == 0 ||
            (prefix[prefix_len - 1] == '/' || prefix[prefix_len - 1] == '\\'))) {
        path_sep = 0;
    }
    path = malloc(prefix_len + path_sep + suffix_len + ext_len + 1);
    if (!path) {
        return 0;
    }
    n = 0;
    memcpy(path, prefix, prefix_len);
    n += prefix_len;
    if (path_sep) {
        path[n++] = '/';
    }<commit_msg>Use size_t to silence warnings<commit_after>#include <string.h>
#include <stdio.h>

/* Ensures portable headers are included such as inline. */
#include "config.h"
#include "fileio.h"

/* `strnlen` not widely supported. */
static inline size_t pstrnlen(const char *s, size_t max_len)
{
    const char *end = memchr (s, 0, max_len);
    return end ? (size_t)(end - s) : max_len;
}
#undef strnlen
#define strnlen pstrnlen

char *fb_copy_path_n(const char *path, size_t len)
{
    size_t n;
    char *s;

    n = strnlen(path, len);
    if ((s = malloc(n + 1))) {
        memcpy(s, path, n);
        s[n] = '\0';
    }
    return s;
}

char *fb_copy_path(const char *path)
{
    size_t n;
    char *s;

    n = strlen(path);
    if ((s = malloc(n + 1))) {
        memcpy(s, path, n);
        s[n] = '\0';
    }
    return s;
}

size_t fb_chomp(const char *path, size_t len, const char *ext)
{
    size_t ext_len = ext ? strlen(ext) : 0;
    if (len > ext_len && 0 == strncmp(path + len - ext_len, ext, ext_len)) {
        len -= ext_len;
    }
    return len;
}

char *fb_create_join_path(const char *prefix, size_t prefix_len,
        const char *suffix, size_t suffix_len, const char *ext, int path_sep)
{
    char *path;
    size_t ext_len = ext ? strlen(ext) : 0;
    size_t n;

    if (!prefix ||
            (suffix_len > 0 && (suffix[0] == '/' || suffix[0] == '\\')) ||
            (suffix_len > 1 && suffix[1] == ':')) {
        prefix_len = 0;
    }
    if (path_sep && (prefix_len == 0 ||
            (prefix[prefix_len - 1] == '/' || prefix[prefix_len - 1] == '\\'))) {
        path_sep = 0;
    }
    path = malloc(prefix_len + path_sep + suffix_len + ext_len + 1);
    if (!path) {
        return 0;
    }
    n = 0;
    memcpy(path, prefix, prefix_len);
    n += prefix_len;
    if (path_sep) {
        path[n++] = '/';
    }
{'fraction_non_alphanumeric': 0.16497670594683475, 'fraction_numerical': 0.011510002740476843, 'mean_word_length': 2.3151680290644867, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1319249', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1395, 'n_words': 370}