<commit_before>/**
  * Touhou Community Reliant Automatic Patcher
  * Main DLL
  *
  * ----
  *
  * Breakpoints for contiguous files.
  */

#include "thcrap.h"
#include <map>

#define POST_JSON_SIZE(fr) (fr)->pre_json_size + (fr)->patch_size

int file_rep_init(file_rep_t *fr, const char *file_name)
{
	size_t fn_len;

	if (fr->name) {
		file_rep_clear(fr);
	}
	fn_len = strlen(file_name) + 1;
	fr->name = EnsureUTF8(file_name, fn_len);
	fr->rep_buffer = stack_game_file_resolve(fr->name, &fr->pre_json_size);
	fr->offset = -1;
	fr->hooks = patchhooks_build(fr->name);
	if (fr->hooks) {
		size_t diff_fn_len = fn_len + strlen(".jdiff") + 1;
		size_t diff_size = 0;
		VLA(char, diff_fn, diff_fn_len);
		strcpy(diff_fn, fr->name);
		strcat(diff_fn, ".jdiff");
		fr->patch = stack_game_json_resolve(diff_fn, &diff_size);
		VLA_FREE(diff_fn);
		fr->patch_size += diff_size;
	}
	return 1;
}

static int file_rep_hooks_run(file_rep_t *fr)
{
	return patchhooks_run(
		fr->hooks, fr->game_buffer, POST_JSON_SIZE(fr), fr->pre_json_size, fr->patch
	);
}
<commit_msg>file_rep_init: use the correct lenght for the jdiff buffer path.<commit_after>/**
  * Touhou Community Reliant Automatic Patcher
  * Main DLL
  *
  * ----
  *
  * Breakpoints for contiguous files.
  */

#include "thcrap.h"
#include <map>

#define POST_JSON_SIZE(fr) (fr)->pre_json_size + (fr)->patch_size

int file_rep_init(file_rep_t *fr, const char *file_name)
{
	size_t fn_len;

	if (fr->name) {
		file_rep_clear(fr);
	}
	fn_len = strlen(file_name) + 1;
	fr->name = EnsureUTF8(file_name, fn_len);
	fr->rep_buffer = stack_game_file_resolve(fr->name, &fr->pre_json_size);
	fr->offset = -1;
	fr->hooks = patchhooks_build(fr->name);
	if (fr->hooks) {
		size_t diff_fn_len = strlen(fr->name) + strlen(".jdiff") + 1;
		size_t diff_size = 0;
		VLA(char, diff_fn, diff_fn_len);
		strcpy(diff_fn, fr->name);
		strcat(diff_fn, ".jdiff");
		fr->patch = stack_game_json_resolve(diff_fn, &diff_size);
		VLA_FREE(diff_fn);
		fr->patch_size += diff_size;
	}
	return 1;
}

static int file_rep_hooks_run(file_rep_t *fr)
{
	return patchhooks_run(
		fr->hooks, fr->game_buffer, POST_JSON_SIZE(fr), fr->pre_json_size, fr->patch
	);
}

{'fraction_non_alphanumeric': 0.15554532903819604, 'fraction_numerical': 0.005522319374137137, 'mean_word_length': 4.517766497461929, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, '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': '884701', 'n_tokens_mistral': 955, 'n_tokens_neox': 919, 'n_words': 169}