#include "util/compile_context.h"
#include "util/container.h"
#include "util/dump_charclass.h"
+#include "util/dump_util.h"
#include "util/graph_range.h"
#include "util/multibit.h"
#include "util/multibit_build.h"
}
}
-/**
- * \brief Helper function: returns a writeable C stdio FILE* handle wrapped in
- * a unique_ptr that takes care of closing the file on destruction.
- */
-static
-std::unique_ptr<FILE, decltype(&fclose)> openStdioFile(const string &filename) {
- return std::unique_ptr<FILE, decltype(&fclose)>(
- fopen(filename.c_str(), "w"), &fclose);
-}
-
static
void dumpComponentInfoCsv(const RoseEngine *t, const string &base) {
- auto f = openStdioFile(base + "/rose_components.csv");
+ auto f = openStdioFile(base + "/rose_components.csv", "w");
fprintf(f.get(), "Index, Offset,Engine Type,States,Stream State,"
"Bytecode Size,Kind,Notes\n");
static
void dumpExhaust(const RoseEngine *t, const string &base) {
- auto f = openStdioFile(base + "/rose_exhaust.csv");
+ auto f = openStdioFile(base + "/rose_exhaust.csv", "w");
const NfaInfo *infos
= (const NfaInfo *)((const char *)t + t->nfaInfoOffset);
if (dump_raw) {
stringstream ssraw;
ssraw << base << "rose_nfa_" << i << ".raw";
- auto f = openStdioFile(ssraw.str());
+ auto f = openStdioFile(ssraw.str(), "w");
fwrite(n, 1, n->length, f.get());
}
}
if (dump_raw) {
stringstream ssraw;
ssraw << base << "som_rev_nfa_" << i << ".raw";
- auto f = openStdioFile(ssraw.str());
+ auto f = openStdioFile(ssraw.str(), "w");
fwrite(n, 1, n->length, f.get());
}
}
static
void roseDumpLiteralMatchers(const RoseEngine *t, const string &base) {
if (const HWLM *ftable = getFloatingMatcher(t)) {
- auto f = openStdioFile(base + "/lit_table_floating.txt");
+ auto f = openStdioFile(base + "/lit_table_floating.txt", "w");
hwlmPrintStats(ftable, f.get());
}
if (const HWLM *drtable = getDelayRebuildMatcher(t)) {
- auto f = openStdioFile(base + "/lit_table_delay_rebuild.txt");
+ auto f = openStdioFile(base + "/lit_table_delay_rebuild.txt", "w");
hwlmPrintStats(drtable, f.get());
}
if (const HWLM *etable = getEodMatcher(t)) {
- auto f = openStdioFile(base + "/lit_table_eod.txt");
+ auto f = openStdioFile(base + "/lit_table_eod.txt", "w");
hwlmPrintStats(etable, f.get());
}
if (const HWLM *sbtable = getSmallBlockMatcher(t)) {
- auto f = openStdioFile(base + "/lit_table_small_block.txt");
+ auto f = openStdioFile(base + "/lit_table_small_block.txt", "w");
hwlmPrintStats(sbtable, f.get());
}
return;
}
- auto f = openStdioFile(grey.dumpPath + "/rose.txt");
+ auto f = openStdioFile(grey.dumpPath + "/rose.txt", "w");
if (!t) {
fprintf(f.get(), "<< no rose >>\n");
// Literals
dumpRoseLiterals(build, fragments, grey);
- f = openStdioFile(grey.dumpPath + "/rose_struct.txt");
+ f = openStdioFile(grey.dumpPath + "/rose_struct.txt", "w");
roseDumpStructRaw(t, f.get());
}