/* matcher.c generated by valac 0.56.0, the Vala compiler
 * generated from matcher.vala, do not modify */

/*
* Copyright (C) 2015 The Lemon Man
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "findinfiles.h"

#define GEDIT_FIND_IN_FILES_PLUGIN_TYPE_IMATCHER (gedit_find_in_files_plugin_imatcher_get_type ())
#define GEDIT_FIND_IN_FILES_PLUGIN_IMATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_IMATCHER, GeditFindInFilesPluginIMatcher))
#define GEDIT_FIND_IN_FILES_PLUGIN_IS_IMATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_IMATCHER))
#define GEDIT_FIND_IN_FILES_PLUGIN_IMATCHER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_IMATCHER, GeditFindInFilesPluginIMatcherIface))

typedef struct _GeditFindInFilesPluginIMatcher GeditFindInFilesPluginIMatcher;
typedef struct _GeditFindInFilesPluginIMatcherIface GeditFindInFilesPluginIMatcherIface;

#define GEDIT_FIND_IN_FILES_PLUGIN_TYPE_RANGE (gedit_find_in_files_plugin_range_get_type ())
typedef struct _GeditFindInFilesPluginRange GeditFindInFilesPluginRange;

#define GEDIT_FIND_IN_FILES_PLUGIN_TYPE_REGEX_FIND (gedit_find_in_files_plugin_regex_find_get_type ())
#define GEDIT_FIND_IN_FILES_PLUGIN_REGEX_FIND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_REGEX_FIND, GeditFindInFilesPluginRegexFind))
#define GEDIT_FIND_IN_FILES_PLUGIN_REGEX_FIND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_REGEX_FIND, GeditFindInFilesPluginRegexFindClass))
#define GEDIT_FIND_IN_FILES_PLUGIN_IS_REGEX_FIND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_REGEX_FIND))
#define GEDIT_FIND_IN_FILES_PLUGIN_IS_REGEX_FIND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_REGEX_FIND))
#define GEDIT_FIND_IN_FILES_PLUGIN_REGEX_FIND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_REGEX_FIND, GeditFindInFilesPluginRegexFindClass))

typedef struct _GeditFindInFilesPluginRegexFind GeditFindInFilesPluginRegexFind;
typedef struct _GeditFindInFilesPluginRegexFindClass GeditFindInFilesPluginRegexFindClass;
typedef struct _GeditFindInFilesPluginRegexFindPrivate GeditFindInFilesPluginRegexFindPrivate;
enum  {
	GEDIT_FIND_IN_FILES_PLUGIN_REGEX_FIND_0_PROPERTY,
	GEDIT_FIND_IN_FILES_PLUGIN_REGEX_FIND_NUM_PROPERTIES
};
static GParamSpec* gedit_find_in_files_plugin_regex_find_properties[GEDIT_FIND_IN_FILES_PLUGIN_REGEX_FIND_NUM_PROPERTIES];
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define GEDIT_FIND_IN_FILES_PLUGIN_TYPE_BOYER_MOORE_HORSPOOL (gedit_find_in_files_plugin_boyer_moore_horspool_get_type ())
#define GEDIT_FIND_IN_FILES_PLUGIN_BOYER_MOORE_HORSPOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_BOYER_MOORE_HORSPOOL, GeditFindInFilesPluginBoyerMooreHorspool))
#define GEDIT_FIND_IN_FILES_PLUGIN_BOYER_MOORE_HORSPOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_BOYER_MOORE_HORSPOOL, GeditFindInFilesPluginBoyerMooreHorspoolClass))
#define GEDIT_FIND_IN_FILES_PLUGIN_IS_BOYER_MOORE_HORSPOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_BOYER_MOORE_HORSPOOL))
#define GEDIT_FIND_IN_FILES_PLUGIN_IS_BOYER_MOORE_HORSPOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_BOYER_MOORE_HORSPOOL))
#define GEDIT_FIND_IN_FILES_PLUGIN_BOYER_MOORE_HORSPOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_FIND_IN_FILES_PLUGIN_TYPE_BOYER_MOORE_HORSPOOL, GeditFindInFilesPluginBoyerMooreHorspoolClass))

typedef struct _GeditFindInFilesPluginBoyerMooreHorspool GeditFindInFilesPluginBoyerMooreHorspool;
typedef struct _GeditFindInFilesPluginBoyerMooreHorspoolClass GeditFindInFilesPluginBoyerMooreHorspoolClass;
typedef struct _GeditFindInFilesPluginBoyerMooreHorspoolPrivate GeditFindInFilesPluginBoyerMooreHorspoolPrivate;
enum  {
	GEDIT_FIND_IN_FILES_PLUGIN_BOYER_MOORE_HORSPOOL_0_PROPERTY,
	GEDIT_FIND_IN_FILES_PLUGIN_BOYER_MOORE_HORSPOOL_NUM_PROPERTIES
};
static GParamSpec* gedit_find_in_files_plugin_boyer_moore_horspool_properties[GEDIT_FIND_IN_FILES_PLUGIN_BOYER_MOORE_HORSPOOL_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GeditFindInFilesPluginRange {
	gsize from;
	gsize to;
};

struct _GeditFindInFilesPluginIMatcherIface {
	GTypeInterface parent_iface;
	gboolean (*has_match) (GeditFindInFilesPluginIMatcher* self, guint8* text, gsize text_length, gsize pos, GeditFindInFilesPluginRange* match);
};

struct _GeditFindInFilesPluginRegexFind {
	GObject parent_instance;
	GeditFindInFilesPluginRegexFindPrivate * priv;
};

struct _GeditFindInFilesPluginRegexFindClass {
	GObjectClass parent_class;
};

struct _GeditFindInFilesPluginRegexFindPrivate {
	GRegex* re;
};

struct _GeditFindInFilesPluginBoyerMooreHorspool {
	GObject parent_instance;
	GeditFindInFilesPluginBoyerMooreHorspoolPrivate * priv;
};

struct _GeditFindInFilesPluginBoyerMooreHorspoolClass {
	GObjectClass parent_class;
};

struct _GeditFindInFilesPluginBoyerMooreHorspoolPrivate {
	gchar* pattern;
	gint bad_char_shift[256];
	gboolean ignore_case;
};

static gint GeditFindInFilesPluginRegexFind_private_offset;
static gpointer gedit_find_in_files_plugin_regex_find_parent_class = NULL;
static GeditFindInFilesPluginIMatcherIface * gedit_find_in_files_plugin_regex_find_gedit_find_in_files_plugin_imatcher_parent_iface = NULL;
static GType gedit_find_in_files_plugin_regex_find_type_id = 0;
static gint GeditFindInFilesPluginBoyerMooreHorspool_private_offset;
static gpointer gedit_find_in_files_plugin_boyer_moore_horspool_parent_class = NULL;
static GeditFindInFilesPluginIMatcherIface * gedit_find_in_files_plugin_boyer_moore_horspool_gedit_find_in_files_plugin_imatcher_parent_iface = NULL;
static GType gedit_find_in_files_plugin_boyer_moore_horspool_type_id = 0;

VALA_EXTERN GType gedit_find_in_files_plugin_range_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GeditFindInFilesPluginRange* gedit_find_in_files_plugin_range_dup (const GeditFindInFilesPluginRange* self);
VALA_EXTERN void gedit_find_in_files_plugin_range_free (GeditFindInFilesPluginRange* self);
GType gedit_find_in_files_plugin_imatcher_register_type (GTypeModule * module);
VALA_EXTERN GType gedit_find_in_files_plugin_imatcher_get_type (void) G_GNUC_CONST ;
GType gedit_find_in_files_plugin_regex_find_register_type (GTypeModule * module);
VALA_EXTERN GType gedit_find_in_files_plugin_regex_find_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GeditFindInFilesPluginRegexFind* gedit_find_in_files_plugin_regex_find_new (const gchar* pattern,
                                                                            gboolean ignore_case,
                                                                            GError** error);
VALA_EXTERN GeditFindInFilesPluginRegexFind* gedit_find_in_files_plugin_regex_find_construct (GType object_type,
                                                                                  const gchar* pattern,
                                                                                  gboolean ignore_case,
                                                                                  GError** error);
static gboolean gedit_find_in_files_plugin_regex_find_real_has_match (GeditFindInFilesPluginIMatcher* base,
                                                               guint8* text,
                                                               gsize text_length,
                                                               gsize pos,
                                                               GeditFindInFilesPluginRange* match);
VALA_EXTERN gboolean gedit_find_in_files_plugin_imatcher_has_match (GeditFindInFilesPluginIMatcher* self,
                                                        guint8* text,
                                                        gsize text_length,
                                                        gsize pos,
                                                        GeditFindInFilesPluginRange* match);
static void gedit_find_in_files_plugin_regex_find_finalize (GObject * obj);
GType gedit_find_in_files_plugin_boyer_moore_horspool_register_type (GTypeModule * module);
VALA_EXTERN GType gedit_find_in_files_plugin_boyer_moore_horspool_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GeditFindInFilesPluginBoyerMooreHorspool* gedit_find_in_files_plugin_boyer_moore_horspool_new (const gchar* pattern_,
                                                                                               gboolean ignore_case_);
VALA_EXTERN GeditFindInFilesPluginBoyerMooreHorspool* gedit_find_in_files_plugin_boyer_moore_horspool_construct (GType object_type,
                                                                                                     const gchar* pattern_,
                                                                                                     gboolean ignore_case_);
static gboolean gedit_find_in_files_plugin_boyer_moore_horspool_real_has_match (GeditFindInFilesPluginIMatcher* base,
                                                                         guint8* text,
                                                                         gsize text_length,
                                                                         gsize pos,
                                                                         GeditFindInFilesPluginRange* match);
static void gedit_find_in_files_plugin_boyer_moore_horspool_finalize (GObject * obj);

static inline gpointer
gedit_find_in_files_plugin_regex_find_get_instance_private (GeditFindInFilesPluginRegexFind* self)
{
	return G_STRUCT_MEMBER_P (self, GeditFindInFilesPluginRegexFind_private_offset);
}

GeditFindInFilesPluginRegexFind*
gedit_find_in_files_plugin_regex_find_construct (GType object_type,
                                                 const gchar* pattern,
                                                 gboolean ignore_case,
                                                 GError** error)
{
	GeditFindInFilesPluginRegexFind * self = NULL;
	GRegexCompileFlags flags = 0U;
	GRegex* _tmp0_ = NULL;
	GRegex* _tmp1_;
	GRegex* _tmp2_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (pattern != NULL, NULL);
	self = (GeditFindInFilesPluginRegexFind*) g_object_new (object_type, NULL);
	flags = G_REGEX_OPTIMIZE;
	if (ignore_case) {
		flags |= G_REGEX_CASELESS;
	}
	_tmp1_ = g_regex_new (pattern, flags, 0, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp2_ = _tmp0_;
	_tmp0_ = NULL;
	_g_regex_unref0 (self->priv->re);
	self->priv->re = _tmp2_;
	_g_regex_unref0 (_tmp0_);
	return self;
}

GeditFindInFilesPluginRegexFind*
gedit_find_in_files_plugin_regex_find_new (const gchar* pattern,
                                           gboolean ignore_case,
                                           GError** error)
{
	return gedit_find_in_files_plugin_regex_find_construct (GEDIT_FIND_IN_FILES_PLUGIN_TYPE_REGEX_FIND, pattern, ignore_case, error);
}

static gboolean
gedit_find_in_files_plugin_regex_find_real_has_match (GeditFindInFilesPluginIMatcher* base,
                                                      guint8* text,
                                                      gsize text_length,
                                                      gsize pos,
                                                      GeditFindInFilesPluginRange* match)
{
	GeditFindInFilesPluginRegexFind * self;
	GMatchInfo* info = NULL;
	gint casted_pos = 0;
	const gchar* str = NULL;
	gint _tmp8_ = 0;
	gint _tmp9_ = 0;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (GeditFindInFilesPluginRegexFind*) base;
	g_return_val_if_fail (match != NULL, FALSE);
	if (pos > ((gsize) G_MAXINT)) {
		casted_pos = 0;
		text = text + pos;
	} else {
		casted_pos = (gint) pos;
	}
	str = (const gchar*) text;
	{
		gboolean _tmp0_ = FALSE;
		GRegex* _tmp1_;
		GMatchInfo* _tmp2_ = NULL;
		gboolean _tmp3_;
		_tmp1_ = self->priv->re;
		_tmp3_ = g_regex_match_full (_tmp1_, str, (gssize) text_length, casted_pos, 0, &_tmp2_, &_inner_error0_);
		_g_match_info_unref0 (info);
		info = _tmp2_;
		_tmp0_ = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp4_ = FALSE;
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_match_info_unref0 (info);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp4_;
		}
		if (!_tmp0_) {
			result = FALSE;
			_g_match_info_unref0 (info);
			return result;
		}
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		GError* err = NULL;
		GError* _tmp5_;
		const gchar* _tmp6_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp5_ = err;
		_tmp6_ = _tmp5_->message;
		g_warning ("matcher.vala:55: %s", _tmp6_);
		result = FALSE;
		_g_error_free0 (err);
		_g_match_info_unref0 (info);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp7_ = FALSE;
		_g_match_info_unref0 (info);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp7_;
	}
	g_match_info_fetch_pos (info, 0, &_tmp8_, &_tmp9_);
	(*match).from = (gsize) _tmp8_;
	(*match).to = (gsize) _tmp9_;
	result = TRUE;
	_g_match_info_unref0 (info);
	return result;
}

static void
gedit_find_in_files_plugin_regex_find_class_init (GeditFindInFilesPluginRegexFindClass * klass,
                                                  gpointer klass_data)
{
	gedit_find_in_files_plugin_regex_find_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GeditFindInFilesPluginRegexFind_private_offset);
	G_OBJECT_CLASS (klass)->finalize = gedit_find_in_files_plugin_regex_find_finalize;
}

static void
gedit_find_in_files_plugin_regex_find_gedit_find_in_files_plugin_imatcher_interface_init (GeditFindInFilesPluginIMatcherIface * iface,
                                                                                          gpointer iface_data)
{
	gedit_find_in_files_plugin_regex_find_gedit_find_in_files_plugin_imatcher_parent_iface = g_type_interface_peek_parent (iface);
	iface->has_match = (gboolean (*) (GeditFindInFilesPluginIMatcher*, guint8*, gsize, gsize, GeditFindInFilesPluginRange*)) gedit_find_in_files_plugin_regex_find_real_has_match;
}

static void
gedit_find_in_files_plugin_regex_find_instance_init (GeditFindInFilesPluginRegexFind * self,
                                                     gpointer klass)
{
	self->priv = gedit_find_in_files_plugin_regex_find_get_instance_private (self);
}

static void
gedit_find_in_files_plugin_regex_find_finalize (GObject * obj)
{
	GeditFindInFilesPluginRegexFind * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEDIT_FIND_IN_FILES_PLUGIN_TYPE_REGEX_FIND, GeditFindInFilesPluginRegexFind);
	_g_regex_unref0 (self->priv->re);
	G_OBJECT_CLASS (gedit_find_in_files_plugin_regex_find_parent_class)->finalize (obj);
}

GType
gedit_find_in_files_plugin_regex_find_get_type (void)
{
	return gedit_find_in_files_plugin_regex_find_type_id;
}

GType
gedit_find_in_files_plugin_regex_find_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (GeditFindInFilesPluginRegexFindClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gedit_find_in_files_plugin_regex_find_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GeditFindInFilesPluginRegexFind), 0, (GInstanceInitFunc) gedit_find_in_files_plugin_regex_find_instance_init, NULL };
	static const GInterfaceInfo gedit_find_in_files_plugin_imatcher_info = { (GInterfaceInitFunc) gedit_find_in_files_plugin_regex_find_gedit_find_in_files_plugin_imatcher_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	gedit_find_in_files_plugin_regex_find_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GeditFindInFilesPluginRegexFind", &g_define_type_info, 0);
	g_type_module_add_interface (module, gedit_find_in_files_plugin_regex_find_type_id, GEDIT_FIND_IN_FILES_PLUGIN_TYPE_IMATCHER, &gedit_find_in_files_plugin_imatcher_info);
	GeditFindInFilesPluginRegexFind_private_offset = sizeof (GeditFindInFilesPluginRegexFindPrivate);
	return gedit_find_in_files_plugin_regex_find_type_id;
}

static inline gpointer
gedit_find_in_files_plugin_boyer_moore_horspool_get_instance_private (GeditFindInFilesPluginBoyerMooreHorspool* self)
{
	return G_STRUCT_MEMBER_P (self, GeditFindInFilesPluginBoyerMooreHorspool_private_offset);
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

GeditFindInFilesPluginBoyerMooreHorspool*
gedit_find_in_files_plugin_boyer_moore_horspool_construct (GType object_type,
                                                           const gchar* pattern_,
                                                           gboolean ignore_case_)
{
	GeditFindInFilesPluginBoyerMooreHorspool * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (pattern_ != NULL, NULL);
	self = (GeditFindInFilesPluginBoyerMooreHorspool*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (pattern_);
	_g_free0 (self->priv->pattern);
	self->priv->pattern = _tmp0_;
	self->priv->ignore_case = ignore_case_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				const gchar* _tmp3_;
				gint _tmp4_;
				gint _tmp5_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < 256)) {
					break;
				}
				_tmp3_ = self->priv->pattern;
				_tmp4_ = strlen (_tmp3_);
				_tmp5_ = _tmp4_;
				self->priv->bad_char_shift[i] = _tmp5_;
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp6_ = FALSE;
			_tmp6_ = TRUE;
			while (TRUE) {
				const gchar* _tmp8_;
				gint _tmp9_;
				gint _tmp10_;
				if (!_tmp6_) {
					gint _tmp7_;
					_tmp7_ = i;
					i = _tmp7_ + 1;
				}
				_tmp6_ = FALSE;
				_tmp8_ = self->priv->pattern;
				_tmp9_ = strlen (_tmp8_);
				_tmp10_ = _tmp9_;
				if (!(i < (_tmp10_ - 1))) {
					break;
				}
				if (self->priv->ignore_case) {
					const gchar* _tmp11_;
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					const gchar* _tmp15_;
					const gchar* _tmp16_;
					gint _tmp17_;
					gint _tmp18_;
					_tmp11_ = self->priv->pattern;
					_tmp12_ = self->priv->pattern;
					_tmp13_ = strlen (_tmp12_);
					_tmp14_ = _tmp13_;
					self->priv->bad_char_shift[toupper ((gint) string_get (_tmp11_, (glong) i))] = (_tmp14_ - 1) - i;
					_tmp15_ = self->priv->pattern;
					_tmp16_ = self->priv->pattern;
					_tmp17_ = strlen (_tmp16_);
					_tmp18_ = _tmp17_;
					self->priv->bad_char_shift[tolower ((gint) string_get (_tmp15_, (glong) i))] = (_tmp18_ - 1) - i;
				} else {
					const gchar* _tmp19_;
					const gchar* _tmp20_;
					gint _tmp21_;
					gint _tmp22_;
					_tmp19_ = self->priv->pattern;
					_tmp20_ = self->priv->pattern;
					_tmp21_ = strlen (_tmp20_);
					_tmp22_ = _tmp21_;
					self->priv->bad_char_shift[string_get (_tmp19_, (glong) i)] = (_tmp22_ - 1) - i;
				}
			}
		}
	}
	return self;
}

GeditFindInFilesPluginBoyerMooreHorspool*
gedit_find_in_files_plugin_boyer_moore_horspool_new (const gchar* pattern_,
                                                     gboolean ignore_case_)
{
	return gedit_find_in_files_plugin_boyer_moore_horspool_construct (GEDIT_FIND_IN_FILES_PLUGIN_TYPE_BOYER_MOORE_HORSPOOL, pattern_, ignore_case_);
}

static gboolean
gedit_find_in_files_plugin_boyer_moore_horspool_real_has_match (GeditFindInFilesPluginIMatcher* base,
                                                                guint8* text,
                                                                gsize text_length,
                                                                gsize pos,
                                                                GeditFindInFilesPluginRange* match)
{
	GeditFindInFilesPluginBoyerMooreHorspool * self;
	guint i = 0U;
	const gchar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean result;
	self = (GeditFindInFilesPluginBoyerMooreHorspool*) base;
	g_return_val_if_fail (match != NULL, FALSE);
	i = (guint) 0;
	text = text + pos;
	text_length = text_length - pos;
	_tmp0_ = self->priv->pattern;
	_tmp1_ = strlen (_tmp0_);
	_tmp2_ = _tmp1_;
	if (text_length < ((gsize) _tmp2_)) {
		result = FALSE;
		return result;
	}
	while (TRUE) {
		const gchar* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		const gchar* _tmp19_;
		gint _tmp20_;
		gint _tmp21_;
		guint8 _tmp22_;
		gint _tmp23_;
		_tmp3_ = self->priv->pattern;
		_tmp4_ = strlen (_tmp3_);
		_tmp5_ = _tmp4_;
		if (!(((gsize) i) <= (text_length - _tmp5_))) {
			break;
		}
		{
			gint j = 0;
			const gchar* _tmp6_;
			gint _tmp7_;
			gint _tmp8_;
			_tmp6_ = self->priv->pattern;
			_tmp7_ = strlen (_tmp6_);
			_tmp8_ = _tmp7_;
			j = _tmp8_ - 1;
			{
				gboolean _tmp9_ = FALSE;
				_tmp9_ = TRUE;
				while (TRUE) {
					if (!_tmp9_) {
						gint _tmp10_;
						_tmp10_ = j;
						j = _tmp10_ - 1;
					}
					_tmp9_ = FALSE;
					if (!(j >= 0)) {
						break;
					}
					if (self->priv->ignore_case) {
						guint8 _tmp11_;
						const gchar* _tmp12_;
						_tmp11_ = text[i + j];
						_tmp12_ = self->priv->pattern;
						if (tolower ((gint) _tmp11_) != tolower ((gint) string_get (_tmp12_, (glong) j))) {
							break;
						}
					} else {
						guint8 _tmp13_;
						const gchar* _tmp14_;
						_tmp13_ = text[i + j];
						_tmp14_ = self->priv->pattern;
						if (_tmp13_ != ((guint8) string_get (_tmp14_, (glong) j))) {
							break;
						}
					}
					if (j == 0) {
						GeditFindInFilesPluginRange _tmp15_;
						const gchar* _tmp16_;
						gint _tmp17_;
						gint _tmp18_;
						(*match).from = pos + i;
						_tmp15_ = *match;
						_tmp16_ = self->priv->pattern;
						_tmp17_ = strlen (_tmp16_);
						_tmp18_ = _tmp17_;
						(*match).to = _tmp15_.from + _tmp18_;
						result = TRUE;
						return result;
					}
				}
			}
		}
		_tmp19_ = self->priv->pattern;
		_tmp20_ = strlen (_tmp19_);
		_tmp21_ = _tmp20_;
		_tmp22_ = text[(i + _tmp21_) - 1];
		_tmp23_ = self->priv->bad_char_shift[_tmp22_];
		i += (guint) _tmp23_;
	}
	result = FALSE;
	return result;
}

static void
gedit_find_in_files_plugin_boyer_moore_horspool_class_init (GeditFindInFilesPluginBoyerMooreHorspoolClass * klass,
                                                            gpointer klass_data)
{
	gedit_find_in_files_plugin_boyer_moore_horspool_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GeditFindInFilesPluginBoyerMooreHorspool_private_offset);
	G_OBJECT_CLASS (klass)->finalize = gedit_find_in_files_plugin_boyer_moore_horspool_finalize;
}

static void
gedit_find_in_files_plugin_boyer_moore_horspool_gedit_find_in_files_plugin_imatcher_interface_init (GeditFindInFilesPluginIMatcherIface * iface,
                                                                                                    gpointer iface_data)
{
	gedit_find_in_files_plugin_boyer_moore_horspool_gedit_find_in_files_plugin_imatcher_parent_iface = g_type_interface_peek_parent (iface);
	iface->has_match = (gboolean (*) (GeditFindInFilesPluginIMatcher*, guint8*, gsize, gsize, GeditFindInFilesPluginRange*)) gedit_find_in_files_plugin_boyer_moore_horspool_real_has_match;
}

static void
gedit_find_in_files_plugin_boyer_moore_horspool_instance_init (GeditFindInFilesPluginBoyerMooreHorspool * self,
                                                               gpointer klass)
{
	self->priv = gedit_find_in_files_plugin_boyer_moore_horspool_get_instance_private (self);
}

static void
gedit_find_in_files_plugin_boyer_moore_horspool_finalize (GObject * obj)
{
	GeditFindInFilesPluginBoyerMooreHorspool * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEDIT_FIND_IN_FILES_PLUGIN_TYPE_BOYER_MOORE_HORSPOOL, GeditFindInFilesPluginBoyerMooreHorspool);
	_g_free0 (self->priv->pattern);
	G_OBJECT_CLASS (gedit_find_in_files_plugin_boyer_moore_horspool_parent_class)->finalize (obj);
}

GType
gedit_find_in_files_plugin_boyer_moore_horspool_get_type (void)
{
	return gedit_find_in_files_plugin_boyer_moore_horspool_type_id;
}

GType
gedit_find_in_files_plugin_boyer_moore_horspool_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (GeditFindInFilesPluginBoyerMooreHorspoolClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gedit_find_in_files_plugin_boyer_moore_horspool_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GeditFindInFilesPluginBoyerMooreHorspool), 0, (GInstanceInitFunc) gedit_find_in_files_plugin_boyer_moore_horspool_instance_init, NULL };
	static const GInterfaceInfo gedit_find_in_files_plugin_imatcher_info = { (GInterfaceInitFunc) gedit_find_in_files_plugin_boyer_moore_horspool_gedit_find_in_files_plugin_imatcher_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	gedit_find_in_files_plugin_boyer_moore_horspool_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GeditFindInFilesPluginBoyerMooreHorspool", &g_define_type_info, 0);
	g_type_module_add_interface (module, gedit_find_in_files_plugin_boyer_moore_horspool_type_id, GEDIT_FIND_IN_FILES_PLUGIN_TYPE_IMATCHER, &gedit_find_in_files_plugin_imatcher_info);
	GeditFindInFilesPluginBoyerMooreHorspool_private_offset = sizeof (GeditFindInFilesPluginBoyerMooreHorspoolPrivate);
	return gedit_find_in_files_plugin_boyer_moore_horspool_type_id;
}

