<commit_before>/*
 * fillbuf.c - fill a buffer
 */
/* $Header$ */

#include	<stdio.h>
#include	<stdlib.h>
#include	"loc_incl.h"

int _read(int d, char *buf, int nbytes);

int
__fillbuf(register FILE *stream)
{
	static unsigned char ch[FOPEN_MAX];
	register int i;

	stream->_count = 0;
	if (fileno(stream) < 0) return EOF;
	if (io_testflag(stream, (_IOEOF | _IOERR ))) return EOF; 
	if (!io_testflag(stream, _IOREAD)) return EOF;
	if (io_testflag(stream, _IOWRITING)) return EOF;

	if (!io_testflag(stream, _IOREADING))
		stream->_flags |= _IOREADING;
	
	if (!io_testflag(stream, _IONBF) && !stream->_buf) {
		stream->_buf = (unsigned char *) malloc(BUFSIZ);
		if (!stream->_buf) {
			stream->_flags |= _IONBF;
		}
		else {
			stream->_flags |= _IOMYBUF;
			stream->_bufsiz = BUFSIZ;<commit_msg>Fix: set error flag in some error cases<commit_after>/*
 * fillbuf.c - fill a buffer
 */
/* $Header$ */

#include	<stdio.h>
#include	<stdlib.h>
#include	"loc_incl.h"

int _read(int d, char *buf, int nbytes);

int
__fillbuf(register FILE *stream)
{
	static unsigned char ch[FOPEN_MAX];
	register int i;

	stream->_count = 0;
	if (fileno(stream) < 0) return EOF;
	if (io_testflag(stream, (_IOEOF | _IOERR ))) return EOF; 
	if (!io_testflag(stream, _IOREAD)) {
		stream->_flags |= _IOERR;
		return EOF;
	}
	if (io_testflag(stream, _IOWRITING)) {
		stream->_flags |= _IOERR;
		return EOF;
	}

	if (!io_testflag(stream, _IOREADING))
		stream->_flags |= _IOREADING;
	
	if (!io_testflag(stream, _IONBF) && !stream->_buf) {
		stream->_buf = (unsigned char *) malloc(BUFSIZ);
		if (!stream->_buf) {
			stream->_flags |= _IONBF;
		}
		else {
			stream->_flags |= _IOMYBUF;
			stream->_bufsiz = BUFSIZ;
{'fraction_non_alphanumeric': 0.16073546856465007, 'fraction_numerical': 0.002372479240806643, 'mean_word_length': 4.112121212121212, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, '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': '229957', 'n_tokens_mistral': 709, 'n_tokens_neox': 671, 'n_words': 160}