summaryrefslogtreecommitdiff
path: root/tests/posix/string-concat.c-expected
blob: 686f5d8b443ce850022c0620dd8a908031f46b45 (plain)
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
/* posix_string_concat.c generated by valac, the Vala compiler
 * generated from posix_string_concat.vala, do not modify */

#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <assert.h>

#if !defined(VALA_EXTERN)
#if defined(_WIN32) || defined(__CYGWIN__)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _free0(var) ((var == NULL) ? NULL : (var = (free (var), NULL)))

VALA_EXTERN const char* get_foo (void);
static void _vala_main (void);

const char*
get_foo (void)
{
	const char* result;
	result = "foo";
	return result;
}

static int
_strcmp0 (const void * s1,
          const void * s2)
{
	if (!s1) {
		return -(s1 != s2);
	}
	if (!s2) {
		return s1 != s2;
	}
	return strcmp (s1, s2);
}

static void
_vala_main (void)
{
	char* s = NULL;
	const char* _tmp0_;
	char* _tmp1_;
	char* _tmp2_;
	char* _tmp3_;
	char* _tmp4_;
	_tmp0_ = get_foo ();
	_tmp1_ = strcat (strcpy (malloc (1 + (strlen (_tmp0_) + strlen ("bar"))), _tmp0_), "bar");
	_tmp2_ = _tmp1_;
	_tmp3_ = strcat (strcpy (malloc (1 + (strlen (_tmp2_) + strlen ("!"))), _tmp2_), "!");
	_tmp4_ = _tmp3_;
	_free0 (_tmp2_);
	s = _tmp4_;
	assert (_strcmp0 (s, "foobar!") == 0);
	_free0 (s);
}

int
main (int argc,
      char ** argv)
{
	_vala_main ();
	return 0;
}