<commit_before>/**
 * Statistic events
 * @date 3.9.2006
 * @author <NAME>
 * @cvs-id $Id$
 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <assert.h>
#include <string.h>

#include "bestatevent.h"

#define STACK_SIZE 16

typedef struct {
	FILE *f;
	char tag[512];
} ev_env_t;

static ev_env_t envs[STACK_SIZE];
static unsigned sp = 0;

void be_stat_ev_push(const char **tags, int n_tags, FILE *f)
{
	int i;
	ev_env_t *env;

	assert(sp < STACK_SIZE && "stat event stack full");
	env = &envs[sp++];

	env->tag[0] = '\0';
	for(i = 0; i < n_tags; ++i) {
		strncat(env->tag, tags[i], sizeof(env->tag));
		strncat(env->tag, ";", sizeof(env->tag));
	}
	env->tag[sizeof(env->tag) - 1] = '\0';
	env->f = f;
}

void be_stat_ev_pop(void)
{
	if(sp == 0)
		return;

	envs[--sp].f = NULL;
}

void be_stat_ev(const char *ev, int value)
{
	if(sp == 0)
		return;

	ev_env_t *env = &envs[sp - 1];
	if(env->f == NULL)
		return;

	fprintf(env->f, "%s%s;%d\n", env->tag, ev, value);
}

void be_stat_ev_l(const char *ev, long value)
{
	if(sp == 0)
		return;

	ev_env_t *env = &envs[sp - 1];
	if(env->f == NULL)
		return;

	fprintf(env->f, "%s%s;%ld\n", env->tag, ev, value);
}

void be_stat_ev_dbl(const char *ev, double value)
{
	if(sp == 0)
		return;

	ev_env_t *env = &envs[sp - 1];
	if(env->f == NULL)
		return;

	fprintf(env->f, "%s%s;%f\n", env->tag, ev, value);
}

void be_stat_ev_ull(const char *ev, ulong64 value)
{
	if(sp == 0)
		return;

	ev_env_t *env = &envs[sp - 1];
	if(env->f == NULL)<commit_msg>fixed C99 stuff<commit_after>/**
 * Statistic events
 * @date 3.9.2006
 * @author <NAME>
 * @cvs-id $Id$
 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <assert.h>
#include <string.h>

#include "bestatevent.h"

#define STACK_SIZE 16

typedef struct {
	FILE *f;
	char tag[512];
} ev_env_t;

static ev_env_t envs[STACK_SIZE];
static unsigned sp = 0;

void be_stat_ev_push(const char **tags, int n_tags, FILE *f)
{
	int i;
	ev_env_t *env;

	assert(sp < STACK_SIZE && "stat event stack full");
	env = &envs[sp++];

	env->tag[0] = '\0';
	for(i = 0; i < n_tags; ++i) {
		strncat(env->tag, tags[i], sizeof(env->tag));
		strncat(env->tag, ";", sizeof(env->tag));
	}
	env->tag[sizeof(env->tag) - 1] = '\0';
	env->f = f;
}

void be_stat_ev_pop(void)
{
	if (sp == 0)
		return;

	envs[--sp].f = NULL;
}

void be_stat_ev(const char *ev, int value)
{
	ev_env_t *env;

	if (sp == 0)
		return;

	env = &envs[sp - 1];
	if (env->f == NULL)
		return;

	fprintf(env->f, "%s%s;%d\n", env->tag, ev, value);
}

void be_stat_ev_l(const char *ev, long value)
{
	ev_env_t *env;

	if (sp == 0)
		return;

	env = &envs[sp - 1];
	if (env->f == NULL)
		return;

	fprintf(env->f, "%s%s;%ld\n", env->tag, ev, value);
}

void be_stat_ev_dbl(const char *ev, double value)
{
	ev_env_t *env;

	if (sp == 0)
		return;

	env = &envs[sp - 1];
	if (env->f == NULL)
		return;

	fprintf(env->f, "%s%s;%f\n", env->tag, ev, value);
}

void be_stat_ev_ull(const char *ev, ulong64 value)
{
	ev_env_t *env;

	if (sp == 0)
		return;

	env = &envs[sp - 1];
	if (env->f == NULL)
{'fraction_non_alphanumeric': 0.20689655172413793, 'fraction_numerical': 0.01904761904761905, 'mean_word_length': 3.5735735735735736, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 45, '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': '5481237', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1422, 'n_words': 332}