You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
naka/src/display.c

51 lines
1.3 KiB

//! Displaying match data
#include <stdio.h>
#include <stdlib.h>
#include <macros.h>
#include <comp.h>
#include <display.h>
static void _display_normal(FILE* output, dispin_t*pIN input, dispflags_t flags)
{
slice_t cslice = input->cslice;
const void* base = input->base;
usize i = input->index;
#ifdef _DEBUG_MANCALC_OFFSETS
struct {
usize start, end;
} pos = {
.start = AS(cslice.ptr - base, usize),
};
pos.end = pos.start + cslice.len;
#else
let pos = slice_sted((slice_t[]){ SLICE(AS(cslice.ptr - base, usize), cslice.len)});
#endif
INFO("Mapped region slice for %lu, pre-transform (at %p): " SLICE_FORMAT ", len: %lu", i+1, base, SLICE_FORMAT_ARGS(&cslice), cslice.len);
//TODO: Honour `flags`
IGNORE(flags);
fprintf(output, "match: %lu: %lu -> %lu\n", i+1, pos.start, pos.end);
}
void display_result(FILE* output, dispin_t input, dispkind_t how, dispflags_t flags)
{
flags = flags ?: DISPLAY_FLAGS_DEFAULT;
output = output ?: stdout;
debug_assert(input);
TRACE("Outputting as %d to %p with flags 0x%08lx", (int)how, output, (usize)flags);
switch(how)
{
case DISPK_NORMAL:
_display_normal(output, &input, flags);
break;
case DISPK_CSV:
case DISPK_BINARY:
case DISPK_INI:
default: COLD_EXPR(FATAL("unknown or unimplemented display kind: %d", (int)how));
}
}