<commit_before>#include <editor.hpp>

#include <kdb.hpp>
#include <modules.hpp>
#include <cmdline.hpp>
#include <external.hpp>
#include <keysetio.hpp>

#include <unistd.h>

#include <export.hpp>
#include <import.hpp>

#include <iostream>
#include <string>

#include <merging/threewaymerge.hpp>
#include <merging/metamergestrategy.hpp>
#include <mergehelper.hpp>

using namespace kdb;
using namespace kdb::tools;
using namespace kdb::tools::merging;
using namespace std;

EditorCommand::EditorCommand()
{
}

EditorCommand::~EditorCommand()
{
}

void EditorCommand::tmpFile()
{
#ifndef _WIN32
	const char * tmpvar = getenv ("TMPDIR");
	if (!tmpvar)
	{
		tmpvar = "/tmp";
	}
	filename = tmpvar;
	filename += "/elektra-test.XXXXXX";
	char * fn = static_cast<char*>(malloc(filename.length()+1));
	strcpy(fn, filename.c_str());
	fd = mkstemp (fn);
	filename = std::string(fn);
	close(fd);
	free (fn);
#endif
}

bool runAllEditors(std::string filename)
{
	using namespace kdb;
	std::string dirname = "/sw/kdb/current/";
	KDB kdb;
	KeySet conf;
	kdb.get(conf, dirname);

	Key k = conf.lookup(dirname+"editor");
	if (k)
	{
		std::string editor = k.get<std::string>().c_str();
		if (runEditor(editor, filename))
		{
			return true;
		} else {<commit_msg>kdb-editor: use new KDB standard<commit_after>#include <editor.hpp>

#include <kdb.hpp>
#include <modules.hpp>
#include <cmdline.hpp>
#include <external.hpp>
#include <keysetio.hpp>

#include <unistd.h>

#include <export.hpp>
#include <import.hpp>

#include <iostream>
#include <string>

#include <merging/threewaymerge.hpp>
#include <merging/metamergestrategy.hpp>
#include <mergehelper.hpp>

using namespace kdb;
using namespace kdb::tools;
using namespace kdb::tools::merging;
using namespace std;

EditorCommand::EditorCommand()
{
}

EditorCommand::~EditorCommand()
{
}

void EditorCommand::tmpFile()
{
#ifndef _WIN32
	const char * tmpvar = getenv ("TMPDIR");
	if (!tmpvar)
	{
		tmpvar = "/tmp";
	}
	filename = tmpvar;
	filename += "/elektra-test.XXXXXX";
	char * fn = static_cast<char*>(malloc(filename.length()+1));
	strcpy(fn, filename.c_str());
	fd = mkstemp (fn);
	filename = std::string(fn);
	close(fd);
	free (fn);
#endif
}

bool runAllEditors(std::string filename)
{
	using namespace kdb;
	std::string dirname = "/sw/elektra/kdb/#0/";
	std::string legacyDirname = "/sw/kdb/current/";
	KDB kdb;
	KeySet conf;
	kdb.get(conf, dirname);
	kdb.get(conf, legacyDirname);

	Key k = conf.lookup(dirname+"current/editor");
	if (!k) k = conf.lookup(dirname+"%/editor");
	if (!k) k = conf.lookup(legacyDirname+"editor");
	if (k)
	{
		std::string editor = k.get<std::string>().c_str();
		if (runEditor(editor, filename))
		{
			return true;
		} else {
{'fraction_non_alphanumeric': 0.17297698589458055, 'fraction_numerical': 0.0025983667409057165, 'mean_word_length': 5.238425925925926, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '5867378', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1027, 'n_words': 221}