<commit_before>#include "iobuf.h"

int ibuf_gets(ibuf* in, char* data, unsigned datalen, char boundary)
{
  iobuf* io;
  io = &in->io;
  in->count = 0;
  while (datalen) {
    if (io->bufstart >= io->buflen) ibuf_refill(in);
    if (ibuf_eof(in) || ibuf_error(in)) break;
    in->count++;
    if ((*data++ = io->buffer[io->bufstart++]) == boundary) return 1;
  }
  return ibuf_eof(in);
}<commit_msg>Take into account timeout in refill. Simplified some logic.<commit_after>#include "iobuf.h"

int ibuf_gets(ibuf* in, char* data, unsigned datalen, char boundary)
{
  iobuf* io;
  int ch;
  
  io = &in->io;
  in->count = 0;
  while (datalen) {
    if (io->bufstart >= io->buflen) ibuf_refill(in);
    if (ibuf_timedout(in)) return 0;
    if (ibuf_eof(in) || ibuf_error(in)) break;
    in->count++;
    ch = io->buffer[io->bufstart++];
    *data++ = ch;
    if (ch == boundary) return 1;
  }
  return ibuf_eof(in);
}
{'fraction_non_alphanumeric': 0.18072289156626506, 'fraction_numerical': 0.00547645125958379, 'mean_word_length': 3.5247524752475248, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '6566157', 'n_tokens_mistral': 386, 'n_tokens_neox': 375, 'n_words': 89}