summaryrefslogtreecommitdiff
path: root/doc/common.c
blob: 4ceaff80cb2acd5a51910a5a3bd292a20e45d3e2 (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;

}