<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
#include <string.h>
#include <liblazy/io.h>

/* the maximum length of an input line */
#define MAX_INPUT_LINE_SIZE (FILE_READING_BUFFER_SIZE)

int main(int argc, char *argv[]) {
	/* the exit code */
	int exit_code = EXIT_FAILURE;

	/* a regular expression */
	regex_t expression;

	/* an input line */
	char line[MAX_INPUT_LINE_SIZE];

	/* the input line length */
	size_t length;

	/* make sure the number of command-line arguments is valid */
	if (2 != argc)
		goto end;

	/* compile the regular expression */
	if (0 != regcomp(&expression, argv[1], REG_EXTENDED))
		goto end;

	do {
		/* read an input line */
		if (NULL == fgets((char *) &line, sizeof(line), stdin))
			break;

		/* if the line ends with a line break, terminate it */
		length = strlen((char *) &line);
		if ('\n' == line[length - 1])
			line[length - 1] = '\0';

		/* if the line matches the given expression, print it */
		if (0 == regexec(&expression, (char *) &line, 0, NULL, 0)) {
			if (0 > printf("%s\n", (char *) &line))
				goto free_expression;
		}
	} while (1);

	/* report success */
	exit_code = EXIT_SUCCESS;

free_expression:
	/* free the compiled regular expression */
	regfree(&expression);

end:
	return exit_code;
}<commit_msg>Added support for grep -v.<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
#include <string.h>
#include <liblazy/io.h>

/* the maximum length of an input line */
#define MAX_INPUT_LINE_SIZE (FILE_READING_BUFFER_SIZE)

int main(int argc, char *argv[]) {
	/* the exit code */
	int exit_code = EXIT_FAILURE;

	/* a regular expression */
	char *expression;

	/* a compiled regular expression */
	regex_t compiled_expression;

	/* an input line */
	char line[MAX_INPUT_LINE_SIZE];

	/* the input line length */
	size_t length;

	/* flag which indicates which lines should be printed */
	bool should_match;

	/* the regular expression matching result */
	int result;

	/* parse the command-line */
	switch (argc) {
		case 2:
			expression = argv[1];
			should_match = true;
			break;

		case 3:
			if (0 != strcmp("-v", argv[1]))
				goto end;
			expression = argv[2];
			should_match = false;
			break;

		default:
			goto end;
	}

	/* compile the regular expression */
	if (0 != regcomp(&compiled_expression, expression, REG_EXTENDED))
		goto end;

	do {
		/* read an input line */
		if (NULL == fgets((char *) &line, sizeof(line), stdin))
			break;

		/* if the line ends with a line break, terminate it */
		length = strlen((char *) &line);
		if ('\n' == line[length - 1])
			line[length - 1] = '\0';

		/* if the line matches the given expression, print it */
		result = regexec(&compiled_expression, (char *) &line, 0, NULL, 0);
		if (((0 == result) && (true == should_match)) ||
		    ((REG_NOMATCH == result) && (false == should_match))) {
			if (0 > printf("%s\n", (char *) &line))
				goto free_expression;
		}
	} while (1);

	/* report success */
	exit_code = EXIT_SUCCESS;

free_expression:
	/* free the compiled regular expression */
	regfree(&compiled_expression);

end:
	return exit_code;
}
{'fraction_non_alphanumeric': 0.14974293059125965, 'fraction_numerical': 0.008354755784061696, 'mean_word_length': 3.3845070422535213, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '7002368', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1043, 'n_words': 337}