<commit_before>/**
 * @file
 * @brief Simple scanf implementation.
 *
 * @date 10.02.09
 * @author <NAME>
 *          - Initial implementation
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <stdbool.h>
#include <fs/file_operation.h>

FILE *file;

/*TODO: throw out.*/
/**
 * convert digit character to integer
 * @param digit character for converting
 * @param base for converting
 * @return converted symbol
 * @return -1 if error
 */
int ch_to_digit(char ch, int base) {
	ch = toupper(ch);
	switch (base) {
	case 16: {
		if (ch >= '0' && ch <= '9') {
			return (ch - '0');
		} else if (ch >= 'A' && ch <= 'F') {
			return (ch - 'A' + 0x0A);
		}
		return -1;
	}
	case 10: {
		if (ch >= '0' && ch <= '9') {
			return (ch - '0');
		}
		return -1;
	}
	case 8: {
		if (ch >= '0' && ch <= '7') {
			return (ch - '0');
		}
		return -1;
	}
	default:
		return -1;
	}
	return -1;
}

static void unscanchar(const char **str, int ch) {
	if ((unsigned int) str >= 2) {
		(*str) --;
	} else if ((int) str == 1) {
		ungetc(ch, file);
	} else {
		ungetchar(ch);
	}
}

static int scanchar(const char **str) {
	extern int getchar(void);
	int ch;
	if ((unsigned int)str >= 2) {
		ch = **str;
		(*str)++;
		return ch == '\0' ? EOF : ch;
	} else if ((int)str == 1) {
		return getc(file);
	} else {
		if ('\n' == (ch = getchar())) {
			return EOF;
		}
		return ch;
	}
}

static bool is_space(int ch) {<commit_msg>scanf: Fix compilation very weird code<commit_after>/**
 * @file
 * @brief Simple scanf implementation.
 *
 * @date 10.02.09
 * @author <NAME>
 *          - Initial implementation
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <stdbool.h>
#include <fs/file_operation.h>

FILE *file;

/*TODO: throw out.*/
/**
 * convert digit character to integer
 * @param digit character for converting
 * @param base for converting
 * @return converted symbol
 * @return -1 if error
 */
int ch_to_digit(char ch, int base) {
	ch = toupper(ch);
	switch (base) {
	case 16: {
		if (ch >= '0' && ch <= '9') {
			return (ch - '0');
		} else if (ch >= 'A' && ch <= 'F') {
			return (ch - 'A' + 0x0A);
		}
		return -1;
	}
	case 10: {
		if (ch >= '0' && ch <= '9') {
			return (ch - '0');
		}
		return -1;
	}
	case 8: {
		if (ch >= '0' && ch <= '7') {
			return (ch - '0');
		}
		return -1;
	}
	default:
		return -1;
	}
	return -1;
}

static void unscanchar(const char **str, int ch) {
	if ((uintptr_t) str >= 2) {
		(*str) --;
	} else if ((uintptr_t) str == 1) {
		ungetc(ch, file);
	} else {
		ungetchar(ch);
	}
}

static int scanchar(const char **str) {
	extern int getchar(void);
	int ch;
	if ((uintptr_t)str >= 2) {
		ch = **str;
		(*str)++;
		return ch == '\0' ? EOF : ch;
	} else if ((uintptr_t)str == 1) {
		return getc(file);
	} else {
		if ('\n' == (ch = getchar())) {
			return EOF;
		}
		return ch;
	}
}

static bool is_space(int ch) {
{'fraction_non_alphanumeric': 0.2012215812690872, 'fraction_numerical': 0.022395656599932135, 'mean_word_length': 2.7222222222222223, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, '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': '1337171', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1211, 'n_words': 353}