summaryrefslogtreecommitdiff
path: root/lexer/symbol.c
blob: 7a8001f8af0367b29ed4a7d6f1ee0ce244085058 (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
/* Name: make_local_label()
 * Desc: Constructs a local label of the form:
 *	 " " + global_name + " " + local_name
 * Args:
 *	global: Global label name.
 *	global_len: Length of Global label name.
 *	local: Local label name.
 *	local_len: Length of Local label name.
 * Return value: Returns the constructed local label.
 */

char make_local_label(char *global, int global_len, char *local, int local_len) {
	char *name;
	char *p;

	if (!global_len) {
		/* Use last defined global. */
		global = last_global;
		global_len = strlen(last_global);
	}
	name = malloc(local_len+global_len+3);
	p = name;
	*p++ = ' ';
	if (global_len) {
		memcpy(p, global, global_len);
		p += global_len;
	}
	*p++ = ' ';
	memcpy(p, local, local_len);
	p[local_len] = '\0';
	return name;
}

/* Name:
 * Desc:
 * Args:
 *
 *
 *
 *
 * Return value:
 */