<commit_before>#include "lpg_create_process.h"
#include "lpg_assert.h"
#include "lpg_allocate.h"
#include "lpg_win32.h"

#ifdef _WIN32
static win32_string build_command_line(unicode_view const executable, unicode_view const *const arguments,
                                       size_t const argument_count)
{
    size_t result_size = 2;
    {
        ASSERT(executable.length <= (size_t)INT_MAX);
        int const converted_size = MultiByteToWideChar(CP_UTF8, 0, executable.begin, (int)executable.length, NULL, 0);
        ASSERT((executable.length == 0) || (converted_size != 0));
        result_size += (size_t)converted_size;
    }
    for (size_t i = 0; i < argument_count; ++i)
    {
        result_size += 1;
        ASSERT(arguments[i].length <= (size_t)INT_MAX);
        int const converted_size =
            MultiByteToWideChar(CP_UTF8, 0, arguments[i].begin, (int)arguments[i].length, NULL, 0);
        ASSERT((arguments[i].length == 0) || (converted_size != 0));
        result_size += (size_t)converted_size;
    }
    ASSERT(result_size <= (size_t)INT_MAX);
    win32_string const result = {allocate_array(result_size + 1, sizeof(*result.c_str)), result_size};
    result.c_str[0] = L'"';
    size_t destination = 1;
    destination += (size_t)MultiByteToWideChar(CP_UTF8, 0, executable.begin, (int)executable.length,
                                               result.c_str + destination, (int)(result.size - destination));
    for (size_t i = 1; i < destination; ++i)
    {
        if (result.c_str[i] == L'/')
        {
            result.c_str[i] = L'\\';
        }
    }
    result.c_str[destination] = L'"';
    destination += 1;
    for (size_t i = 0; i < argument_count; ++i)
    {
        result.c_str[destination] = L' ';
        destination += 1;
        destination += (size_t)MultiByteToWideChar(CP_UTF8, 0, arguments[i].begin, (int)arguments[i].length,
                                                   result.c_str + destination, (int)(result.size - destination));
    }
    ASSUME(destination == result.size);
    result.c_str[result.size] = L'\0';
    return result;
}
#else
#include <unistd.h>
#include <sys/prctl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h><commit_msg>try to fix OSX build<commit_after>#include "lpg_create_process.h"
#include "lpg_assert.h"
#include "lpg_allocate.h"
#include "lpg_win32.h"

#ifdef _WIN32
static win32_string build_command_line(unicode_view const executable, unicode_view const *const arguments,
                                       size_t const argument_count)
{
    size_t result_size = 2;
    {
        ASSERT(executable.length <= (size_t)INT_MAX);
        int const converted_size = MultiByteToWideChar(CP_UTF8, 0, executable.begin, (int)executable.length, NULL, 0);
        ASSERT((executable.length == 0) || (converted_size != 0));
        result_size += (size_t)converted_size;
    }
    for (size_t i = 0; i < argument_count; ++i)
    {
        result_size += 1;
        ASSERT(arguments[i].length <= (size_t)INT_MAX);
        int const converted_size =
            MultiByteToWideChar(CP_UTF8, 0, arguments[i].begin, (int)arguments[i].length, NULL, 0);
        ASSERT((arguments[i].length == 0) || (converted_size != 0));
        result_size += (size_t)converted_size;
    }
    ASSERT(result_size <= (size_t)INT_MAX);
    win32_string const result = {allocate_array(result_size + 1, sizeof(*result.c_str)), result_size};
    result.c_str[0] = L'"';
    size_t destination = 1;
    destination += (size_t)MultiByteToWideChar(CP_UTF8, 0, executable.begin, (int)executable.length,
                                               result.c_str + destination, (int)(result.size - destination));
    for (size_t i = 1; i < destination; ++i)
    {
        if (result.c_str[i] == L'/')
        {
            result.c_str[i] = L'\\';
        }
    }
    result.c_str[destination] = L'"';
    destination += 1;
    for (size_t i = 0; i < argument_count; ++i)
    {
        result.c_str[destination] = L' ';
        destination += 1;
        destination += (size_t)MultiByteToWideChar(CP_UTF8, 0, arguments[i].begin, (int)arguments[i].length,
                                                   result.c_str + destination, (int)(result.size - destination));
    }
    ASSUME(destination == result.size);
    result.c_str[result.size] = L'\0';
    return result;
}
#else
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#endif
#ifdef __linux__
#include <sys/prctl.h>
{'fraction_non_alphanumeric': 0.14098287747387148, 'fraction_numerical': 0.01467645096731154, 'mean_word_length': 2.6748366013071894, 'pattern_counts': {'":': 0, '<': 25, '<?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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6618076', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1491, 'n_words': 294}