<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <confuse.h>
#include <sys/utsname.h>

struct source_section {
	bool bootstrap;			/* optional */
	bool create_wrksrc;		/* optional */
	bool disable_pbuild;		/* optional */
	bool disable_asneeded;		/* optional */
	bool noextract;			/* optional */
	bool nofetch;			/* optional */
	const char *source;
	const char *version;
	const char *revision;
	const char *homepage;
	const char *maintainer;
	const char *license;
	const char *description;
	const char *build_style;	/* optional */
	const char *build_requires;	/* optional */
	const char *wrksrc;		/* optional */
	const char *build_wrksrc;	/* optional */
	const char *conf_script;	/* optional */
	const char *patch_args;		/* optional */
	const char *required_abi;	/* optional */
};

struct pkg_section {
	bool noarch;			/* optional */
	bool nostrip;			/* optional */
	bool nonfree;			/* optional */
	bool noverifyrdeps;		/* optional */
	bool preserve;			/* optional */
	const char *pkgname;
	const char *desc;
	const char *arch;		/* optional */
	const char *makedirs;		/* optional */
	/* package specific */
	const char *sgml_catalogs;	/* optional */
	const char *xml_catalogs;	/* optional */
	const char *sgml_entries;	/* optional */
	const char *xml_entries;	/* optional */
};

static bool
get_bool(cfg_t *cfg, const char *name)
{
	bool prop;

	prop = cfg_getbool(cfg, name);
	if (prop)
		printf("%s: %s\n", name, prop ? "true" : "false");

	return prop;
}

static const char *
get_string(cfg_t *cfg, const char *name, bool mandatory)
{
	const char *prop;

	prop = cfg_getstr(cfg, name);
	if (mandatory && prop == NULL) {
		fprintf(stderr, "%s string is undefined!\n", name);
		exit(EXIT_FAILURE);
	} else if (prop) {
		printf("%s: %s\n", name, prop);
		return prop;
	}

	return NULL;
}

static void
print_strlist(cfg_t *cfg, const char *name, bool show_name)
{
	unsigned int i, size;

	size = cfg_size(cfg, name);
	if (size > 0) {
		if (show_name) printf("%s: ", name);
		for (i = 0; i < size; i++)
			printf("%s ", cfg_getnstr(cfg, name, i));
		if (show_name) printf("\n");
	}
}

static int
validate_mkdeps_section(cfg_t *cfg, cfg_opt_t *opt)
{
	cfg_t *cfgsec;
	unsigned int i;
	bool found = false;

	for (i = 0; i < cfg_size(cfg, "make-depends"); i++) {
		cfgsec = cfg_getnsec(cfg, "make-depends", i);
		if (cfg_size(cfgsec, "all")) {
			found =  true;
			break;
		}
	}
	if (!found) {
		fprintf(stderr, "%s:%d incorrect build template: missing 'all' "
		    "string list in make-depends section.\n",
		    cfg->filename, cfg->line);
		return -1;
	}
	return 0;
}

static int
validate_distfiles_section(cfg_t *cfg, cfg_opt_t *opt)
{
	cfg_t *cfgsec;
	unsigned int i;
	bool found_src = false, found_hash = false;

	for (i = 0; i < cfg_size(cfg, "distfiles"); i++) {
		cfgsec = cfg_getnsec(cfg, "distfiles", i);
		if (cfg_size(cfgsec, "source") > 0)
			found_src =  true;
		if (cfg_size(cfgsec, "sha256") > 0)
			found_hash = true;
	}
	if (!found_src || !found_hash) {
		fprintf(stderr, "%s:%d incorrect build template: missing "
		    "'%s' list in distfiles section.\n",
		    cfg->filename, cfg->line, !found_src ? "source" : "sha256");
		return -1;
	}
	return 0;
}

static int
validate_pkg_section(cfg_t *cfg)
{
	if (cfg_getnsec(cfg, "package", 0) == NULL) {<commit_msg>template.c: fix warnings due to unused args.<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <confuse.h>
#include <sys/utsname.h>

struct source_section {
	bool bootstrap;			/* optional */
	bool create_wrksrc;		/* optional */
	bool disable_pbuild;		/* optional */
	bool disable_asneeded;		/* optional */
	bool noextract;			/* optional */
	bool nofetch;			/* optional */
	const char *source;
	const char *version;
	const char *revision;
	const char *homepage;
	const char *maintainer;
	const char *license;
	const char *description;
	const char *build_style;	/* optional */
	const char *build_requires;	/* optional */
	const char *wrksrc;		/* optional */
	const char *build_wrksrc;	/* optional */
	const char *conf_script;	/* optional */
	const char *patch_args;		/* optional */
	const char *required_abi;	/* optional */
};

struct pkg_section {
	bool noarch;			/* optional */
	bool nostrip;			/* optional */
	bool nonfree;			/* optional */
	bool noverifyrdeps;		/* optional */
	bool preserve;			/* optional */
	const char *pkgname;
	const char *desc;
	const char *arch;		/* optional */
	const char *makedirs;		/* optional */
	/* package specific */
	const char *sgml_catalogs;	/* optional */
	const char *xml_catalogs;	/* optional */
	const char *sgml_entries;	/* optional */
	const char *xml_entries;	/* optional */
};

static bool
get_bool(cfg_t *cfg, const char *name)
{
	bool prop;

	prop = cfg_getbool(cfg, name);
	if (prop)
		printf("%s: %s\n", name, prop ? "true" : "false");

	return prop;
}

static const char *
get_string(cfg_t *cfg, const char *name, bool mandatory)
{
	const char *prop;

	prop = cfg_getstr(cfg, name);
	if (mandatory && prop == NULL) {
		fprintf(stderr, "%s string is undefined!\n", name);
		exit(EXIT_FAILURE);
	} else if (prop) {
		printf("%s: %s\n", name, prop);
		return prop;
	}

	return NULL;
}

static void
print_strlist(cfg_t *cfg, const char *name, bool show_name)
{
	unsigned int i, size;

	size = cfg_size(cfg, name);
	if (size > 0) {
		if (show_name) printf("%s: ", name);
		for (i = 0; i < size; i++)
			printf("%s ", cfg_getnstr(cfg, name, i));
		if (show_name) printf("\n");
	}
}

static int
validate_mkdeps_section(cfg_t *cfg, cfg_opt_t *opt)
{
	cfg_t *cfgsec;
	unsigned int i;
	bool found = false;

	(void)opt;

	for (i = 0; i < cfg_size(cfg, "make-depends"); i++) {
		cfgsec = cfg_getnsec(cfg, "make-depends", i);
		if (cfg_size(cfgsec, "all")) {
			found =  true;
			break;
		}
	}
	if (!found) {
		fprintf(stderr, "%s:%d incorrect build template: missing 'all' "
		    "string list in make-depends section.\n",
		    cfg->filename, cfg->line);
		return -1;
	}
	return 0;
}

static int
validate_distfiles_section(cfg_t *cfg, cfg_opt_t *opt)
{
	cfg_t *cfgsec;
	unsigned int i;
	bool found_src = false, found_hash = false;

	(void)opt;

	for (i = 0; i < cfg_size(cfg, "distfiles"); i++) {
		cfgsec = cfg_getnsec(cfg, "distfiles", i);
		if (cfg_size(cfgsec, "source") > 0)
			found_src =  true;
		if (cfg_size(cfgsec, "sha256") > 0)
			found_hash = true;
	}
	if (!found_src || !found_hash) {
		fprintf(stderr, "%s:%d incorrect build template: missing "
		    "'%s' list in distfiles section.\n",
		    cfg->filename, cfg->line, !found_src ? "source" : "sha256");
		return -1;
	}
	return 0;
}

static int
validate_pkg_section(cfg_t *cfg)
{
	if (cfg_getnsec(cfg, "package", 0) == NULL) {
{'fraction_non_alphanumeric': 0.15873721654068476, 'fraction_numerical': 0.005039276715577293, 'mean_word_length': 3.6505858028945557, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1614558', 'n_tokens_mistral': 2680, 'n_tokens_neox': 2545, 'n_words': 708}