<commit_before>#include "optget.h"

/* Variables used by getopt */
char *optarg  = NULL;
int optind    =    1;
int opterr    =   -1;
int optopt    =    0;

/* getopt: gets the options from an argument list */
int getopt(int argc, char *argv[], const char *optstring) {
	static volatile unsigned argn = 1;
	static volatile unsigned ap = 0;
	unsigned osl = strlen(optstring);
	char *auxptr;

    // Every parameter checked?
    if (argn >= argc) {
        argn = 1;			// Prepare for next time the function is called
        return -1;			// Say that everything is done
    }

	// Check if a clean has occurred
	if (opterr == -1) {
		opterr = 0;
		ap = 0;
		argn = 1;
	}

	// Check if optstring is a valid string
	if (!osl) return -1;	// Everything is done

	// Current parameter already checked?
	if (ap > strlen(argv[argn])-1) /* if (!argv[argn][ap])*/{
		argn++;
		ap = 0;
	}

	// Are we analyzing the first character of an argument? It should be a '-'
	while (ap == 0 && (optopt+optind)<argc) {			// Repeat this analysis until we find a real
		if (argv[argn][0] == '-' && (argv[argn][1])) {	// option. Stop if we already analyzed every argument.
			ap++;
		} else {
			// If it is not a '-', we won't analyze it!
			int i;
			// Put this argument at the end (y adelanta los otros par'ametros una posici'on)
			auxptr = argv[argn];
			for (i=argn; i<argc; i++) argv[i]=argv[i+1];
			argv[i-1] = auxptr;
			optopt++;<commit_msg>Change getopt to avoid segmentation fault<commit_after>#include "optget.h"

/* Variables used by getopt */
char *optarg  = NULL;
int optind    =    1;
int opterr    =   -1;
int optopt    =    0;

/* getopt: gets the options from an argument list */
int getopt(int argc, char *argv[], const char *optstring) {
	static volatile unsigned argn = 1;
	static volatile unsigned ap = 0;
	unsigned osl = strlen(optstring);
	char *auxptr;

    // Every parameter checked?
    if (argn >= argc) {
        argn = 1;			// Prepare for next time the function is called
        return -1;			// Say that everything is done
    }

	// Check if a clean has occurred
	if (opterr == -1) {
		opterr = 0;
		ap = 0;
		argn = 1;
	}

	// Check if optstring is a valid string
	if (!osl) return -1;	// Everything is done

	// Current parameter already checked?
	if (ap > strlen(argv[argn])-1) /* if (!argv[argn][ap])*/{
		argn++;
		ap = 0;
	}

    // Every parameter checked? - yes, again
    if (argn >= argc) {
        argn = 1;			// Prepare for next time the function is called
        return -1;			// Say that everything is done
    }

	// Are we analyzing the first character of an argument? It should be a '-'
	while (ap == 0 && (optopt+optind)<argc) {			// Repeat this analysis until we find a real
		if (argv[argn][0] == '-' && (argv[argn][1])) {	// option. Stop if we already analyzed every argument.
			ap++;
		} else {
			// If it is not a '-', we won't analyze it!
			int i;
			// Put this argument at the end (y adelanta los otros par'ametros una posici'on)
			auxptr = argv[argn];
			for (i=argn; i<argc; i++) argv[i]=argv[i+1];
			argv[i-1] = auxptr;
			optopt++;
{'fraction_non_alphanumeric': 0.1394668400520156, 'fraction_numerical': 0.013003901170351105, 'mean_word_length': 2.5946261682242993, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '150933', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1067, 'n_words': 399}