blob: 9e0cd27a521ffacb07d8c9a0ab71eef9008296d0 (
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
111
112
113
114
115
116
117
118
119
120
121
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>rwprtf.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>rwprtf.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> *</font>
00003 <font class="comment"> * rwprtf - SWFilter decendant to convert all GBF tags to RTF tags</font>
00004 <font class="comment"> */</font>
00005
00006
00007 <font class="preprocessor">#include <stdlib.h></font>
00008 <font class="preprocessor">#include <string.h></font>
00009 <font class="preprocessor">#include <rwprtf.h></font>
00010
00011
00012 RWPRTF::RWPRTF() {
00013
00014 }
00015
00016
00017 <font class="keywordtype">char</font> RWPRTF::ProcessText(<font class="keywordtype">char</font> *text, <font class="keywordtype">int</font> maxlen, <font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *key, <font class="keyword">const</font> <a class="code" href="class_s_w_module.html">SWModule</a> *module)
00018 {
00019 <font class="keywordtype">char</font> *to, *from;
00020 <font class="keywordtype">bool</font> ingreek = <font class="keyword">false</font>;
00021 <font class="keywordtype">bool</font> inverse = <font class="keyword">false</font>;
00022 <font class="keywordtype">int</font> len;
00023
00024 len = strlen(text) + 1; <font class="comment">// shift string to right of buffer</font>
00025 <font class="keywordflow">if</font> (len < maxlen) {
00026 memmove(&text[maxlen - len], text, len);
00027 from = &text[maxlen - len];
00028 }
00029 <font class="keywordflow">else</font> from = text; <font class="comment">// -------------------------------</font>
00030 <font class="keywordflow">for</font> (to = text; *from; from++) {
00031 <font class="keywordflow">if</font> (*from == <font class="charliteral">'\\'</font>) {
00032 <font class="keywordflow">if</font>(!ingreek) {
00033 ingreek = <font class="keyword">true</font>;
00034 *to++ = <font class="charliteral">'['</font>;
00035 *to++ = <font class="charliteral">'{'</font>;
00036 *to++ = <font class="charliteral">'\\'</font>;
00037 *to++ = <font class="charliteral">'f'</font>;
00038 *to++ = <font class="charliteral">'8'</font>;
00039 *to++ = <font class="charliteral">' '</font>;
00040 <font class="keywordflow">continue</font>;
00041 }
00042 <font class="keywordflow">else</font> {
00043 ingreek = <font class="keyword">false</font>;
00044 *to++ = <font class="charliteral">'}'</font>;
00045 *to++ = <font class="charliteral">']'</font>;
00046 <font class="keywordflow">continue</font>;
00047 }
00048 }
00049
00050 <font class="keywordflow">if</font> ((ingreek) && ((*from == <font class="charliteral">'h'</font>) || (*from == <font class="charliteral">'H'</font>)))
00051 <font class="keywordflow">continue</font>; <font class="comment">// 'h's are mostly useless in RWP translitterations. The greek is more correct without them.</font>
00052
00053 <font class="keywordflow">if</font> (*from == <font class="charliteral">'#'</font>) { <font class="comment">// verse markings (e.g. "#Mark 1:1|")</font>
00054 inverse = <font class="keyword">true</font>;
00055 *to++ = <font class="charliteral">'{'</font>;
00056 *to++ = <font class="charliteral">'\\'</font>;
00057 *to++ = <font class="charliteral">'c'</font>;
00058 *to++ = <font class="charliteral">'f'</font>;
00059 *to++ = <font class="charliteral">'2'</font>;
00060 *to++ = <font class="charliteral">' '</font>;
00061 *to++ = <font class="charliteral">'#'</font>;
00062 <font class="keywordflow">continue</font>;
00063 }
00064 <font class="keywordflow">if</font> ((*from == <font class="charliteral">'|'</font>) && (inverse)) {
00065 inverse = <font class="keyword">false</font>;
00066 *to++ = <font class="charliteral">'|'</font>;
00067 *to++ = <font class="charliteral">'}'</font>;
00068 <font class="keywordflow">continue</font>;
00069 }
00070
00071 <font class="keywordflow">if</font> (*from == <font class="charliteral">'{'</font>) {
00072 *to++ = <font class="charliteral">'{'</font>;
00073 *to++ = <font class="charliteral">'\\'</font>;
00074 *to++ = <font class="charliteral">'b'</font>;
00075 *to++ = <font class="charliteral">' '</font>;
00076 <font class="keywordflow">if</font> ((from - &text[maxlen - len]) > 10) { <font class="comment">// not the beginning of the entry</font>
00077 *to++ = <font class="charliteral">'\\'</font>;
00078 *to++ = <font class="charliteral">'p'</font>;
00079 *to++ = <font class="charliteral">'a'</font>;
00080 *to++ = <font class="charliteral">'r'</font>;
00081 *to++ = <font class="charliteral">' '</font>;
00082 }
00083 <font class="keywordflow">continue</font>;
00084 }
00085
00086 <font class="keywordflow">if</font> (*from == <font class="charliteral">'}'</font>) {
00087 <font class="comment">// this is kinda neat... DO NOTHING</font>
00088 }
00089 <font class="keywordflow">if</font> ((*from == <font class="charliteral">'\n'</font>) && (from[1] == <font class="charliteral">'\n'</font>)) {
00090 *to++ = <font class="charliteral">'\\'</font>;
00091 *to++ = <font class="charliteral">'p'</font>;
00092 *to++ = <font class="charliteral">'a'</font>;
00093 *to++ = <font class="charliteral">'r'</font>;
00094 *to++ = <font class="charliteral">'\\'</font>;
00095 *to++ = <font class="charliteral">'p'</font>;
00096 *to++ = <font class="charliteral">'a'</font>;
00097 *to++ = <font class="charliteral">'r'</font>;
00098 *to++ = <font class="charliteral">' '</font>;
00099 <font class="keywordflow">continue</font>;
00100 }
00101
00102 *to++ = *from;
00103 }
00104 *to++ = 0;
00105 *to = 0;
00106 <font class="keywordflow">return</font> 0;
00107 }
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:00 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>
|