<commit_before>/* MIT (C) pancake (at) nopcode (dot) org - 2009-2019 */

#include "spp.h"
#include "r_api.h"
#include "config.h"

S_API int spp_run(char *buf, Output *out) {
	int i, ret = 0;
	char *tok;

	D fprintf (stderr, "SPP_RUN(%s)\n", buf);
	if (proc->chop) {
		for (; IS_SPACE (*buf); buf++);
		int buflen = strlen (buf);
		for (tok = buf + (buflen? buflen - 1: 0); IS_SPACE (*tok); tok--) {
			*tok = '\0';
		}
	}

	if (proc->token) {
		tok = strstr (buf, proc->token);
		if (tok) {
			*tok = '\0';
			tok = tok + 1;
		} else {
			tok = buf;
		}
	} else {
		tok = buf;
	}
	for (i = 0; tags[i].callback; i++) {
		D fprintf (stderr, "NAME=(%s)\n", tok);
		if ((!tags[i].name) || (!strcmp (buf, tags[i].name))) {
			if (out->fout) {
				fflush (out->fout);
			}
			ret = tags[i].callback (&proc->state, out, tok);
			proc->state.ifl += ret;
			if (ret == -1) {
				break;
			}
			if (ret) {

				if (proc->state.ifl < 0 || proc->state.ifl >= MAXIFL) {
					fprintf (stderr, "Nested conditionals parsing error.\n");
					break;
				}
			}
			break;
		}
	}
	return ret;
}

static char *spp_run_str(char *buf, int *rv) {
	char *b;
	Output tmp;
	tmp.fout = NULL;
	tmp.cout = r_strbuf_new ("");
	int rc = spp_run (buf, &tmp);
	b = strdup (r_strbuf_get (tmp.cout));
	r_strbuf_free (tmp.cout);
	if (rv) {
		*rv = rc;
	}
	return b;<commit_msg>Aim to fix the spp r_util build dependency<commit_after>/* MIT (C) pancake (at) nopcode (dot) org - 2009-2019 */

#include "spp.h"
#if USE_R2
#include <r_util.h>
#else
#include "r_api.h"
#endif
#include "config.h"

S_API int spp_run(char *buf, Output *out) {
	int i, ret = 0;
	char *tok;

	D fprintf (stderr, "SPP_RUN(%s)\n", buf);
	if (proc->chop) {
		for (; IS_SPACE (*buf); buf++);
		int buflen = strlen (buf);
		for (tok = buf + (buflen? buflen - 1: 0); IS_SPACE (*tok); tok--) {
			*tok = '\0';
		}
	}

	if (proc->token) {
		tok = strstr (buf, proc->token);
		if (tok) {
			*tok = '\0';
			tok = tok + 1;
		} else {
			tok = buf;
		}
	} else {
		tok = buf;
	}
	for (i = 0; tags[i].callback; i++) {
		D fprintf (stderr, "NAME=(%s)\n", tok);
		if ((!tags[i].name) || (!strcmp (buf, tags[i].name))) {
			if (out->fout) {
				fflush (out->fout);
			}
			ret = tags[i].callback (&proc->state, out, tok);
			proc->state.ifl += ret;
			if (ret == -1) {
				break;
			}
			if (ret) {
				if (proc->state.ifl < 0 || proc->state.ifl >= MAXIFL) {
					fprintf (stderr, "Nested conditionals parsing error.\n");
					break;
				}
			}
			break;
		}
	}
	return ret;
}

static char *spp_run_str(char *buf, int *rv) {
	char *b;
	Output tmp;
	tmp.fout = NULL;
	tmp.cout = r_strbuf_new ("");
	int rc = spp_run (buf, &tmp);
	b = strdup (r_strbuf_get (tmp.cout));
	r_strbuf_free (tmp.cout);
	if (rv) {
		*rv = rc;
	}
	return b;
{'fraction_non_alphanumeric': 0.20966569767441862, 'fraction_numerical': 0.012718023255813954, 'mean_word_length': 2.7202702702702704, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 24, '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': '24617', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1216, 'n_words': 314}