<commit_before>#include <ber_decoder.c>
#include <ber_tlv_length.c>
#include <ber_tlv_tag.c>
#include <der_encoder.c>
#include <constraints.c>
#undef	ADVANCE
#undef	RETURN
#undef	LEFT
#include <OCTET_STRING.c>


uint8_t *buf;
size_t buf_size;
size_t buf_off;

static int
write_to_buf(const void *buffer, size_t size, void *key) {
	(void)key;

	if(buf_off + size > buf_size) {
		size_t n = buf_size?:16;
		while(n < buf_off + size) n <<= 2;
		buf = realloc(buf, n);
		assert(buf);
		buf_size = n;
	}

	memcpy(buf + buf_off, buffer, size);

	buf_off += size;
	return 0;
}


static void
check(int size) {
	OCTET_STRING_t *os;
	OCTET_STRING_t *nos = 0;
	der_enc_rval_t erval;
	ber_dec_rval_t rval;
	int i;

	os = OCTET_STRING_new_fromBuf(0, size);
	assert(os);
	assert(os->size == 0);

	os->buf = malloc(size);
	assert(os->buf);
	os->size = size;

	for(i = 0; i < size; i++) {
		os->buf[i] = i;
	}

	buf_off = 0;
	erval = der_encode(&asn1_DEF_OCTET_STRING,
		os, write_to_buf, 0);
	assert(erval.encoded == buf_off);
	assert(buf_off > size);

	rval = ber_decode(&asn1_DEF_OCTET_STRING, &nos, buf, buf_off);
	assert(rval.code == RC_OK);
	assert(rval.consumed == buf_off);
<commit_msg>portability<commit_after>#include <ber_decoder.c>
#include <ber_tlv_length.c>
#include <ber_tlv_tag.c>
#include <der_encoder.c>
#include <constraints.c>
#undef	ADVANCE
#undef	RETURN
#undef	LEFT
#include <OCTET_STRING.c>


uint8_t *buf;
size_t buf_size;
size_t buf_off;

static int
write_to_buf(const void *buffer, size_t size, void *key) {
	(void)key;

	if(buf_off + size > buf_size) {
		size_t n = buf_size?:16;
		while(n < buf_off + size) n <<= 2;
		buf = realloc(buf, n);
		assert(buf);
		buf_size = n;
	}

	memcpy(buf + buf_off, buffer, size);

	buf_off += size;
	return 0;
}


static void
check(int size) {
	OCTET_STRING_t *os;
	OCTET_STRING_t *nos = 0;
	der_enc_rval_t erval;
	ber_dec_rval_t rval;
	int i;

	os = OCTET_STRING_new_fromBuf(0, size);
	assert(os);
	assert(os->size == 0);

	os->buf = malloc(size);
	assert(os->buf);
	os->size = size;

	for(i = 0; i < size; i++) {
		os->buf[i] = i;
	}

	buf_off = 0;
	erval = der_encode(&asn1_DEF_OCTET_STRING,
		os, write_to_buf, 0);
	assert(erval.encoded == buf_off);
	assert(buf_off > size);

	rval = ber_decode(&asn1_DEF_OCTET_STRING, (void **)&nos, buf, buf_off);
	assert(rval.code == RC_OK);
	assert(rval.consumed == buf_off);

{'fraction_non_alphanumeric': 0.15488785442234448, 'fraction_numerical': 0.011002962336013541, 'mean_word_length': 4.5754716981132075, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, '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': '946689', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1056, 'n_words': 225}