/* gitg-convert.c generated by valac 0.32.1, the Vala compiler
 * generated from gitg-convert.vala, do not modify */

/*
 * This file is part of gitg
 *
 * Copyright (C) 2015 - Jesse van den Kieboom
 *
 * gitg 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 of the License, or
 * (at your option) any later version.
 *
 * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))



void gitg_convert_utf8_validate_fallback (gchar** text, gssize size);
gchar* gitg_convert_convert_fallback (const gchar* text, gssize size, const gchar* fallback);
gboolean gitg_convert_convert_and_check (const gchar* text, gssize size, const gchar* from_charset, gchar** ret);
gchar* gitg_convert_utf8 (const gchar* str, gssize size, const gchar* from_charset);


void gitg_convert_utf8_validate_fallback (gchar** text, gssize size) {
	gchar* end = NULL;
#line 22 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	g_return_if_fail (*text != NULL);
#line 26 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	while (TRUE) {
#line 46 "gitg-convert.c"
		const gchar* _tmp0_ = NULL;
		gssize _tmp1_ = 0L;
		gchar* _tmp2_ = NULL;
		gboolean _tmp3_ = FALSE;
		gchar* _tmp4_ = NULL;
		gchar _tmp5_ = '\0';
#line 26 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp0_ = *text;
#line 26 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp1_ = size;
#line 26 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp3_ = g_utf8_validate (_tmp0_, _tmp1_, &_tmp2_);
#line 26 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		end = _tmp2_;
#line 26 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		if (!(!_tmp3_)) {
#line 26 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			break;
#line 65 "gitg-convert.c"
		}
#line 28 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp4_ = end;
#line 28 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		*_tmp4_ = '?';
#line 28 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp5_ = *_tmp4_;
#line 73 "gitg-convert.c"
	}
}


gchar* gitg_convert_convert_fallback (const gchar* text, gssize size, const gchar* fallback) {
	gchar* result = NULL;
	gchar* res = NULL;
	gchar* _tmp0_ = NULL;
	gsize read = 0UL;
	GString* str = NULL;
	GString* _tmp1_ = NULL;
	GString* _tmp20_ = NULL;
	const gchar* _tmp21_ = NULL;
	gchar* retval = NULL;
	GString* _tmp22_ = NULL;
	const gchar* _tmp23_ = NULL;
	gchar* _tmp24_ = NULL;
	GString* _tmp25_ = NULL;
	gssize _tmp26_ = 0L;
	GError * _inner_error_ = NULL;
#line 32 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	g_return_val_if_fail (text != NULL, NULL);
#line 32 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	g_return_val_if_fail (fallback != NULL, NULL);
#line 34 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp0_ = g_strdup ("");
#line 34 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	res = _tmp0_;
#line 37 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp1_ = g_string_new ("");
#line 37 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	str = _tmp1_;
#line 39 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	while (TRUE) {
#line 108 "gitg-convert.c"
		{
			gchar* _tmp2_ = NULL;
			const gchar* _tmp3_ = NULL;
			gssize _tmp4_ = 0L;
			gsize _tmp5_ = 0UL;
			gchar* _tmp6_ = NULL;
			gchar* _tmp7_ = NULL;
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp3_ = text;
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp4_ = size;
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp6_ = g_convert (_tmp3_, _tmp4_, "UTF-8", "ASCII", &_tmp5_, NULL, &_inner_error_);
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			read = _tmp5_;
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp2_ = _tmp6_;
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 128 "gitg-convert.c"
				goto __catch68_g_error;
			}
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp7_ = _tmp2_;
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp2_ = NULL;
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_g_free0 (res);
#line 43 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			res = _tmp7_;
#line 44 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_g_free0 (_tmp2_);
#line 44 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			break;
#line 143 "gitg-convert.c"
		}
		goto __finally68;
		__catch68_g_error:
		{
			GString* _tmp13_ = NULL;
			const gchar* _tmp14_ = NULL;
			const gchar* _tmp15_ = NULL;
			gsize _tmp16_ = 0UL;
			gssize _tmp17_ = 0L;
			gssize _tmp18_ = 0L;
			gsize _tmp19_ = 0UL;
#line 41 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			g_clear_error (&_inner_error_);
#line 41 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_inner_error_ = NULL;
#line 159 "gitg-convert.c"
			{
				gchar* _tmp8_ = NULL;
				const gchar* _tmp9_ = NULL;
				gsize _tmp10_ = 0UL;
				gchar* _tmp11_ = NULL;
				GString* _tmp12_ = NULL;
#line 50 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_tmp9_ = text;
#line 50 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_tmp10_ = read;
#line 50 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_tmp11_ = g_convert (_tmp9_, (gssize) _tmp10_, "UTF-8", "ASCII", NULL, NULL, &_inner_error_);
#line 50 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_tmp8_ = _tmp11_;
#line 50 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 176 "gitg-convert.c"
					goto __catch69_g_error;
				}
#line 50 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_tmp12_ = str;
#line 50 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				g_string_append (_tmp12_, _tmp8_);
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_g_free0 (_tmp8_);
#line 185 "gitg-convert.c"
			}
			goto __finally69;
			__catch69_g_error:
			{
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				g_clear_error (&_inner_error_);
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_inner_error_ = NULL;
#line 194 "gitg-convert.c"
			}
			__finally69:
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_g_string_free0 (str);
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_g_free0 (res);
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				g_clear_error (&_inner_error_);
#line 48 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				return NULL;
#line 209 "gitg-convert.c"
			}
#line 53 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp13_ = str;
#line 53 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp14_ = fallback;
#line 53 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			g_string_append (_tmp13_, _tmp14_);
#line 55 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp15_ = text;
#line 55 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp16_ = read;
#line 55 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp17_ = size;
#line 55 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			text = (const gchar*) (((guint8*) _tmp15_) + ((gint) (_tmp16_ + 1)));
#line 56 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp18_ = size;
#line 56 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp19_ = read;
#line 56 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			size = _tmp18_ - ((gssize) _tmp19_);
#line 231 "gitg-convert.c"
		}
		__finally68:
#line 41 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 41 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_g_string_free0 (str);
#line 41 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_g_free0 (res);
#line 41 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 41 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			g_clear_error (&_inner_error_);
#line 41 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			return NULL;
#line 246 "gitg-convert.c"
		}
	}
#line 60 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp20_ = str;
#line 60 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp21_ = res;
#line 60 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	g_string_append (_tmp20_, _tmp21_);
#line 62 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp22_ = str;
#line 62 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp23_ = _tmp22_->str;
#line 62 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp24_ = g_strdup (_tmp23_);
#line 62 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	retval = _tmp24_;
#line 63 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp25_ = str;
#line 63 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp26_ = _tmp25_->len;
#line 63 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	gitg_convert_utf8_validate_fallback (&retval, _tmp26_);
#line 65 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	result = retval;
#line 65 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_g_string_free0 (str);
#line 65 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_g_free0 (res);
#line 65 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	return result;
#line 277 "gitg-convert.c"
}


gboolean gitg_convert_convert_and_check (const gchar* text, gssize size, const gchar* from_charset, gchar** ret) {
	gchar* _vala_ret = NULL;
	gboolean result = FALSE;
	gsize read = 0UL;
	gsize written = 0UL;
	GError * _inner_error_ = NULL;
#line 68 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	g_return_val_if_fail (text != NULL, FALSE);
#line 68 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	g_return_val_if_fail (from_charset != NULL, FALSE);
#line 72 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_g_free0 (_vala_ret);
#line 72 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_vala_ret = NULL;
#line 295 "gitg-convert.c"
	{
		gchar* _tmp0_ = NULL;
		const gchar* _tmp1_ = NULL;
		gssize _tmp2_ = 0L;
		const gchar* _tmp3_ = NULL;
		gsize _tmp4_ = 0UL;
		gsize _tmp5_ = 0UL;
		gchar* _tmp6_ = NULL;
		gchar* _tmp7_ = NULL;
		gsize _tmp8_ = 0UL;
		gssize _tmp9_ = 0L;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp1_ = text;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp2_ = size;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp3_ = from_charset;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp6_ = g_convert (_tmp1_, _tmp2_, "UTF-8", _tmp3_, &_tmp4_, &_tmp5_, &_inner_error_);
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		read = _tmp4_;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		written = _tmp5_;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp0_ = _tmp6_;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 323 "gitg-convert.c"
			goto __catch70_g_error;
		}
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp7_ = _tmp0_;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp0_ = NULL;
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_g_free0 (_vala_ret);
#line 76 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_vala_ret = _tmp7_;
#line 78 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp8_ = read;
#line 78 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp9_ = size;
#line 78 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		if (_tmp8_ == ((gsize) _tmp9_)) {
#line 340 "gitg-convert.c"
			gsize _tmp10_ = 0UL;
#line 80 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp10_ = written;
#line 80 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			gitg_convert_utf8_validate_fallback (&_vala_ret, (gssize) _tmp10_);
#line 81 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			result = TRUE;
#line 81 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_g_free0 (_tmp0_);
#line 81 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			if (ret) {
#line 81 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				*ret = _vala_ret;
#line 354 "gitg-convert.c"
			} else {
#line 81 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
				_g_free0 (_vala_ret);
#line 358 "gitg-convert.c"
			}
#line 81 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			return result;
#line 362 "gitg-convert.c"
		}
#line 74 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_g_free0 (_tmp0_);
#line 366 "gitg-convert.c"
	}
	goto __finally70;
	__catch70_g_error:
	{
#line 74 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		g_clear_error (&_inner_error_);
#line 74 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_inner_error_ = NULL;
#line 375 "gitg-convert.c"
	}
	__finally70:
#line 74 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 74 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 74 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		g_clear_error (&_inner_error_);
#line 74 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		return FALSE;
#line 386 "gitg-convert.c"
	}
#line 86 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	result = FALSE;
#line 86 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	if (ret) {
#line 86 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		*ret = _vala_ret;
#line 394 "gitg-convert.c"
	} else {
#line 86 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_g_free0 (_vala_ret);
#line 398 "gitg-convert.c"
	}
#line 86 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	return result;
#line 402 "gitg-convert.c"
}


static gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	glong string_length = 0L;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	glong _tmp2_ = 0L;
	glong _tmp5_ = 0L;
	gboolean _tmp8_ = FALSE;
	glong _tmp9_ = 0L;
	gboolean _tmp12_ = FALSE;
	glong _tmp13_ = 0L;
	glong _tmp16_ = 0L;
	glong _tmp17_ = 0L;
	glong _tmp18_ = 0L;
	glong _tmp19_ = 0L;
	glong _tmp20_ = 0L;
	gchar* _tmp21_ = NULL;
#line 1328 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	g_return_val_if_fail (self != NULL, NULL);
#line 1329 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp0_ = strlen (self);
#line 1329 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp1_ = _tmp0_;
#line 1329 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	string_length = (glong) _tmp1_;
#line 1330 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp2_ = start;
#line 1330 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	if (_tmp2_ < ((glong) 0)) {
#line 435 "gitg-convert.c"
		glong _tmp3_ = 0L;
		glong _tmp4_ = 0L;
#line 1331 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp3_ = string_length;
#line 1331 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp4_ = start;
#line 1331 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		start = _tmp3_ + _tmp4_;
#line 444 "gitg-convert.c"
	}
#line 1333 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp5_ = end;
#line 1333 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	if (_tmp5_ < ((glong) 0)) {
#line 450 "gitg-convert.c"
		glong _tmp6_ = 0L;
		glong _tmp7_ = 0L;
#line 1334 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp6_ = string_length;
#line 1334 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp7_ = end;
#line 1334 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		end = _tmp6_ + _tmp7_;
#line 459 "gitg-convert.c"
	}
#line 1336 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp9_ = start;
#line 1336 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	if (_tmp9_ >= ((glong) 0)) {
#line 465 "gitg-convert.c"
		glong _tmp10_ = 0L;
		glong _tmp11_ = 0L;
#line 1336 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp10_ = start;
#line 1336 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp11_ = string_length;
#line 1336 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp8_ = _tmp10_ <= _tmp11_;
#line 474 "gitg-convert.c"
	} else {
#line 1336 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp8_ = FALSE;
#line 478 "gitg-convert.c"
	}
#line 1336 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	g_return_val_if_fail (_tmp8_, NULL);
#line 1337 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp13_ = end;
#line 1337 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	if (_tmp13_ >= ((glong) 0)) {
#line 486 "gitg-convert.c"
		glong _tmp14_ = 0L;
		glong _tmp15_ = 0L;
#line 1337 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp14_ = end;
#line 1337 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp15_ = string_length;
#line 1337 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp12_ = _tmp14_ <= _tmp15_;
#line 495 "gitg-convert.c"
	} else {
#line 1337 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
		_tmp12_ = FALSE;
#line 499 "gitg-convert.c"
	}
#line 1337 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	g_return_val_if_fail (_tmp12_, NULL);
#line 1338 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp16_ = start;
#line 1338 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp17_ = end;
#line 1338 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	g_return_val_if_fail (_tmp16_ <= _tmp17_, NULL);
#line 1339 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp18_ = start;
#line 1339 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp19_ = end;
#line 1339 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp20_ = start;
#line 1339 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	_tmp21_ = g_strndup (((gchar*) self) + _tmp18_, (gsize) (_tmp19_ - _tmp20_));
#line 1339 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	result = _tmp21_;
#line 1339 "/usr/share/vala-0.32/vapi/glib-2.0.vapi"
	return result;
#line 521 "gitg-convert.c"
}


gchar* gitg_convert_utf8 (const gchar* str, gssize size, const gchar* from_charset) {
	gchar* result = NULL;
	gssize _tmp0_ = 0L;
	const gchar* _tmp4_ = NULL;
	gchar* locale_charset = NULL;
	const gchar* _tmp22_ = NULL;
	gboolean _tmp23_ = FALSE;
	gchar* _tmp24_ = NULL;
	const gchar* _tmp30_ = NULL;
	gssize _tmp31_ = 0L;
	gchar* _tmp32_ = NULL;
#line 90 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	g_return_val_if_fail (str != NULL, NULL);
#line 92 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp0_ = size;
#line 92 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	if (_tmp0_ == ((gssize) -1)) {
#line 542 "gitg-convert.c"
		const gchar* _tmp1_ = NULL;
		gint _tmp2_ = 0;
		gint _tmp3_ = 0;
#line 94 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp1_ = str;
#line 94 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp2_ = strlen (_tmp1_);
#line 94 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp3_ = _tmp2_;
#line 94 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		size = (gssize) _tmp3_;
#line 554 "gitg-convert.c"
	}
#line 97 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp4_ = from_charset;
#line 97 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	if (_tmp4_ == NULL) {
#line 560 "gitg-convert.c"
		const gchar* _tmp5_ = NULL;
		gssize _tmp6_ = 0L;
		gboolean _tmp7_ = FALSE;
#line 99 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp5_ = str;
#line 99 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp6_ = size;
#line 99 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp7_ = g_utf8_validate (_tmp5_, _tmp6_, NULL);
#line 99 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		if (_tmp7_) {
#line 572 "gitg-convert.c"
			const gchar* _tmp8_ = NULL;
			gssize _tmp9_ = 0L;
			gchar* _tmp10_ = NULL;
#line 101 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp8_ = str;
#line 101 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp9_ = size;
#line 101 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp10_ = string_slice (_tmp8_, (glong) 0, (glong) _tmp9_);
#line 101 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			result = _tmp10_;
#line 101 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			return result;
#line 586 "gitg-convert.c"
		}
	} else {
		gchar* ret = NULL;
		const gchar* _tmp11_ = NULL;
		gint _tmp12_ = 0;
		const gchar* _tmp17_ = NULL;
		gssize _tmp18_ = 0L;
		const gchar* _tmp19_ = NULL;
		gchar* _tmp20_ = NULL;
		gboolean _tmp21_ = FALSE;
#line 108 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp11_ = from_charset;
#line 108 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp12_ = g_ascii_strcasecmp (_tmp11_, "UTF-8");
#line 108 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		if (_tmp12_ == 0) {
#line 603 "gitg-convert.c"
			const gchar* _tmp13_ = NULL;
			gssize _tmp14_ = 0L;
			gchar* _tmp15_ = NULL;
			gssize _tmp16_ = 0L;
#line 110 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp13_ = str;
#line 110 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp14_ = size;
#line 110 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp15_ = string_slice (_tmp13_, (glong) 0, (glong) _tmp14_);
#line 110 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_g_free0 (ret);
#line 110 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			ret = _tmp15_;
#line 111 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_tmp16_ = size;
#line 111 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			gitg_convert_utf8_validate_fallback (&ret, _tmp16_);
#line 113 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			result = ret;
#line 113 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			return result;
#line 626 "gitg-convert.c"
		}
#line 116 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp17_ = str;
#line 116 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp18_ = size;
#line 116 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp19_ = from_charset;
#line 116 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp21_ = gitg_convert_convert_and_check (_tmp17_, _tmp18_, _tmp19_, &_tmp20_);
#line 116 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_g_free0 (ret);
#line 116 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		ret = _tmp20_;
#line 116 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		if (_tmp21_) {
#line 118 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			result = ret;
#line 118 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			return result;
#line 646 "gitg-convert.c"
		}
#line 97 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_g_free0 (ret);
#line 650 "gitg-convert.c"
	}
#line 124 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp23_ = g_get_charset (&_tmp22_);
#line 124 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_g_free0 (locale_charset);
#line 124 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp24_ = g_strdup (_tmp22_);
#line 124 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	locale_charset = _tmp24_;
#line 124 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	if (!_tmp23_) {
#line 662 "gitg-convert.c"
		gchar* ret = NULL;
		const gchar* _tmp25_ = NULL;
		gssize _tmp26_ = 0L;
		const gchar* _tmp27_ = NULL;
		gchar* _tmp28_ = NULL;
		gboolean _tmp29_ = FALSE;
#line 128 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp25_ = str;
#line 128 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp26_ = size;
#line 128 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp27_ = locale_charset;
#line 128 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_tmp29_ = gitg_convert_convert_and_check (_tmp25_, _tmp26_, _tmp27_, &_tmp28_);
#line 128 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_g_free0 (ret);
#line 128 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		ret = _tmp28_;
#line 128 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		if (_tmp29_) {
#line 130 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			result = ret;
#line 130 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			_g_free0 (locale_charset);
#line 130 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
			return result;
#line 689 "gitg-convert.c"
		}
#line 124 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
		_g_free0 (ret);
#line 693 "gitg-convert.c"
	}
#line 134 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp30_ = str;
#line 134 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp31_ = size;
#line 134 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_tmp32_ = gitg_convert_convert_fallback (_tmp30_, _tmp31_, "?");
#line 134 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	result = _tmp32_;
#line 134 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	_g_free0 (locale_charset);
#line 134 "/home/jesse/dev/gitg/gitg/gitg-convert.vala"
	return result;
#line 707 "gitg-convert.c"
}



