<commit_before>/*
	CopyLib.exe DIR oDIR

		DIR, oDIR ... ݂fBNgł邱ƁB
*/

#include "C:\Factory\Common\all.h"

static autoList_t *ResAutoComment;

static void AutoComment(autoList_t *ranges)
{
	autoList_t *range;
	uint range_index;
	int commentEntered = 0;
	int classEntered = 0;

	foreach(ranges, range, range_index)
	{
		char *line;
		uint index;

		foreach(range, line, index)
		{
			int insCmt;

			line = strx(line);
			nn_strstr(line, "//")[0] = '\0'; // CCRg̏
			trimTrail(line, ' ');

			if(startsWith(line, "class "))
				classEntered = 1;

			if(!strcmp(line, "};"))
				classEntered = 0;

			if(!strcmp(line, "}"))
				classEntered = 0;

			// set insCmt >

			if(classEntered)
			{
				insCmt = line[0] == '\t' && (m_isalpha(line[1]) || line[1] == '_' || line[1] == '~');

				if(startsWith(line, "#define "))
					insCmt = 1;

				if(index && !strcmp(getLine(range, index - 1), "\t*/"))
					insCmt = 0;

				if(index && startsWith(getLine(range, index - 1), "#define "))
					insCmt = 0;

				if(!strcmp(line, "\t/*"))
					insCmt = 1;
			}
			else
			{
				insCmt = m_isalpha(line[0]) || line[0] == '_';

				if(startsWith(line, "#define "))
					insCmt = 1;

				if(index && !strcmp(getLine(range, index - 1), "}") && endsWith(line, ";")) // typedef Ȃ
					insCmt = 0;

				if(index && !strcmp(getLine(range, index - 1), "*/"))
					insCmt = 0;

				if(index && startsWith(getLine(range, index - 1), "template <"))
					insCmt = 0;

				if(!strcmp(line, "/*"))
					insCmt = 1;
			}

			if(endsWith(line, ":"))
				insCmt = 0;

			if(commentEntered)
				insCmt = 0;

			if(!range_index && !index)
				insCmt = 1;

			// < set insCmt

			if(insCmt)
			{
				char *comment;
				uint comment_index;

				foreach(ResAutoComment, comment, comment_index)
				{
					insertElement(range, index++, (uint)xcout("%s%s", classEntered ? "\t" : "", comment));
				}
			}

			{
				char *tmp = strx(getLine(range, index));
//				char *tmp = strx(line); // CCRg폜Ă̂ng

				ucTrim(tmp);

				if(commentEntered)
				{
					if(!strcmp(tmp, "*/"))
						commentEntered = 0;

					if(!strcmp(tmp, "//*/")) // LOG_ENABLED ƂƂ /* ` /*/ ` //*/
						commentEntered = 0;
				}
				else
				{
					if(!strcmp(tmp, "/*"))
						commentEntered = 1;
				}
				memFree(tmp);
			}

			memFree(line);
		}
	}
	errorCase(commentEntered);
	errorCase(classEntered);
}
static autoList_t *ReadCommonAndAppSpecRanges(char *file)
{
	autoList_t *ranges = newList();
	autoList_t *lines = newList();
	FILE *fp = fileOpen(file, "rt");<commit_msg>coffee break<commit_after>/*
	CopyLib.exe DIR oDIR

		DIR, oDIR ... ݂fBNgł邱ƁB
*/

#include "C:\Factory\Common\all.h"

static autoList_t *ResAutoComment;

static void AutoComment(autoList_t *ranges)
{
	autoList_t *range;
	uint range_index;
	char *line;
	uint index;
	int commentEntered = 0;
	int classEntered = 0;

	foreach(ranges, range, range_index)
	foreach(range, line, index)
	{
		int insCmt;

		line = strx(line);
		nn_strstr(line, "//")[0] = '\0'; // CCRg̏
		trimTrail(line, ' ');

		if(startsWith(line, "class "))
			classEntered = 1;

		if(!strcmp(line, "};"))
			classEntered = 0;

		if(!strcmp(line, "}"))
			classEntered = 0;

		// set insCmt >

		if(classEntered)
		{
			insCmt = line[0] == '\t' && (m_isalpha(line[1]) || line[1] == '_' || line[1] == '~');

			if(startsWith(line, "#define "))
				insCmt = 1;

			if(index && !strcmp(getLine(range, index - 1), "\t*/"))
				insCmt = 0;

			if(index && startsWith(getLine(range, index - 1), "#define "))
				insCmt = 0;

			if(!strcmp(line, "\t/*"))
				insCmt = 1;
		}
		else
		{
			insCmt = m_isalpha(line[0]) || line[0] == '_';

			if(startsWith(line, "#define "))
				insCmt = 1;

			if(index && !strcmp(getLine(range, index - 1), "}") && endsWith(line, ";")) // typedef Ȃ
				insCmt = 0;

			if(index && !strcmp(getLine(range, index - 1), "*/"))
				insCmt = 0;

			if(index && startsWith(getLine(range, index - 1), "template <"))
				insCmt = 0;

			if(!strcmp(line, "/*"))
				insCmt = 1;
		}

		if(endsWith(line, ":"))
			insCmt = 0;

		if(commentEntered)
			insCmt = 0;

		if(!range_index && !index)
			insCmt = 1;

		// < set insCmt

		if(insCmt)
		{
			char *comment;
			uint comment_index;

			foreach(ResAutoComment, comment, comment_index)
			{
				insertElement(range, index++, (uint)xcout("%s%s", classEntered ? "\t" : "", comment));
			}
		}

		{
			char *tmp = strx(getLine(range, index));
//			char *tmp = strx(line); // CCRg폜Ă̂ng

			ucTrim(tmp);

			if(commentEntered)
			{
				if(!strcmp(tmp, "*/"))
					commentEntered = 0;

				if(!strcmp(tmp, "//*/")) // LOG_ENABLED ƂƂ /* ` /*/ ` //*/
					commentEntered = 0;
			}
			else
			{
				if(!strcmp(tmp, "/*"))
					commentEntered = 1;
			}
			memFree(tmp);
		}

		memFree(line);
	}
	errorCase(commentEntered);
	errorCase(classEntered);
}
static autoList_t *ReadCommonAndAppSpecRanges(char *file)
{
	autoList_t *ranges = newList();
	autoList_t *lines = newList();
	FILE *fp = fileOpen(file, "rt");
{'fraction_non_alphanumeric': 0.1959117587532888, 'fraction_numerical': 0.013357619914996965, 'mean_word_length': 2.842923794712286, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 5, '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': '4508484', 'n_tokens_mistral': 2458, 'n_tokens_neox': 2018, 'n_words': 370}