<commit_before>/*
Copyright (c), Helios
All rights reserved.

Distributed under a permissive license. See COPYING.txt for details.
*/

#include "stdafx.h"
#include "BoundedStreamFilter.h"

std::streamsize BoundedInputFilter::read(char *output, std::streamsize length){
	length = std::min(length, this->simulated_length - this->bytes_read);
	auto head = output;
	std::streamsize ret = 0;
	bool bad = false;
	while (length){
		auto temp = this->next_read(output, length);
		if (temp < 0){
			bad = true;
			break;
		}
		ret += temp;
		output = (char *)output + temp;
		length -= temp;
	}
	this->bytes_read += ret;
	return !ret && bad ? -1 : ret;
}
<commit_msg>Added missing EOF check in BoundedInputFilter::read().<commit_after>/*
Copyright (c), Helios
All rights reserved.

Distributed under a permissive license. See COPYING.txt for details.
*/

#include "stdafx.h"
#include "BoundedStreamFilter.h"

std::streamsize BoundedInputFilter::read(char *output, std::streamsize length){
	if (this->bytes_read == this->simulated_length)
		return -1;
	length = std::min(length, this->simulated_length - this->bytes_read);
	auto head = output;
	std::streamsize ret = 0;
	bool bad = false;
	while (length){
		auto temp = this->next_read(output, length);
		if (temp < 0){
			bad = true;
			break;
		}
		ret += temp;
		output = (char *)output + temp;
		length -= temp;
	}
	this->bytes_read += ret;
	return !ret && bad ? -1 : ret;
}

{'fraction_non_alphanumeric': 0.14150304671631686, 'fraction_numerical': 0.004739336492890996, 'mean_word_length': 3.4119402985074627, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7630657', 'n_tokens_mistral': 530, 'n_tokens_neox': 506, 'n_words': 140}