]>
Commit | Line | Data |
---|---|---|
9a29912f JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: tex2any.cpp | |
3 | // Purpose: Utilities for Latex conversion. | |
4 | // Author: Julian Smart | |
b63b07a8 RL |
5 | // Modified by: Wlodzimiez ABX Skiba 2003/2004 Unicode support |
6 | // Ron Lee | |
9a29912f JS |
7 | // Created: 01/01/99 |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) Julian Smart | |
10 | // Licence: wxWindows licence | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifdef __GNUG__ | |
14 | #pragma implementation | |
15 | #endif | |
16 | ||
17 | // For compilers that support precompilation, includes "wx.h". | |
18 | #include "wx/wxprec.h" | |
19 | ||
20 | #ifdef __BORLANDC__ | |
21 | #pragma hdrstop | |
22 | #endif | |
23 | ||
24 | #ifndef WX_PRECOMP | |
9a29912f JS |
25 | #endif |
26 | ||
27 | #include <ctype.h> | |
28 | #include "tex2any.h" | |
29 | #include <stdlib.h> | |
30 | #include <time.h> | |
31 | ||
ea172e69 MB |
32 | #if !WXWIN_COMPATIBILITY_2_4 |
33 | static inline wxChar* copystring(const wxChar* s) | |
34 | { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); } | |
35 | #endif | |
36 | ||
9a29912f JS |
37 | /* |
38 | * Variables accessible from clients | |
39 | * | |
40 | */ | |
41 | ||
42 | TexChunk * DocumentTitle = NULL; | |
43 | TexChunk * DocumentAuthor = NULL; | |
44 | TexChunk * DocumentDate = NULL; | |
45 | ||
46 | // Header/footers/pagestyle | |
47 | TexChunk * LeftHeaderEven = NULL; | |
48 | TexChunk * LeftFooterEven = NULL; | |
49 | TexChunk * CentreHeaderEven = NULL; | |
50 | TexChunk * CentreFooterEven = NULL; | |
51 | TexChunk * RightHeaderEven = NULL; | |
52 | TexChunk * RightFooterEven = NULL; | |
53 | TexChunk * LeftHeaderOdd = NULL; | |
54 | TexChunk * LeftFooterOdd = NULL; | |
55 | TexChunk * CentreHeaderOdd = NULL; | |
56 | TexChunk * CentreFooterOdd = NULL; | |
57 | TexChunk * RightHeaderOdd = NULL; | |
58 | TexChunk * RightFooterOdd = NULL; | |
6c155d33 | 59 | wxChar * PageStyle = copystring(_T("plain")); |
9a29912f JS |
60 | |
61 | int DocumentStyle = LATEX_REPORT; | |
62 | int MinorDocumentStyle = 0; | |
63 | wxPathList TexPathList; | |
6c155d33 JS |
64 | wxChar * BibliographyStyleString = copystring(_T("plain")); |
65 | wxChar * DocumentStyleString = copystring(_T("report")); | |
66 | wxChar * MinorDocumentStyleString = NULL; | |
9a29912f JS |
67 | int ParSkip = 0; |
68 | int ParIndent = 0; | |
69 | ||
70 | int normalFont = 10; | |
71 | int smallFont = 8; | |
72 | int tinyFont = 6; | |
73 | int largeFont1 = 12; | |
74 | int LargeFont2 = 14; | |
75 | int LARGEFont3 = 18; | |
76 | int hugeFont1 = 20; | |
77 | int HugeFont2 = 24; | |
78 | int HUGEFont3 = 28; | |
79 | ||
fad535ee GT |
80 | // All of these tokens MUST be found on a line by themselves (no other |
81 | // text) and must start at the first character of the line, or tex2rtf | |
82 | // will fail to process them correctly (a limitation of tex2rtf, not TeX) | |
7cbe4e79 | 83 | static const wxString syntaxTokens[] = |
6c155d33 JS |
84 | { _T("\\begin{verbatim}"), |
85 | _T("\\begin{toocomplex}"), | |
86 | _T("\\end{verbatim}"), | |
87 | _T("\\end{toocomplex}"), | |
88 | _T("\\verb"), | |
89 | _T("\\begin{comment}"), | |
90 | _T("\\end{comment}"), | |
91 | _T("\\verbatiminput"), | |
92 | // _T("\\par"), | |
93 | _T("\\input"), | |
94 | _T("\\helpinput"), | |
95 | _T("\\include"), | |
fad535ee GT |
96 | wxEmptyString |
97 | }; | |
98 | ||
99 | ||
9a29912f JS |
100 | /* |
101 | * USER-ADJUSTABLE SETTINGS | |
102 | * | |
103 | */ | |
104 | ||
105 | // Section font sizes | |
106 | int chapterFont = 12; // LARGEFont3; | |
107 | int sectionFont = 12; // LargeFont2; | |
108 | int subsectionFont = 12; // largeFont1; | |
109 | int titleFont = LARGEFont3; | |
110 | int authorFont = LargeFont2; | |
b63b07a8 RL |
111 | int mirrorMargins = true; |
112 | bool winHelp = false; // Output in Windows Help format if TRUE, linear otherwise | |
113 | bool isInteractive = false; | |
114 | bool runTwice = false; | |
9a29912f | 115 | int convertMode = TEX_RTF; |
b63b07a8 RL |
116 | bool checkCurleyBraces = false; |
117 | bool checkSyntax = false; | |
118 | bool headerRule = false; | |
119 | bool footerRule = false; | |
120 | bool compatibilityMode = false; // If TRUE, maximum Latex compatibility | |
9a29912f JS |
121 | // (Quality of RTF generation deteriorate) |
122 | bool generateHPJ; // Generate WinHelp Help Project file | |
6c155d33 | 123 | wxChar *winHelpTitle = NULL; // Windows Help title |
9a29912f JS |
124 | int defaultTableColumnWidth = 2000; |
125 | ||
126 | int labelIndentTab = 18; // From left indent to item label (points) | |
127 | int itemIndentTab = 40; // From left indent to item (points) | |
128 | ||
b63b07a8 | 129 | bool useUpButton = true; |
9a29912f JS |
130 | int htmlBrowseButtons = HTML_BUTTONS_TEXT; |
131 | ||
b63b07a8 | 132 | bool truncateFilenames = false; // Truncate for DOS |
9a29912f | 133 | int winHelpVersion = 3; // WinHelp Version (3 for Windows 3.1, 4 for Win95) |
b63b07a8 RL |
134 | bool winHelpContents = false; // Generate .cnt file for WinHelp 4 |
135 | bool htmlIndex = false; // Generate .htx file for HTML | |
136 | bool htmlFrameContents = false; // Use frames for HTML contents page | |
6c155d33 | 137 | wxChar *htmlStylesheet = NULL; // Use this CSS stylesheet for HTML pages |
b63b07a8 RL |
138 | bool useHeadingStyles = true; // Insert \s1, s2 etc. |
139 | bool useWord = true; // Insert proper Word table of contents, etc etc | |
9a29912f | 140 | int contentsDepth = 4; // Depth of Word table of contents |
b63b07a8 | 141 | bool indexSubsections = true; // Index subsections in linear RTF |
9a29912f | 142 | // Linear RTF method of including bitmaps. Can be "includepicture", "hex" |
6c155d33 | 143 | wxChar *bitmapMethod = copystring(_T("includepicture")); |
b63b07a8 | 144 | bool upperCaseNames = false; |
9a29912f | 145 | // HTML background and text colours |
6c155d33 JS |
146 | wxChar *backgroundImageString = NULL; |
147 | wxChar *backgroundColourString = copystring(_T("255;255;255")); | |
148 | wxChar *textColourString = NULL; | |
149 | wxChar *linkColourString = NULL; | |
150 | wxChar *followedLinkColourString = NULL; | |
b63b07a8 RL |
151 | bool combineSubSections = false; |
152 | bool htmlWorkshopFiles = false; | |
153 | bool ignoreBadRefs = false; | |
6c155d33 | 154 | wxChar *htmlFaceName = NULL; |
9a29912f | 155 | |
3924dd22 GT |
156 | extern int passNumber; |
157 | ||
158 | extern wxHashTable TexReferences; | |
159 | ||
9a29912f JS |
160 | /* |
161 | * International support | |
162 | */ | |
163 | ||
164 | // Names to help with internationalisation | |
6c155d33 JS |
165 | wxChar *ContentsNameString = copystring(_T("Contents")); |
166 | wxChar *AbstractNameString = copystring(_T("Abstract")); | |
167 | wxChar *GlossaryNameString = copystring(_T("Glossary")); | |
168 | wxChar *ReferencesNameString = copystring(_T("References")); | |
169 | wxChar *FiguresNameString = copystring(_T("List of Figures")); | |
170 | wxChar *TablesNameString = copystring(_T("List of Tables")); | |
171 | wxChar *FigureNameString = copystring(_T("Figure")); | |
172 | wxChar *TableNameString = copystring(_T("Table")); | |
173 | wxChar *IndexNameString = copystring(_T("Index")); | |
174 | wxChar *ChapterNameString = copystring(_T("chapter")); | |
175 | wxChar *SectionNameString = copystring(_T("section")); | |
176 | wxChar *SubsectionNameString = copystring(_T("subsection")); | |
177 | wxChar *SubsubsectionNameString = copystring(_T("subsubsection")); | |
178 | wxChar *UpNameString = copystring(_T("Up")); | |
9a29912f JS |
179 | |
180 | /* | |
181 | * Section numbering | |
182 | * | |
183 | */ | |
184 | ||
185 | int chapterNo = 0; | |
186 | int sectionNo = 0; | |
187 | int subsectionNo = 0; | |
188 | int subsubsectionNo = 0; | |
189 | int figureNo = 0; | |
190 | int tableNo = 0; | |
191 | ||
192 | /* | |
193 | * Other variables | |
194 | * | |
195 | */ | |
196 | ||
197 | FILE *CurrentOutput1 = NULL; | |
198 | FILE *CurrentOutput2 = NULL; | |
199 | FILE *Inputs[15]; | |
dda2e4fd | 200 | unsigned long LineNumbers[15]; |
6c155d33 | 201 | wxChar *FileNames[15]; |
9a29912f JS |
202 | int CurrentInputIndex = 0; |
203 | ||
6c155d33 JS |
204 | wxChar *TexFileRoot = NULL; |
205 | wxChar *TexBibName = NULL; // Bibliography output file name | |
206 | wxChar *TexTmpBibName = NULL; // Temporary bibliography output file name | |
b63b07a8 RL |
207 | bool isSync = false; // If TRUE, should not yield to other processes. |
208 | bool stopRunning = false; // If TRUE, should abort. | |
9a29912f JS |
209 | |
210 | static int currentColumn = 0; | |
6c155d33 | 211 | wxChar *currentArgData = NULL; |
b63b07a8 | 212 | bool haveArgData = false; // If TRUE, we're simulating the data. |
9a29912f JS |
213 | TexChunk *currentArgument = NULL; |
214 | TexChunk *nextChunk = NULL; | |
b63b07a8 | 215 | bool isArgOptional = false; |
446dd881 | 216 | int noArgs = 0; |
9a29912f JS |
217 | |
218 | TexChunk *TopLevel = NULL; | |
219 | // wxList MacroDefs(wxKEY_STRING); | |
220 | wxHashTable MacroDefs(wxKEY_STRING); | |
221 | wxStringList IgnorableInputFiles; // Ignorable \input files, e.g. psbox.tex | |
6c155d33 | 222 | wxChar *BigBuffer = NULL; // For reading in large chunks of text |
9a29912f JS |
223 | TexMacroDef *SoloBlockDef = NULL; |
224 | TexMacroDef *VerbatimMacroDef = NULL; | |
225 | ||
226 | #define IncrementLineNumber() LineNumbers[CurrentInputIndex] ++ | |
227 | ||
3924dd22 | 228 | |
6c155d33 JS |
229 | TexRef::TexRef(const wxChar *label, const wxChar *file, |
230 | const wxChar *section, const wxChar *sectionN) | |
3924dd22 GT |
231 | { |
232 | refLabel = copystring(label); | |
6c155d33 JS |
233 | refFile = file ? copystring(file) : (wxChar*) NULL; |
234 | sectionNumber = section ? copystring(section) : copystring(_T("??")); | |
235 | sectionName = sectionN ? copystring(sectionN) : copystring(_T("??")); | |
3924dd22 GT |
236 | } |
237 | ||
238 | TexRef::~TexRef(void) | |
239 | { | |
240 | delete [] refLabel; refLabel = NULL; | |
241 | delete [] refFile; refFile = NULL; | |
242 | delete [] sectionNumber; sectionNumber = NULL; | |
243 | delete [] sectionName; sectionName = NULL; | |
244 | } | |
245 | ||
246 | ||
247 | CustomMacro::~CustomMacro() | |
248 | { | |
249 | if (macroName) | |
250 | delete [] macroName; | |
251 | if (macroBody) | |
252 | delete [] macroBody; | |
253 | } | |
254 | ||
6c155d33 | 255 | void TexOutput(const wxChar *s, bool ordinaryText) |
9a29912f | 256 | { |
6c155d33 | 257 | int len = wxStrlen(s); |
9a29912f JS |
258 | |
259 | // Update current column, but only if we're guaranteed to | |
260 | // be ordinary text (not mark-up stuff) | |
261 | int i; | |
262 | if (ordinaryText) | |
263 | for (i = 0; i < len; i++) | |
264 | { | |
265 | if (s[i] == 13 || s[i] == 10) | |
266 | currentColumn = 0; | |
267 | else | |
268 | currentColumn ++; | |
269 | } | |
270 | ||
271 | if (CurrentOutput1) | |
6c155d33 | 272 | wxFprintf(CurrentOutput1, _T("%s"), s); |
9a29912f | 273 | if (CurrentOutput2) |
6c155d33 | 274 | wxFprintf(CurrentOutput2, _T("%s"), s); |
9a29912f JS |
275 | } |
276 | ||
277 | /* | |
278 | * Try to find a Latex macro, in one of the following forms: | |
279 | * (1) \begin{} ... \end{} | |
280 | * (2) \macroname{arg1}...{argn} | |
281 | * (3) {\bf arg1} | |
282 | */ | |
283 | ||
284 | void ForbidWarning(TexMacroDef *def) | |
285 | { | |
04b9c5bb | 286 | wxString informBuf; |
9a29912f JS |
287 | switch (def->forbidden) |
288 | { | |
289 | case FORBID_WARN: | |
290 | { | |
6c155d33 JS |
291 | informBuf.Printf(_T("Warning: it is recommended that command %s is not used."), def->name); |
292 | OnInform((const wxChar *)informBuf.c_str()); | |
9a29912f JS |
293 | break; |
294 | } | |
295 | case FORBID_ABSOLUTELY: | |
296 | { | |
6c155d33 JS |
297 | informBuf.Printf(_T("Error: command %s cannot be used and will lead to errors."), def->name); |
298 | OnInform((const wxChar *)informBuf.c_str()); | |
9a29912f JS |
299 | break; |
300 | } | |
301 | default: | |
302 | break; | |
303 | } | |
304 | } | |
305 | ||
6c155d33 | 306 | TexMacroDef *MatchMacro(wxChar *buffer, int *pos, wxChar **env, bool *parseToBrace) |
9a29912f | 307 | { |
b63b07a8 | 308 | *parseToBrace = true; |
9a29912f JS |
309 | int i = (*pos); |
310 | TexMacroDef *def = NULL; | |
6c155d33 | 311 | wxChar macroBuf[40]; |
9a29912f JS |
312 | |
313 | // First, try to find begin{thing} | |
6c155d33 | 314 | if (wxStrncmp(buffer+i, _T("begin{"), 6) == 0) |
9a29912f JS |
315 | { |
316 | i += 6; | |
317 | ||
318 | int j = i; | |
319 | while ((isalpha(buffer[j]) || buffer[j] == '*') && ((j - i) < 39)) | |
320 | { | |
321 | macroBuf[j-i] = buffer[j]; | |
322 | j ++; | |
323 | } | |
324 | macroBuf[j-i] = 0; | |
325 | def = (TexMacroDef *)MacroDefs.Get(macroBuf); | |
326 | ||
327 | if (def) | |
328 | { | |
329 | *pos = j + 1; // BUGBUG Should this be + 1??? | |
330 | *env = def->name; | |
331 | ForbidWarning(def); | |
332 | return def; | |
333 | } | |
334 | else return NULL; | |
335 | } | |
336 | ||
337 | // Failed, so try to find macro from definition list | |
338 | int j = i; | |
339 | ||
340 | // First try getting a one-character macro, but ONLY | |
341 | // if these TWO characters are not both alphabetical (could | |
342 | // be a longer macro) | |
343 | if (!(isalpha(buffer[i]) && isalpha(buffer[i+1]))) | |
344 | { | |
345 | macroBuf[0] = buffer[i]; | |
346 | macroBuf[1] = 0; | |
347 | ||
348 | def = (TexMacroDef *)MacroDefs.Get(macroBuf); | |
349 | if (def) j ++; | |
350 | } | |
351 | ||
352 | if (!def) | |
353 | { | |
354 | while ((isalpha(buffer[j]) || buffer[j] == '*') && ((j - i) < 39)) | |
355 | { | |
356 | macroBuf[j-i] = buffer[j]; | |
357 | j ++; | |
358 | } | |
359 | macroBuf[j-i] = 0; | |
360 | def = (TexMacroDef *)MacroDefs.Get(macroBuf); | |
361 | } | |
362 | ||
363 | if (def) | |
364 | { | |
365 | i = j; | |
366 | ||
367 | // We want to check whether this is a space-consuming macro | |
368 | // (e.g. {\bf word}) | |
369 | // No brace, e.g. \input thing.tex instead of \input{thing}; | |
370 | // or a numeric argument, such as \parindent0pt | |
371 | if ((def->no_args > 0) && ((buffer[i] == 32) || (buffer[i] == '=') || (isdigit(buffer[i])))) | |
372 | { | |
373 | if ((buffer[i] == 32) || (buffer[i] == '=')) | |
374 | i ++; | |
375 | ||
b63b07a8 | 376 | *parseToBrace = false; |
9a29912f JS |
377 | } |
378 | *pos = i; | |
379 | ForbidWarning(def); | |
380 | return def; | |
381 | } | |
382 | return NULL; | |
383 | } | |
384 | ||
6c155d33 | 385 | void EatWhiteSpace(wxChar *buffer, int *pos) |
9a29912f | 386 | { |
6c155d33 | 387 | int len = wxStrlen(buffer); |
9a29912f | 388 | int j = *pos; |
b63b07a8 RL |
389 | bool keepGoing = true; |
390 | bool moreLines = true; | |
9a29912f JS |
391 | while ((j < len) && keepGoing && |
392 | (buffer[j] == 10 || buffer[j] == 13 || buffer[j] == ' ' || buffer[j] == 9)) | |
393 | { | |
394 | j ++; | |
395 | if (j >= len) | |
396 | { | |
397 | if (moreLines) | |
398 | { | |
399 | moreLines = read_a_line(buffer); | |
6c155d33 | 400 | len = wxStrlen(buffer); |
9a29912f JS |
401 | j = 0; |
402 | } | |
403 | else | |
b63b07a8 | 404 | keepGoing = false; |
9a29912f JS |
405 | } |
406 | } | |
407 | *pos = j; | |
408 | } | |
409 | ||
6c155d33 | 410 | bool FindEndEnvironment(wxChar *buffer, int *pos, wxChar *env) |
9a29912f JS |
411 | { |
412 | int i = (*pos); | |
413 | ||
414 | // Try to find end{thing} | |
6c155d33 JS |
415 | if ((wxStrncmp(buffer+i, _T("end{"), 4) == 0) && |
416 | (wxStrncmp(buffer+i+4, env, wxStrlen(env)) == 0)) | |
9a29912f | 417 | { |
6c155d33 | 418 | *pos = i + 5 + wxStrlen(env); |
b63b07a8 | 419 | return true; |
9a29912f | 420 | } |
b63b07a8 | 421 | else return false; |
9a29912f JS |
422 | } |
423 | ||
b63b07a8 RL |
424 | bool readingVerbatim = false; |
425 | bool readInVerbatim = false; // Within a verbatim, but not nec. verbatiminput | |
9a29912f | 426 | |
f6bcfd97 BP |
427 | // Switched this off because e.g. \verb${$ causes it to fail. There is no |
428 | // detection of \verb yet. | |
fad535ee | 429 | // #define CHECK_BRACES 1 |
f6bcfd97 | 430 | |
341479ff GT |
431 | unsigned long leftCurley = 0; |
432 | unsigned long rightCurley = 0; | |
6c155d33 | 433 | static wxString currentFileName = _T(""); |
f6bcfd97 | 434 | |
6c155d33 | 435 | bool read_a_line(wxChar *buf) |
9a29912f JS |
436 | { |
437 | if (CurrentInputIndex < 0) | |
438 | { | |
439 | buf[0] = 0; | |
b63b07a8 | 440 | return false; |
9a29912f | 441 | } |
fad535ee | 442 | |
9a29912f | 443 | int ch = -2; |
dda2e4fd | 444 | unsigned long bufIndex = 0; |
9a29912f | 445 | buf[0] = 0; |
6644cbe7 | 446 | int lastChar; |
f6bcfd97 | 447 | |
9a29912f JS |
448 | while (ch != EOF && ch != 10) |
449 | { | |
0e6ca394 GT |
450 | if (bufIndex >= MAX_LINE_BUFFER_SIZE) |
451 | { | |
452 | wxString errBuf; | |
6c155d33 JS |
453 | errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), |
454 | LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(), MAX_LINE_BUFFER_SIZE); | |
455 | OnError((wxChar *)errBuf.c_str()); | |
b63b07a8 | 456 | return false; |
0e6ca394 GT |
457 | } |
458 | ||
6c155d33 JS |
459 | if (((bufIndex == 14) && (wxStrncmp(buf, _T("\\end{verbatim}"), 14) == 0)) || |
460 | ((bufIndex == 16) && (wxStrncmp(buf, _T("\\end{toocomplex}"), 16) == 0))) | |
b63b07a8 | 461 | readInVerbatim = false; |
9a29912f | 462 | |
c22287af | 463 | lastChar = ch; |
9a29912f | 464 | ch = getc(Inputs[CurrentInputIndex]); |
f6bcfd97 | 465 | |
fad535ee | 466 | if (checkCurleyBraces) |
f6bcfd97 | 467 | { |
c22287af | 468 | if (ch == '{' && !readInVerbatim && lastChar != _T('\\')) |
341479ff | 469 | leftCurley++; |
c22287af | 470 | if (ch == '}' && !readInVerbatim && lastChar != _T('\\')) |
fad535ee | 471 | { |
341479ff GT |
472 | rightCurley++; |
473 | if (rightCurley > leftCurley) | |
fad535ee GT |
474 | { |
475 | wxString errBuf; | |
6c155d33 JS |
476 | errBuf.Printf(_T("An extra right Curley brace ('}') was detected at line %lu inside file %s"), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); |
477 | OnError((wxChar *)errBuf.c_str()); | |
fad535ee | 478 | |
341479ff | 479 | // Reduce the count of right Curley braces, so the mismatched count |
fad535ee | 480 | // isn't reported on every line that has a '}' after the first mismatch |
341479ff | 481 | rightCurley--; |
fad535ee GT |
482 | } |
483 | } | |
f6bcfd97 | 484 | } |
f6bcfd97 | 485 | |
9a29912f JS |
486 | if (ch != EOF) |
487 | { | |
488 | // Check for 2 consecutive newlines and replace with \par | |
489 | if (ch == 10 && !readInVerbatim) | |
490 | { | |
491 | int ch1 = getc(Inputs[CurrentInputIndex]); | |
492 | if ((ch1 == 10) || (ch1 == 13)) | |
493 | { | |
494 | // Eliminate newline (10) following DOS linefeed | |
0e6ca394 | 495 | if (ch1 == 13) |
6c155d33 | 496 | getc(Inputs[CurrentInputIndex]); |
0e6ca394 | 497 | buf[bufIndex] = 0; |
9a29912f | 498 | IncrementLineNumber(); |
6c155d33 | 499 | // wxStrcat(buf, "\\par\n"); |
9a29912f | 500 | // i += 6; |
0e6ca394 GT |
501 | if (bufIndex+5 >= MAX_LINE_BUFFER_SIZE) |
502 | { | |
503 | wxString errBuf; | |
6c155d33 JS |
504 | errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), |
505 | LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); | |
506 | OnError((wxChar *)errBuf.c_str()); | |
b63b07a8 | 507 | return false; |
0e6ca394 | 508 | } |
6c155d33 | 509 | wxStrcat(buf, _T("\\par")); |
0e6ca394 GT |
510 | bufIndex += 5; |
511 | ||
9a29912f JS |
512 | } |
513 | else | |
514 | { | |
515 | ungetc(ch1, Inputs[CurrentInputIndex]); | |
0e6ca394 GT |
516 | if (bufIndex >= MAX_LINE_BUFFER_SIZE) |
517 | { | |
518 | wxString errBuf; | |
6c155d33 JS |
519 | errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), |
520 | LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); | |
521 | OnError((wxChar *)errBuf.c_str()); | |
b63b07a8 | 522 | return false; |
0e6ca394 GT |
523 | } |
524 | ||
525 | buf[bufIndex] = ch; | |
526 | bufIndex ++; | |
9a29912f JS |
527 | } |
528 | } | |
529 | else | |
530 | { | |
531 | ||
532 | // Convert embedded characters to RTF equivalents | |
fad535ee GT |
533 | switch(ch) |
534 | { | |
535 |