summaryrefslogtreecommitdiff
path: root/doc/common.c
blob: 492f9b969e24cbe07b0c3b71b37a116d97cf0861 (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
char *escape_string(const char *str, char *buffer, int buffer_size)
{
	int i = 0, j = 0;


	while (str[i] != 0 && j < buffer_size - 1) {
		if (str[i] == '_') {
			buffer[j++] = '\\';
			buffer[j++] = '_';
			buffer[j++] = '\\';
			buffer[j++] = '-';
		} else if (str[i] == '#') {
			buffer[j++] = '\\';
			buffer[j++] = '#';
		} else {
			buffer[j++] = str[i];
		}
		i++;
	};

	buffer[j] = 0;

	return buffer;

}

char *escape_texi_string(const char *str, char *buffer, int buffer_size)
{
	int i = 0, j = 0;


	while (str[i] != 0 && j < buffer_size - 1) {
		if (str[i] == '_') {
			buffer[j++] = '_';
			buffer[j++] = '@';
			buffer[j++] = '-';
		} else {
			buffer[j++] = str[i];
		}
		i++;
	};

	buffer[j] = 0;

	return buffer;

}