~ubuntu-desktop/unity-lens-applications/ubuntu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
/* utils.c generated by valac 0.14.2, the Vala compiler
 * generated from utils.vala, do not modify */

/*
 * Copyright (C) 2010 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
 *
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <unity.h>
#include <gee.h>
#include <dee-icu.h>
#include <pwd.h>

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _dee_icu_term_filter_destroy0(var) ((var == NULL) ? NULL : (var = (dee_icu_term_filter_destroy (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))


extern DeeICUTermFilter* unity_applications_lens_utils_icu_filter;
DeeICUTermFilter* unity_applications_lens_utils_icu_filter = NULL;
extern GRegex* unity_applications_lens_utils_camelcase_matcher;
GRegex* unity_applications_lens_utils_camelcase_matcher = NULL;

GAppInfo* unity_applications_lens_utils_get_app_info_for_actor (const gchar* actor);
gchar* unity_applications_lens_utils_get_desktop_id_for_actor (const gchar* actor);
gboolean unity_applications_lens_utils_check_actor_has_category (const gchar* actor, GeeSet* categories);
gboolean unity_applications_lens_utils_is_search_empty (UnityLensSearch* search);
gchar* unity_applications_lens_utils_preprocess_string (const gchar* text);
gchar* unity_applications_lens_utils_uncamelcase (const gchar* text);
static gboolean ___lambda11_ (GMatchInfo* mi, GString* builder);
static gboolean ____lambda11__gregex_eval_callback (GMatchInfo* match_info, GString* _result_, gpointer self);
gchar* unity_applications_lens_utils_subst_tilde (const gchar* s);


GAppInfo* unity_applications_lens_utils_get_app_info_for_actor (const gchar* actor) {
	GAppInfo* result = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* desktop_id;
	UnityAppInfoManager* _tmp2_ = NULL;
	UnityAppInfoManager* _tmp3_;
	GAppInfo* _tmp4_ = NULL;
	GAppInfo* _tmp5_;
	g_return_val_if_fail (actor != NULL, NULL);
	_tmp0_ = actor;
	_tmp1_ = unity_applications_lens_utils_get_desktop_id_for_actor (_tmp0_);
	desktop_id = _tmp1_;
	_tmp2_ = unity_app_info_manager_get_default ();
	_tmp3_ = _tmp2_;
	_tmp4_ = unity_app_info_manager_lookup (_tmp3_, desktop_id);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp3_);
	result = _tmp5_;
	_g_free0 (desktop_id);
	return result;
}


gboolean unity_applications_lens_utils_check_actor_has_category (const gchar* actor, GeeSet* categories) {
	gboolean result = FALSE;
	GeeSet* _tmp0_;
	UnityAppInfoManager* _tmp1_ = NULL;
	UnityAppInfoManager* appman;
	const gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* desktop_id;
	UnityAppInfoManager* _tmp4_;
	const gchar* _tmp5_;
	GAppInfo* _tmp6_ = NULL;
	GAppInfo* appinfo;
	GAppInfo* _tmp7_;
	UnityAppInfoManager* _tmp8_;
	const gchar* _tmp9_;
	gint _tmp10_ = 0;
	gchar** _tmp11_ = NULL;
	gchar** actor_cats;
	gint actor_cats_length1;
	gint _actor_cats_size_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	gchar** _tmp13_;
	gint _tmp13__length1;
	g_return_val_if_fail (actor != NULL, FALSE);
	_tmp0_ = categories;
	if (_tmp0_ == NULL) {
		result = FALSE;
		return result;
	}
	_tmp1_ = unity_app_info_manager_get_default ();
	appman = _tmp1_;
	_tmp2_ = actor;
	_tmp3_ = unity_applications_lens_utils_get_desktop_id_for_actor (_tmp2_);
	desktop_id = _tmp3_;
	_tmp4_ = appman;
	_tmp5_ = desktop_id;
	_tmp6_ = unity_app_info_manager_lookup (_tmp4_, _tmp5_);
	appinfo = _tmp6_;
	_tmp7_ = appinfo;
	if (_tmp7_ == NULL) {
		result = FALSE;
		_g_object_unref0 (appinfo);
		_g_free0 (desktop_id);
		_g_object_unref0 (appman);
		return result;
	}
	_tmp8_ = appman;
	_tmp9_ = desktop_id;
	_tmp11_ = unity_app_info_manager_get_categories (_tmp8_, _tmp9_, &_tmp10_);
	actor_cats = _tmp11_;
	actor_cats_length1 = _tmp10_;
	_actor_cats_size_ = actor_cats_length1;
	_tmp12_ = actor_cats;
	_tmp12__length1 = actor_cats_length1;
	if (_tmp12_ == NULL) {
		result = FALSE;
		_g_object_unref0 (appinfo);
		_g_free0 (desktop_id);
		_g_object_unref0 (appman);
		return result;
	}
	_tmp13_ = actor_cats;
	_tmp13__length1 = actor_cats_length1;
	{
		gchar** cat_collection = NULL;
		gint cat_collection_length1 = 0;
		gint _cat_collection_size_ = 0;
		gint cat_it = 0;
		cat_collection = _tmp13_;
		cat_collection_length1 = _tmp13__length1;
		for (cat_it = 0; cat_it < _tmp13__length1; cat_it = cat_it + 1) {
			gchar* _tmp14_;
			gchar* cat = NULL;
			_tmp14_ = g_strdup (cat_collection[cat_it]);
			cat = _tmp14_;
			{
				GeeSet* _tmp15_;
				const gchar* _tmp16_;
				gboolean _tmp17_ = FALSE;
				_tmp15_ = categories;
				_tmp16_ = cat;
				_tmp17_ = gee_collection_contains ((GeeCollection*) _tmp15_, _tmp16_);
				if (_tmp17_) {
					result = TRUE;
					_g_free0 (cat);
					_g_object_unref0 (appinfo);
					_g_free0 (desktop_id);
					_g_object_unref0 (appman);
					return result;
				}
				_g_free0 (cat);
			}
		}
	}
	result = FALSE;
	_g_object_unref0 (appinfo);
	_g_free0 (desktop_id);
	_g_object_unref0 (appman);
	return result;
}


static glong string_strnlen (gchar* str, glong maxlen) {
	glong result = 0L;
	gchar* _tmp0_;
	glong _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* end;
	gchar* _tmp3_;
	_tmp0_ = str;
	_tmp1_ = maxlen;
	_tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
	end = _tmp2_;
	_tmp3_ = end;
	if (_tmp3_ == NULL) {
		glong _tmp4_;
		_tmp4_ = maxlen;
		result = _tmp4_;
		return result;
	} else {
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp5_ = end;
		_tmp6_ = str;
		result = (glong) (_tmp5_ - _tmp6_);
		return result;
	}
}


static gchar* string_substring (const gchar* self, glong offset, glong len) {
	gchar* result = NULL;
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	glong _tmp1_;
	gboolean _tmp3_;
	glong _tmp9_;
	glong _tmp15_;
	glong _tmp18_;
	glong _tmp19_;
	glong _tmp20_;
	glong _tmp21_;
	glong _tmp22_;
	gchar* _tmp23_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = offset;
	if (_tmp1_ >= ((glong) 0)) {
		glong _tmp2_;
		_tmp2_ = len;
		_tmp0_ = _tmp2_ >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	_tmp3_ = _tmp0_;
	if (_tmp3_) {
		glong _tmp4_;
		glong _tmp5_;
		glong _tmp6_ = 0L;
		_tmp4_ = offset;
		_tmp5_ = len;
		_tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_);
		string_length = _tmp6_;
	} else {
		gint _tmp7_;
		gint _tmp8_;
		_tmp7_ = strlen (self);
		_tmp8_ = _tmp7_;
		string_length = (glong) _tmp8_;
	}
	_tmp9_ = offset;
	if (_tmp9_ < ((glong) 0)) {
		glong _tmp10_;
		glong _tmp11_;
		glong _tmp12_;
		_tmp10_ = string_length;
		_tmp11_ = offset;
		offset = _tmp10_ + _tmp11_;
		_tmp12_ = offset;
		g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL);
	} else {
		glong _tmp13_;
		glong _tmp14_;
		_tmp13_ = offset;
		_tmp14_ = string_length;
		g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL);
	}
	_tmp15_ = len;
	if (_tmp15_ < ((glong) 0)) {
		glong _tmp16_;
		glong _tmp17_;
		_tmp16_ = string_length;
		_tmp17_ = offset;
		len = _tmp16_ - _tmp17_;
	}
	_tmp18_ = offset;
	_tmp19_ = len;
	_tmp20_ = string_length;
	g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL);
	_tmp21_ = offset;
	_tmp22_ = len;
	_tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_);
	result = _tmp23_;
	return result;
}


gchar* unity_applications_lens_utils_get_desktop_id_for_actor (const gchar* actor) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	g_return_val_if_fail (actor != NULL, NULL);
	_tmp0_ = actor;
	_tmp1_ = g_str_has_prefix (_tmp0_, "application://");
	if (_tmp1_) {
		const gchar* _tmp2_;
		gchar* _tmp3_ = NULL;
		_tmp2_ = actor;
		_tmp3_ = string_substring (_tmp2_, (glong) 14, (glong) (-1));
		result = _tmp3_;
		return result;
	} else {
		const gchar* _tmp4_;
		gboolean _tmp5_ = FALSE;
		_tmp4_ = actor;
		_tmp5_ = g_str_has_prefix (_tmp4_, "app://");
		if (_tmp5_) {
			const gchar* _tmp6_;
			gchar* _tmp7_ = NULL;
			_tmp6_ = actor;
			_tmp7_ = string_substring (_tmp6_, (glong) 6, (glong) (-1));
			result = _tmp7_;
			return result;
		} else {
			const gchar* _tmp8_;
			gboolean _tmp9_ = FALSE;
			_tmp8_ = actor;
			_tmp9_ = g_str_has_prefix (_tmp8_, "/");
			if (_tmp9_) {
				const gchar* _tmp10_;
				gchar* _tmp11_ = NULL;
				_tmp10_ = actor;
				_tmp11_ = g_path_get_basename (_tmp10_);
				result = _tmp11_;
				return result;
			}
		}
	}
	_tmp12_ = actor;
	_tmp13_ = g_strdup (_tmp12_);
	result = _tmp13_;
	return result;
}


gboolean unity_applications_lens_utils_is_search_empty (UnityLensSearch* search) {
	gboolean result = FALSE;
	UnityLensSearch* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	UnityLensSearch* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	g_return_val_if_fail (search != NULL, FALSE);
	_tmp0_ = search;
	_tmp1_ = unity_lens_search_get_search_string (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		result = TRUE;
		return result;
	}
	_tmp3_ = search;
	_tmp4_ = unity_lens_search_get_search_string (_tmp3_);
	_tmp5_ = _tmp4_;
	result = g_strcmp0 (_tmp5_, "") == 0;
	return result;
}


gchar* unity_applications_lens_utils_preprocess_string (const gchar* text) {
	gchar* result = NULL;
	DeeICUTermFilter* _tmp0_;
	const gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* uncamelcased;
	DeeICUTermFilter* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_ = NULL;
	gchar* folded;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_ = NULL;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = unity_applications_lens_utils_icu_filter;
	if (_tmp0_ == NULL) {
		DeeICUTermFilter* _tmp1_;
		_tmp1_ = dee_icu_term_filter_new_ascii_folder ();
		_dee_icu_term_filter_destroy0 (unity_applications_lens_utils_icu_filter);
		unity_applications_lens_utils_icu_filter = _tmp1_;
	}
	_tmp2_ = text;
	_tmp3_ = unity_applications_lens_utils_uncamelcase (_tmp2_);
	uncamelcased = _tmp3_;
	_tmp4_ = unity_applications_lens_utils_icu_filter;
	_tmp5_ = uncamelcased;
	_tmp6_ = dee_icu_term_filter_apply (_tmp4_, _tmp5_);
	folded = _tmp6_;
	_tmp7_ = uncamelcased;
	_tmp8_ = folded;
	if (g_strcmp0 (_tmp7_, _tmp8_) == 0) {
		result = uncamelcased;
		_g_free0 (folded);
		return result;
	}
	_tmp9_ = uncamelcased;
	_tmp10_ = folded;
	_tmp11_ = g_strdup_printf ("%s\n%s", _tmp9_, _tmp10_);
	result = _tmp11_;
	_g_free0 (folded);
	_g_free0 (uncamelcased);
	return result;
}


static gboolean ___lambda11_ (GMatchInfo* mi, GString* builder) {
	gboolean result = FALSE;
	gint start_pos = 0;
	GMatchInfo* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_;
	GString* _tmp4_;
	GMatchInfo* _tmp5_;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_;
	g_return_val_if_fail (mi != NULL, FALSE);
	g_return_val_if_fail (builder != NULL, FALSE);
	_tmp0_ = mi;
	g_match_info_fetch_pos (_tmp0_, 0, &_tmp1_, NULL);
	start_pos = _tmp1_;
	_tmp2_ = start_pos;
	if (_tmp2_ != 0) {
		GString* _tmp3_;
		_tmp3_ = builder;
		g_string_append_c (_tmp3_, ' ');
	}
	_tmp4_ = builder;
	_tmp5_ = mi;
	_tmp6_ = g_match_info_fetch (_tmp5_, 0);
	_tmp7_ = _tmp6_;
	g_string_append (_tmp4_, _tmp7_);
	_g_free0 (_tmp7_);
	result = FALSE;
	return result;
}


static gboolean ____lambda11__gregex_eval_callback (GMatchInfo* match_info, GString* _result_, gpointer self) {
	gboolean result;
	result = ___lambda11_ (match_info, _result_);
	return result;
}


gchar* unity_applications_lens_utils_uncamelcase (const gchar* text) {
	gchar* result = NULL;
	GRegex* _tmp0_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = unity_applications_lens_utils_camelcase_matcher;
	if (_tmp0_ == NULL) {
		{
			GRegex* _tmp1_;
			GRegex* _tmp2_;
			_tmp1_ = g_regex_new ("(?<=^|[^[:upper:]\\s])[[:upper:]]+[^[:upper:]]+", G_REGEX_OPTIMIZE, 0, &_inner_error_);
			_tmp2_ = _tmp1_;
			if (_inner_error_ != NULL) {
				goto __catch16_g_error;
			}
			_g_regex_unref0 (unity_applications_lens_utils_camelcase_matcher);
			unity_applications_lens_utils_camelcase_matcher = _tmp2_;
		}
		goto __finally16;
		__catch16_g_error:
		{
			GError* e = NULL;
			GError* _tmp3_;
			const gchar* _tmp4_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp3_ = e;
			_tmp4_ = _tmp3_->message;
			g_warning ("utils.vala:109: %s", _tmp4_);
			_g_error_free0 (e);
		}
		__finally16:
		if (_inner_error_ != NULL) {
			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);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	{
		gchar* _result_ = NULL;
		GRegex* _tmp5_;
		const gchar* _tmp6_;
		gchar* _tmp7_ = NULL;
		gchar* _tmp8_;
		_tmp5_ = unity_applications_lens_utils_camelcase_matcher;
		_tmp6_ = text;
		_tmp7_ = g_regex_replace_eval (_tmp5_, _tmp6_, (gssize) (-1), 0, 0, ____lambda11__gregex_eval_callback, NULL, &_inner_error_);
		_tmp8_ = _tmp7_;
		if (_inner_error_ != NULL) {
			_g_free0 (_result_);
			goto __catch17_g_error;
		}
		_g_free0 (_result_);
		_result_ = _tmp8_;
		result = _result_;
		return result;
	}
	goto __finally17;
	__catch17_g_error:
	{
		GError* e = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		g_warning ("utils.vala:131: %s", _tmp10_);
		_tmp11_ = text;
		_tmp12_ = g_strdup (_tmp11_);
		result = _tmp12_;
		_g_error_free0 (e);
		return result;
	}
	__finally17:
	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);
	g_clear_error (&_inner_error_);
	return NULL;
}


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


static gint string_index_of (const gchar* self, const gchar* needle, gint start_index) {
	gint result = 0;
	gint _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _result_;
	gchar* _tmp3_;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (needle != NULL, 0);
	_tmp0_ = start_index;
	_tmp1_ = needle;
	_tmp2_ = strstr (((gchar*) self) + _tmp0_, (gchar*) _tmp1_);
	_result_ = _tmp2_;
	_tmp3_ = _result_;
	if (_tmp3_ != NULL) {
		gchar* _tmp4_;
		_tmp4_ = _result_;
		result = (gint) (_tmp4_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}


gchar* unity_applications_lens_utils_subst_tilde (const gchar* s) {
	gchar* result = NULL;
	gint k = 0;
	gchar* name = NULL;
	struct passwd* pw = NULL;
	const gchar* _tmp0_;
	gchar _tmp1_ = '\0';
	gboolean _tmp4_ = FALSE;
	const gchar* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	gboolean _tmp10_;
	const gchar* _tmp17_;
	gint _tmp18_ = 0;
	gint _tmp19_;
	const gchar* _tmp25_;
	struct passwd* _tmp26_ = NULL;
	struct passwd* _tmp27_;
	gint _tmp30_;
	g_return_val_if_fail (s != NULL, NULL);
	_tmp0_ = s;
	_tmp1_ = string_get (_tmp0_, (glong) 0);
	if (_tmp1_ != '~') {
		const gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = s;
		_tmp3_ = g_strdup (_tmp2_);
		result = _tmp3_;
		_g_free0 (name);
		return result;
	}
	_tmp5_ = s;
	_tmp6_ = strlen (_tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp7_ == 1) {
		_tmp4_ = TRUE;
	} else {
		const gchar* _tmp8_;
		gchar _tmp9_ = '\0';
		_tmp8_ = s;
		_tmp9_ = string_get (_tmp8_, (glong) 1);
		_tmp4_ = _tmp9_ == '/';
	}
	_tmp10_ = _tmp4_;
	if (_tmp10_) {
		const gchar* _tmp11_ = NULL;
		const gchar* _tmp12_;
		gchar* _tmp13_ = NULL;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp11_ = g_get_home_dir ();
		_tmp12_ = s;
		_tmp13_ = string_substring (_tmp12_, (glong) 1, (glong) (-1));
		_tmp14_ = _tmp13_;
		_tmp15_ = g_strconcat (_tmp11_, _tmp14_, NULL);
		_tmp16_ = _tmp15_;
		_g_free0 (_tmp14_);
		result = _tmp16_;
		_g_free0 (name);
		return result;
	}
	_tmp17_ = s;
	_tmp18_ = string_index_of (_tmp17_, "/", 0);
	k = _tmp18_;
	_tmp19_ = k;
	if (_tmp19_ == (-1)) {
		const gchar* _tmp20_;
		gchar* _tmp21_ = NULL;
		_tmp20_ = s;
		_tmp21_ = string_substring (_tmp20_, (glong) 1, (glong) (-1));
		_g_free0 (name);
		name = _tmp21_;
	} else {
		const gchar* _tmp22_;
		gint _tmp23_;
		gchar* _tmp24_ = NULL;
		_tmp22_ = s;
		_tmp23_ = k;
		_tmp24_ = string_substring (_tmp22_, (glong) 1, (glong) (_tmp23_ - 1));
		_g_free0 (name);
		name = _tmp24_;
	}
	_tmp25_ = name;
	_tmp26_ = getpwnam (_tmp25_);
	pw = _tmp26_;
	_tmp27_ = pw;
	if (_tmp27_ == NULL) {
		const gchar* _tmp28_;
		gchar* _tmp29_;
		_tmp28_ = s;
		_tmp29_ = g_strdup (_tmp28_);
		result = _tmp29_;
		_g_free0 (name);
		return result;
	}
	_tmp30_ = k;
	if (_tmp30_ == (-1)) {
		struct passwd* _tmp31_;
		const gchar* _tmp32_;
		gchar* _tmp33_;
		_tmp31_ = pw;
		_tmp32_ = _tmp31_->pw_dir;
		_tmp33_ = g_strdup (_tmp32_);
		result = _tmp33_;
		_g_free0 (name);
		return result;
	} else {
		struct passwd* _tmp34_;
		const gchar* _tmp35_;
		const gchar* _tmp36_;
		gint _tmp37_;
		gchar* _tmp38_ = NULL;
		gchar* _tmp39_;
		gchar* _tmp40_;
		gchar* _tmp41_;
		_tmp34_ = pw;
		_tmp35_ = _tmp34_->pw_dir;
		_tmp36_ = s;
		_tmp37_ = k;
		_tmp38_ = string_substring (_tmp36_, (glong) _tmp37_, (glong) (-1));
		_tmp39_ = _tmp38_;
		_tmp40_ = g_strconcat (_tmp35_, _tmp39_, NULL);
		_tmp41_ = _tmp40_;
		_g_free0 (_tmp39_);
		result = _tmp41_;
		_g_free0 (name);
		return result;
	}
	_g_free0 (name);
}