<commit_before>// File created: 2011-09-02 23:36:15

#include "cursor.all.h"

#include <assert.h>

#if MUSHSPACE_93
#define STATIC_BOX(sp) (&(sp)->box)
#else
#define STATIC_BOX(sp) (&(sp)->static_box)
#endif

#define mushcursor_in_box MUSHSPACE_CAT(mushcursor,_in_box)

static bool mushcursor_in_box(const mushcursor*);

const size_t mushcursor_sizeof = sizeof(mushcursor);

mushcursor* mushcursor_init(
	mushspace* space, mushcoords pos, mushcoords delta, void* vp)
{
	mushcursor *cursor = vp ? vp : malloc(sizeof *cursor);
	if (!cursor)
		return NULL;

	cursor->space = space;
	cursor->pos   = pos;
	return cursor;
}

static bool mushcursor_in_box(const mushcursor* cursor) {
	switch (MUSHCURSOR_MODE(cursor)) {
	case MushCursorMode_static:
		return mush_staticaabb_contains(cursor->pos);

#if !MUSHSPACE_93
	case MushCursorMode_dynamic:
		return mush_bounds_contains(&cursor->box->bounds, cursor->pos);

	case MushCursorMode_bak:
		return mush_bounds_contains(&cursor->space->bak.bounds, cursor->pos);
#endif
	}
	assert (false);
}

mushcell mushcursor_get(mushcursor* cursor) {
	mushspace *sp = cursor->space;

	mushstats_add(sp->stats, MushStat_lookups, 1);

	switch (MUSHCURSOR_MODE(cursor)) {
	case MushCursorMode_static:
		return mush_staticaabb_get(STATIC_BOX(sp), cursor->pos);

#if !MUSHSPACE_93
	case MushCursorMode_dynamic:
		return mush_aabb_get(cursor->box, cursor->pos);

	case MushCursorMode_bak:
		return mush_bakaabb_get(&sp->bak, cursor->pos);<commit_msg>Check mushcursor_in_box in mushcursor_get<commit_after>// File created: 2011-09-02 23:36:15

#include "cursor.all.h"

#include <assert.h>

#if MUSHSPACE_93
#define STATIC_BOX(sp) (&(sp)->box)
#else
#define STATIC_BOX(sp) (&(sp)->static_box)
#endif

#define mushcursor_in_box MUSHSPACE_CAT(mushcursor,_in_box)

static bool mushcursor_in_box(const mushcursor*);

const size_t mushcursor_sizeof = sizeof(mushcursor);

mushcursor* mushcursor_init(
	mushspace* space, mushcoords pos, mushcoords delta, void* vp)
{
	mushcursor *cursor = vp ? vp : malloc(sizeof *cursor);
	if (!cursor)
		return NULL;

	cursor->space = space;
	cursor->pos   = pos;
	return cursor;
}

static bool mushcursor_in_box(const mushcursor* cursor) {
	switch (MUSHCURSOR_MODE(cursor)) {
	case MushCursorMode_static:
		return mush_staticaabb_contains(cursor->pos);

#if !MUSHSPACE_93
	case MushCursorMode_dynamic:
		return mush_bounds_contains(&cursor->box->bounds, cursor->pos);

	case MushCursorMode_bak:
		return mush_bounds_contains(&cursor->space->bak.bounds, cursor->pos);
#endif
	}
	assert (false);
}

mushcell mushcursor_get(mushcursor* cursor) {
	mushspace *sp = cursor->space;

#if MUSHSPACE_93
	assert (mushcursor_in_box(cursor));
#else
	if (!mushcursor_in_box(cursor))
	{
		mushstats_add(sp->stats, MushStat_lookups, 1);
		return ' ';
	}
#endif

	mushstats_add(sp->stats, MushStat_lookups, 1);

	switch (MUSHCURSOR_MODE(cursor)) {
	case MushCursorMode_static:
		return mush_staticaabb_get(STATIC_BOX(sp), cursor->pos);

#if !MUSHSPACE_93
	case MushCursorMode_dynamic:
		return mush_aabb_get(cursor->box, cursor->pos);

	case MushCursorMode_bak:
		return mush_bakaabb_get(&sp->bak, cursor->pos);
{'fraction_non_alphanumeric': 0.1249205340114431, 'fraction_numerical': 0.014303877940241577, 'mean_word_length': 6.318604651162791, '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': '1589033', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1181, 'n_words': 234}