blob: db87e78fd6f4c08928a6b7f05c9038e0990ca8d0 (
plain) (
blame)
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
|
/******************************************************************************
*
* rwprtf - SWFilter decendant to convert all GBF tags to RTF tags
*/
#include <stdlib.h>
#include <string.h>
#include <rwprtf.h>
SWORD_NAMESPACE_START
RWPRTF::RWPRTF() {
}
char RWPRTF::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
{
char *to, *from;
bool ingreek = false;
bool inverse = false;
int len;
len = strlen(text) + 1; // shift string to right of buffer
if (len < maxlen) {
memmove(&text[maxlen - len], text, len);
from = &text[maxlen - len];
}
else from = text; // -------------------------------
for (to = text; *from; from++) {
if (*from == '\\') {
if(!ingreek) {
ingreek = true;
*to++ = '[';
*to++ = '{';
*to++ = '\\';
*to++ = 'f';
*to++ = '8';
*to++ = ' ';
continue;
}
else {
ingreek = false;
*to++ = '}';
*to++ = ']';
continue;
}
}
if ((ingreek) && ((*from == 'h') || (*from == 'H')))
continue; // 'h's are mostly useless in RWP translitterations. The greek is more correct without them.
if (*from == '#') { // verse markings (e.g. "#Mark 1:1|")
inverse = true;
*to++ = '{';
*to++ = '\\';
*to++ = 'c';
*to++ = 'f';
*to++ = '2';
*to++ = ' ';
*to++ = '#';
continue;
}
if ((*from == '|') && (inverse)) {
inverse = false;
*to++ = '|';
*to++ = '}';
continue;
}
if (*from == '{') {
*to++ = '{';
*to++ = '\\';
*to++ = 'b';
*to++ = ' ';
if ((from - &text[maxlen - len]) > 10) { // not the beginning of the entry
*to++ = '\\';
*to++ = 'p';
*to++ = 'a';
*to++ = 'r';
*to++ = ' ';
}
continue;
}
if (*from == '}') {
// this is kinda neat... DO NOTHING
}
if ((*from == '\n') && (from[1] == '\n')) {
*to++ = '\\';
*to++ = 'p';
*to++ = 'a';
*to++ = 'r';
*to++ = '\\';
*to++ = 'p';
*to++ = 'a';
*to++ = 'r';
*to++ = ' ';
continue;
}
*to++ = *from;
}
*to++ = 0;
*to = 0;
return 0;
}
SWORD_NAMESPACE_END
|