<commit_before>#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

#include "libi3.h"

/*
 * This function returns the absolute path to the executable it is running in.
 *
 * The implementation follows http://stackoverflow.com/a/933996/712014
 *
 */
const char *get_exe_path(const char *argv0) {
    static char destpath[PATH_MAX];
    char tmp[PATH_MAX];

#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
	/* Linux and Debian/kFreeBSD provide /proc/self/exe */
#if defined(__linux__) || defined(__FreeBSD_kernel__)
	const char *exepath = "/proc/self/exe";
#elif defined(__FreeBSD__)
	const char *exepath = "/proc/curproc/file";
#endif
    ssize_t linksize;

    if ((linksize = readlink(exepath, destpath, sizeof(destpath))) != -1) {
		/* readlink() does not NULL-terminate strings, so we have to. */<commit_msg>Bugfix: sizeof(destpath)-1 to have space for the trailing NUL (Thanks Merovius)<commit_after>#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

#include "libi3.h"

/*
 * This function returns the absolute path to the executable it is running in.
 *
 * The implementation follows http://stackoverflow.com/a/933996/712014
 *
 */
const char *get_exe_path(const char *argv0) {
    static char destpath[PATH_MAX];
    char tmp[PATH_MAX];

#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
	/* Linux and Debian/kFreeBSD provide /proc/self/exe */
#if defined(__linux__) || defined(__FreeBSD_kernel__)
	const char *exepath = "/proc/self/exe";
#elif defined(__FreeBSD__)
	const char *exepath = "/proc/curproc/file";
#endif
    ssize_t linksize;

    if ((linksize = readlink(exepath, destpath, sizeof(destpath) - 1)) != -1) {
		/* readlink() does not NULL-terminate strings, so we have to. */
{'fraction_non_alphanumeric': 0.13891891891891892, 'fraction_numerical': 0.017297297297297298, 'mean_word_length': 4.558558558558558, 'pattern_counts': {'":': 0, '<': 13, '<?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': '2444569', 'n_tokens_mistral': 664, 'n_tokens_neox': 618, 'n_words': 169}