<commit_before>#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#endif // _WIN32

#ifdef linux
#include <stdlib.h>
#endif // linux

#include "liblog.h"


#ifdef _WIN32
#define _SysPause() system("pause")
#else
#define _SysPause() system("");
#endif

void check(unsigned int n, unsigned int m, char* p)
{
	if (m != n)
		WriteLog(FC_RED, STDOUT_FILE_HANDLE, "(%s) >> error  m(%05d) != n(%05d).", p, m, n);
}

struct Buffer
{
	char* pBuffer;
	char* pBegin;
	char* pTail;
	char* pRead;
	char* pWrite;

public:
	Buffer()
	{
		pBuffer = new char[10251];
		pRead = pWrite = pBegin = pBuffer;
		pTail = pBuffer + 10251;
	}

	~Buffer()
	{
		delete [] pBuffer;
		pRead = pWrite = pBegin = pTail = pBuffer = NULL;
	}
public:
	char* Read()
	{
		if (pRead == pWrite)
			return NULL;

		int nLen = pWrite - pRead;
		check(nLen, pWrite - pRead, "1");
		char* pBuf = new char[nLen+1];
		check(nLen, pWrite - pRead, "2");
		memset(pBuf, 0, nLen+1);
		check(nLen, pWrite - pRead, "3");
		memcpy(pBuf, pRead, nLen);
		check(nLen, pWrite - pRead, "4");
		pRead += nLen;	
		WriteLog(FC_BLUE, STDOUT_FILE_HANDLE, "-------------------------------------------------------");

		return pBuf;
	}

	bool Write(char* pData, unsigned int nLen)
	{
		unsigned int nLeft = pTail - pWrite;
		if (nLeft <= 0)
			return false;

		if (nLeft < nLen)
			nLen = nLeft;

		memcpy(pWrite, pData, nLen);
		pWrite += nLen;
		return true;
	}
};


void WorkThread(LPWORD pParam)
{
	Buffer* pBuf = (Buffer*) pParam;
	char data[32];

	int a = 0;
	while (true)
	{
		memset(data, 0, 32);
		sprintf_s(data, 32, "%03d >> add new data.", a++);
		pBuf->Write(data, strlen(data));

		Sleep(33);
	}
}

int main()
{
	Buffer buf;
	HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, &buf, 0, 0);

	while (true)
	{
		char* pReadData = buf.Read();
		if (pReadData)
			WriteLog(FC_GREEN, STDOUT_FILE_HANDLE, pReadData);

		Sleep(55);
	}

	return 1;
}<commit_msg>reset test/main.cpp to old<commit_after>#ifdef _WIN32
#include <windows.h>
#endif // _WIN32

#ifdef linux
#include <stdlib.h>
#endif // linux

#include "liblog.h"
#ifdef _WIN32
#define _SysPause() system("pause")
#else
#define _SysPause() system("");
#endif

int main()
{
	_FILE_HANDLE fh = OpenNewLogFile("./test.log", true);
	_FILE_HANDLE fh2 = OpenNewLogFile("./test_no_std.log", false);

	if (fh == STDOUT_FILE_HANDLE)
	{
		WriteLog(FC_RED, STDOUT_FILE_HANDLE, "fh == STDOUT_FILE_HANDLE (./test.log)");
		_SysPause();
		return 0;
	}

	if (fh2 == STDOUT_FILE_HANDLE)
	{
		WriteLog(FC_RED, STDOUT_FILE_HANDLE, "fh2 == STDOUT_FILE_HANDLE (./test_no_std.log)");
		_SysPause();
		return 0;
	}
	int a = 0;
	int b = 0;

	WriteLog(FC_GREEN, fh, "<< fh write new log (%d).", a++);
	WriteLog(FC_GREEN, fh2, ">> fh2 write new log (%d).", b++);

	CloseLogFile(fh);

	WriteLog(FC_RED, fh, "<< fh write new log (%d).", a++);
	WriteLog(FC_RED, fh2, ">> fh2 write new log (%d).", b++);

	FlushLogFile(fh);
	FlushLogFile(fh2);

	//printf("123123123123123.\n");

	_SysPause();

	return 1;
}
{'fraction_non_alphanumeric': 0.19028609447771125, 'fraction_numerical': 0.02661343978709248, 'mean_word_length': 3.569908814589666, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 17, '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': '7506126', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1266, 'n_words': 308}