X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c22287afb2711c424df0ba00bf6fbe2af736b433..fd5e476dbb9245a9ec755eeaa5b0e4b4556d2f8c:/utils/tex2rtf/src/tex2any.cpp diff --git a/utils/tex2rtf/src/tex2any.cpp b/utils/tex2rtf/src/tex2any.cpp index aa2f7ea449..d9227ab721 100644 --- a/utils/tex2rtf/src/tex2any.cpp +++ b/utils/tex2rtf/src/tex2any.cpp @@ -38,7 +38,7 @@ static inline wxChar* copystring(const wxChar* s) * Variables accessible from clients * */ - + TexChunk * DocumentTitle = NULL; TexChunk * DocumentAuthor = NULL; TexChunk * DocumentDate = NULL; @@ -109,7 +109,7 @@ int subsectionFont = 12; // largeFont1; int titleFont = LARGEFont3; int authorFont = LargeFont2; int mirrorMargins = true; -bool winHelp = false; // Output in Windows Help format if TRUE, linear otherwise +bool winHelp = false; // Output in Windows Help format if true, linear otherwise bool isInteractive = false; bool runTwice = false; int convertMode = TEX_RTF; @@ -117,7 +117,7 @@ bool checkCurleyBraces = false; bool checkSyntax = false; bool headerRule = false; bool footerRule = false; -bool compatibilityMode = false; // If TRUE, maximum Latex compatibility +bool compatibilityMode = false; // If true, maximum Latex compatibility // (Quality of RTF generation deteriorate) bool generateHPJ; // Generate WinHelp Help Project file wxChar *winHelpTitle = NULL; // Windows Help title @@ -151,7 +151,7 @@ wxChar *followedLinkColourString = NULL; bool combineSubSections = false; bool htmlWorkshopFiles = false; bool ignoreBadRefs = false; -wxChar *htmlFaceName = NULL; +wxChar *htmlFaceName = NULL; extern int passNumber; @@ -181,7 +181,7 @@ wxChar *UpNameString = copystring(_T("Up")); * Section numbering * */ - + int chapterNo = 0; int sectionNo = 0; int subsectionNo = 0; @@ -193,7 +193,7 @@ int tableNo = 0; * Other variables * */ - + FILE *CurrentOutput1 = NULL; FILE *CurrentOutput2 = NULL; FILE *Inputs[15]; @@ -204,12 +204,12 @@ int CurrentInputIndex = 0; wxChar *TexFileRoot = NULL; wxChar *TexBibName = NULL; // Bibliography output file name wxChar *TexTmpBibName = NULL; // Temporary bibliography output file name -bool isSync = false; // If TRUE, should not yield to other processes. -bool stopRunning = false; // If TRUE, should abort. +bool isSync = false; // If true, should not yield to other processes. +bool stopRunning = false; // If true, should abort. static int currentColumn = 0; wxChar *currentArgData = NULL; -bool haveArgData = false; // If TRUE, we're simulating the data. +bool haveArgData = false; // If true, we're simulating the data. TexChunk *currentArgument = NULL; TexChunk *nextChunk = NULL; bool isArgOptional = false; @@ -227,7 +227,7 @@ TexMacroDef *VerbatimMacroDef = NULL; TexRef::TexRef(const wxChar *label, const wxChar *file, - const wxChar *section, const wxChar *sectionN) + const wxChar *section, const wxChar *sectionN) { refLabel = copystring(label); refFile = file ? copystring(file) : (wxChar*) NULL; @@ -302,7 +302,7 @@ void ForbidWarning(TexMacroDef *def) break; } } - + TexMacroDef *MatchMacro(wxChar *buffer, int *pos, wxChar **env, bool *parseToBrace) { *parseToBrace = true; @@ -359,11 +359,11 @@ TexMacroDef *MatchMacro(wxChar *buffer, int *pos, wxChar **env, bool *parseToBra macroBuf[j-i] = 0; def = (TexMacroDef *)MacroDefs.Get(macroBuf); } - + if (def) { i = j; - + // We want to check whether this is a space-consuming macro // (e.g. {\bf word}) // No brace, e.g. \input thing.tex instead of \input{thing}; @@ -443,7 +443,7 @@ bool read_a_line(wxChar *buf) int ch = -2; unsigned long bufIndex = 0; buf[0] = 0; - char lastChar = _T(' '); + int lastChar; while (ch != EOF && ch != 10) { @@ -492,7 +492,7 @@ bool read_a_line(wxChar *buf) if ((ch1 == 10) || (ch1 == 13)) { // Eliminate newline (10) following DOS linefeed - if (ch1 == 13) + if (ch1 == 13) getc(Inputs[CurrentInputIndex]); buf[bufIndex] = 0; IncrementLineNumber(); @@ -522,7 +522,7 @@ bool read_a_line(wxChar *buf) return false; } - buf[bufIndex] = ch; + buf[bufIndex] = (wxChar)ch; bufIndex ++; } } @@ -537,7 +537,7 @@ bool read_a_line(wxChar *buf) case 0xfc: // ü case 0xd6: // Ö case 0xc4: // Ä - case 0xdc: // Ü + case 0xdc: // Ü if (bufIndex+5 >= MAX_LINE_BUFFER_SIZE) { wxString errBuf; @@ -556,11 +556,11 @@ bool read_a_line(wxChar *buf) case 0xfc:buf[bufIndex++]='u';break; // ü case 0xd6:buf[bufIndex++]='O';break; // Ö case 0xc4:buf[bufIndex++]='A';break; // Ä - case 0xdc:buf[bufIndex++]='U';break; // Ü - } + case 0xdc:buf[bufIndex++]='U';break; // Ü + } buf[bufIndex++]='}'; break; - case 0xdf: // ß + case 0xdf: // ß if (bufIndex+5 >= MAX_LINE_BUFFER_SIZE) { wxString errBuf; @@ -574,7 +574,7 @@ bool read_a_line(wxChar *buf) buf[bufIndex++]='s'; buf[bufIndex++]='\\'; buf[bufIndex++]='/'; - break; + break; default: if (bufIndex >= MAX_LINE_BUFFER_SIZE) { @@ -584,11 +584,11 @@ bool read_a_line(wxChar *buf) OnError((wxChar *)errBuf.c_str()); return false; } - // If the current character read in is a '_', we need to check + // If the current character read in is a '_', we need to check // whether there should be a '\' before it or not if (ch != '_') { - buf[bufIndex++] = ch; + buf[bufIndex++] = (wxChar)ch; break; } @@ -625,7 +625,7 @@ bool read_a_line(wxChar *buf) } } } - buf[bufIndex++] = ch; + buf[bufIndex++] = (wxChar)ch; break; } // switch } // else @@ -635,7 +635,7 @@ bool read_a_line(wxChar *buf) buf[bufIndex] = 0; fclose(Inputs[CurrentInputIndex]); Inputs[CurrentInputIndex] = NULL; - if (CurrentInputIndex > 0) + if (CurrentInputIndex > 0) ch = ' '; // No real end of file CurrentInputIndex --; @@ -687,7 +687,7 @@ bool read_a_line(wxChar *buf) j -= 5; buf[j] = 0; } - + if (buf[j-1] == '}') buf[j-1] = 0; // Ignore final brace @@ -753,7 +753,7 @@ bool read_a_line(wxChar *buf) buf[j] = 0; } - if (buf[j-1] == _T('}')) + if (buf[j-1] == _T('}')) buf[j-1] = 0; // Ignore final brace // Remove backslashes from name @@ -967,7 +967,7 @@ void MacroError(wxChar *buffer) * Parse an argument. * 'environment' specifies the name of the macro IFF if we're looking for the end * of an environment, e.g. \end{itemize}. Otherwise it's NULL. - * 'parseToBrace' is TRUE if the argument should extend to the next right brace, + * 'parseToBrace' is true if the argument should extend to the next right brace, * e.g. in {\bf an argument} as opposed to \vskip 30pt * */ @@ -975,7 +975,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha { Tex2RTFYield(); if (stopRunning) return pos; - + bool eof = false; BigBuffer[0] = 0; int buf_ptr = 0; @@ -1005,7 +1005,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha } } */ - + // If not parsing to brace, just read the next word // (e.g. \vskip 20pt) if (!parseToBrace) @@ -1014,7 +1014,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha while (!eof && ch != 13 && ch != 32 && ch != 10 && ch != 0 && ch != '{') { - BigBuffer[buf_ptr] = ch; + BigBuffer[buf_ptr] = (wxChar)ch; buf_ptr ++; pos ++; ch = buffer[pos]; @@ -1124,7 +1124,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha children.Append((wxObject *)chunk); } pos ++; - + // Try matching \end{environment} if (environment && FindEndEnvironment(buffer, &pos, environment)) { @@ -1190,7 +1190,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha } else { - wxTex2RTFBuffer[i] = ch; + wxTex2RTFBuffer[i] = (wxChar)ch; pos ++; i ++; if (ch == 0) @@ -1221,7 +1221,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha if (buffer[pos] == '*') pos ++; - // Find the delimiter character + // Find the delimiter character int ch = buffer[pos]; pos ++; // Now at start of verbatim text @@ -1297,7 +1297,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha wxStrcat(macroBuf, _T("}")); ParseArg(thisArg, children, macroBuf, 0, NULL, true, chunk); } - + // delete chunk; // Might delete children } } @@ -1353,7 +1353,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha wxStrcat(macroBuf, _T("}")); ParseArg(thisArg, children, macroBuf, 0, NULL, true, chunk); } - + // delete chunk; // Might delete children } } @@ -1557,7 +1557,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha * Consume as many arguments as the macro definition specifies * */ - + int ParseMacroBody(const wxChar *WXUNUSED(macro_name), TexChunk *parent, int no_args, wxChar *buffer, int pos, wxChar *environment, bool parseToBrace, @@ -1674,11 +1674,11 @@ bool TexLoadFile(wxChar *filename) TexPathList.EnsureFileAccessible(filename); - if (line_buffer) + if (line_buffer) delete line_buffer; line_buffer = new wxChar[MAX_LINE_BUFFER_SIZE]; - + Inputs[0] = wxFopen(filename, _T("r")); LineNumbers[0] = 1; FileNames[0] = copystring(filename); @@ -1725,7 +1725,7 @@ TexChunk::TexChunk(TexChunk& toCopy) no_args = toCopy.no_args; argn = toCopy.argn; macroId = toCopy.macroId; - + // if (toCopy.name) // name = copystring(toCopy.name); // else @@ -1736,7 +1736,7 @@ TexChunk::TexChunk(TexChunk& toCopy) value = copystring(toCopy.value); else value = NULL; - + optional = toCopy.optional; wxNode *node = toCopy.children.GetFirst(); while (node) @@ -1776,7 +1776,7 @@ int GetNoArgs(void) // Number of args for this macro * only!) * */ - + void GetArgData1(TexChunk *chunk) { switch (chunk->type) @@ -2066,7 +2066,7 @@ void TexCleanUp(void) refNode = TexReferences.Next(); } TexReferences.Clear(); - + wxNode* bibNode = BibList.GetFirst(); while (bibNode) { @@ -2506,7 +2506,7 @@ void DefineDefaultMacros(void) AddMacroDef(ltUPSHAPE, _T("upshape"), 1); AddMacroDef(ltURLREF, _T("urlref"), 2); AddMacroDef(ltUSEPACKAGE, _T("usepackage"), 1); - + AddMacroDef(ltVAREPSILON, _T("varepsilon"), 0); AddMacroDef(ltVARPHI, _T("varphi"), 0); AddMacroDef(ltVARPI, _T("varpi"), 0); @@ -2570,7 +2570,7 @@ void DefineDefaultMacros(void) * Default behaviour, should be called by client if can't match locally. * */ - + // Called on start/end of macro examination void DefaultOnMacro(int macroId, int no_args, bool start) { @@ -2691,7 +2691,7 @@ void DefaultOnMacro(int macroId, int no_args, bool start) TexOutput(_T("(r)"), true); break; case ltBACKSLASH: - if (start) + if (start) TexOutput(_T("\\"), true); break; case ltLDOTS: @@ -3174,7 +3174,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) else { wxString informBuf; - informBuf.Printf(_T("Warning: unresolved reference '%s'"), refName); + informBuf.Printf(_T("Warning: unresolved reference '%s'"), refName); OnInform((wxChar *)informBuf.c_str()); } } @@ -3222,7 +3222,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) DocumentStyle = LATEX_LETTER; else if (wxStrncmp(DocumentStyleString, _T("slides"), 6) == 0) DocumentStyle = LATEX_SLIDES; - + if (StringMatch(_T("10"), DocumentStyleString)) SetFontSizes(10); else if (StringMatch(_T("11"), DocumentStyleString)) @@ -3436,12 +3436,12 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) if (fd) { ch = getc(fd); - smallBuf[0] = ch; + smallBuf[0] = (wxChar)ch; while (ch != EOF) { TexOutput(smallBuf); ch = getc(fd); - smallBuf[0] = ch; + smallBuf[0] = (wxChar)ch; } fclose(fd); } @@ -3515,7 +3515,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) wxChar *s1 = copystring(s); int i; for (i = 0; i < (int)wxStrlen(s); i++) - s1[i] = wxToupper(s[i]); + s1[i] = (wxChar)wxToupper(s[i]); TexOutput(s1); delete[] s1; return false; @@ -3535,7 +3535,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) wxChar *s1 = copystring(s); int i; for (i = 0; i < (int)wxStrlen(s); i++) - s1[i] = wxTolower(s[i]); + s1[i] = (wxChar)wxTolower(s[i]); TexOutput(s1); delete[] s1; return false; @@ -3555,7 +3555,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) wxChar *s1 = copystring(s); int i; for (i = 0; i < (int)wxStrlen(s); i++) - s1[i] = wxToupper(s[i]); + s1[i] = (wxChar)wxToupper(s[i]); TexOutput(s1); delete[] s1; return false;