<commit_before>/*
 * stopword library
 * <NAME> <<EMAIL>>
 */
#include "postgres.h"

#include "common.h"
#include "dict.h"
#include "ts_locale.h"

#define STOPBUFLEN	4096

void
freestoplist(StopList * s)
{
	char	  **ptr = s->stop;

	if (ptr)
		while (*ptr && s->len > 0)
		{
			free(*ptr);
			ptr++;
			s->len--;
			free(s->stop);
		}
	memset(s, 0, sizeof(StopList));
}

void
readstoplist(text *in, StopList * s)
{
	char	  **stop = NULL;

	s->len = 0;
	if (in && VARSIZE(in) - VARHDRSZ > 0)
	{
		char	   *filename = to_absfilename(text2char(in));
		FILE	   *hin;
		char		buf[STOPBUFLEN], *pbuf;
		int			reallen = 0;

		if ((hin = fopen(filename, "r")) == NULL)
			ereport(ERROR,
					(errcode(ERRCODE_CONFIG_FILE_ERROR),
					 errmsg("could not open file \"%s\": %m",
							filename)));

		while (fgets(buf, sizeof(buf), hin))
		{
			pbuf = buf;
			while( *pbuf && !isspace( *pbuf ) )
				pbuf++;
			*pbuf = '\0';

			pg_verifymbstr(buf, strlen(buf), false);
			if (*buf == '\0' || *buf=='\n' || *buf=='\r')
				continue;

			if (s->len >= reallen)
			{
				char	  **tmp;

				reallen = (reallen) ? reallen * 2 : 16;
				tmp = (char **) realloc((void *) stop, sizeof(char *) * reallen);
				if (!tmp)
				{
					freestoplist(s);<commit_msg>Fix unportable use of isspace(), per buildfarm results.<commit_after>/*
 * stopword library
 * <NAME> <<EMAIL>>
 */
#include "postgres.h"

#include "common.h"
#include "dict.h"
#include "ts_locale.h"

#define STOPBUFLEN	4096

void
freestoplist(StopList * s)
{
	char	  **ptr = s->stop;

	if (ptr)
		while (*ptr && s->len > 0)
		{
			free(*ptr);
			ptr++;
			s->len--;
			free(s->stop);
		}
	memset(s, 0, sizeof(StopList));
}

void
readstoplist(text *in, StopList * s)
{
	char	  **stop = NULL;

	s->len = 0;
	if (in && VARSIZE(in) - VARHDRSZ > 0)
	{
		char	   *filename = to_absfilename(text2char(in));
		FILE	   *hin;
		char		buf[STOPBUFLEN], *pbuf;
		int			reallen = 0;

		if ((hin = fopen(filename, "r")) == NULL)
			ereport(ERROR,
					(errcode(ERRCODE_CONFIG_FILE_ERROR),
					 errmsg("could not open file \"%s\": %m",
							filename)));

		while (fgets(buf, sizeof(buf), hin))
		{
			pbuf = buf;
			while( *pbuf && !isspace((unsigned char) *pbuf ) )
				pbuf++;
			*pbuf = '\0';

			pg_verifymbstr(buf, strlen(buf), false);
			if (*buf == '\0' || *buf=='\n' || *buf=='\r')
				continue;

			if (s->len >= reallen)
			{
				char	  **tmp;

				reallen = (reallen) ? reallen * 2 : 16;
				tmp = (char **) realloc((void *) stop, sizeof(char *) * reallen);
				if (!tmp)
				{
					freestoplist(s);
{'fraction_non_alphanumeric': 0.20086648286727057, 'fraction_numerical': 0.011815675462780622, 'mean_word_length': 2.8719512195121952, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 27, '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': '4009830', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1060, 'n_words': 239}