<commit_before>#ifndef REGEX_H
#define REGEX_H

#include <stddef.h>
#include <string.h>
#include <stdlib.h>

/* naive and wrong regex stubs */
typedef struct regex_t {
	char *pattern;
} regex_t;

#define REG_EXTENDED 1
#define REG_ICASE    2
#define REG_NOSUB    4
#define REG_NEWLINE  8

int regcomp(regex_t *regex, const char *pattern, int cflags)
{
	size_t len = strlen(pattern)+1;
	(void) cflags;
	regex->pattern = malloc(len);
	memcpy(regex->pattern, pattern, len);
}

int regexec(const regex_t *regex, const char *haystack, int flags)
{
	size_t i = 0;
	const char *pattern = regex->pattern;
	for (i = 0; pattern[i] != '\0'; ++i) {
		if (pattern[i] != haystack[i])
			return 0;
	}
	return 1;
}

void regfree(regex_t *regex)
{
	free(regex->pattern);
}

#endif<commit_msg>Fixed the "naive and wrong regex stubs", so it has the right signature and returns the right value/error code now.<commit_after>#ifndef REGEX_H
#define REGEX_H

#include <stddef.h>
#include <string.h>
#include <stdlib.h>

/* naive and wrong regex stubs */
typedef struct regex_t {
	char *pattern;
} regex_t;

typedef size_t regoff_t;

typedef struct regmatch_t {
	regoff_t rm_so;
	regoff_t rm_eo;
} regmatch_t;

#define REG_EXTENDED 1
#define REG_ICASE    2
#define REG_NOSUB    4
#define REG_NEWLINE  8
#define REG_NOTBOL   16
#define REG_NOTEOL   32

#define REG_NOMATCH 1

int regcomp(regex_t *regex, const char *pattern, int cflags)
{
	(void) cflags;
	regex->pattern = _strdup(pattern);
	return 0;
}

int regexec(const regex_t *regex, const char *haystack, size_t nmatch, regmatch_t pmatch[], int flags)
{
	size_t i = 0;
	const char *pattern = regex->pattern;
	for (i = 0; pattern[i] != '\0'; ++i) {
		if (pattern[i] != haystack[i])
			return REG_NOMATCH;
	}
	return 0;
}

void regfree(regex_t *regex)
{
	free(regex->pattern);
}

#endif
{'fraction_non_alphanumeric': 0.12617079889807162, 'fraction_numerical': 0.013223140495867768, 'mean_word_length': 4.404761904761905, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, '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': '3984116', 'n_tokens_mistral': 743, 'n_tokens_neox': 706, 'n_words': 208}