X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5938a184a568873b48c1e59bf5c4ed5a9528d7f4..c0cc7004a6ec1c53c0fd974898ef9ffd3739bef4:/utils/tex2rtf/src/tex2any.cpp diff --git a/utils/tex2rtf/src/tex2any.cpp b/utils/tex2rtf/src/tex2any.cpp index bbb0a9e8b0..4984789f8b 100644 --- a/utils/tex2rtf/src/tex2any.cpp +++ b/utils/tex2rtf/src/tex2any.cpp @@ -25,10 +25,8 @@ #include #include -#if !WXWIN_COMPATIBILITY_2_4 static inline wxChar* copystring(const wxChar* s) { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); } -#endif /* * Variables accessible from clients @@ -248,17 +246,15 @@ CustomMacro::~CustomMacro() delete [] macroBody; } -void TexOutput(const wxChar *s, bool ordinaryText) +void TexOutput(const wxString& s, bool ordinaryText) { - int len = wxStrlen(s); - // Update current column, but only if we're guaranteed to // be ordinary text (not mark-up stuff) int i; if (ordinaryText) - for (i = 0; i < len; i++) + for (wxString::const_iterator i = s.begin(); i != s.end(); ++i) { - if (s[i] == 13 || s[i] == 10) + if (*i == 13 || *i == 10) currentColumn = 0; else currentColumn ++; @@ -285,13 +281,13 @@ void ForbidWarning(TexMacroDef *def) case FORBID_WARN: { informBuf.Printf(_T("Warning: it is recommended that command %s is not used."), def->name); - OnInform((const wxChar *)informBuf.c_str()); + OnInform(informBuf); break; } case FORBID_ABSOLUTELY: { informBuf.Printf(_T("Error: command %s cannot be used and will lead to errors."), def->name); - OnInform((const wxChar *)informBuf.c_str()); + OnInform(informBuf); break; } default: @@ -451,7 +447,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(), MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } @@ -473,7 +469,7 @@ bool read_a_line(wxChar *buf) { wxString errBuf; errBuf.Printf(_T("An extra right Curly brace ('}') was detected at line %lu inside file %s"), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); // Reduce the count of right Curly braces, so the mismatched count // isn't reported on every line that has a '}' after the first mismatch @@ -502,7 +498,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } wxStrcat(buf, _T("\\par")); @@ -517,7 +513,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } @@ -542,7 +538,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } buf[bufIndex++]='\\'; @@ -565,7 +561,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } buf[bufIndex++]='\\'; @@ -580,7 +576,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } // If the current character read in is a '_', we need to check @@ -601,7 +597,7 @@ bool read_a_line(wxChar *buf) // wxString errBuf; // errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that should NOT have a '\\' before it."), // LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); -// OnError((wxChar *)errBuf.c_str()); +// OnError(errBuf); } } else @@ -612,7 +608,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that may need a '\\' before it."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } else if ((buf[bufIndex-1] != '\\') && (buf[0] != '%') && // If it is a comment line, then no warnings (wxStrncmp(buf, _T("\\input"), 6))) // do not report filenames that have underscores in them @@ -620,7 +616,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that may need a '\\' before it."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } } @@ -645,7 +641,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Curly braces do not match inside file %s\n%lu opens, %lu closes"), (const wxChar*) currentFileName.c_str(),leftCurly,rightCurly); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } leftCurly = 0; rightCurly = 0; @@ -696,13 +692,13 @@ bool read_a_line(wxChar *buf) { wxString errBuf; errBuf.Printf(_T("Could not find file: %s"),fileName); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } else { wxString informStr; informStr.Printf(_T("Processing: %s"),actualFile.c_str()); - OnInform((wxChar *)informStr.c_str()); + OnInform(informStr); CurrentInputIndex ++; Inputs[CurrentInputIndex] = wxFopen(actualFile, _T("r")); @@ -760,7 +756,7 @@ bool read_a_line(wxChar *buf) fileNameStr.Replace(_T("\\"), _T("")); // Ignore some types of input files (e.g. macro definition files) - wxChar *fileOnly = wxFileNameFromPath((wxChar*) (const wxChar*) fileNameStr); + wxString fileOnly = wxFileNameFromPath(fileNameStr); currentFileName = fileOnly; if (IgnorableInputFiles.Member(fileOnly)) return read_a_line(buf); @@ -778,7 +774,7 @@ bool read_a_line(wxChar *buf) { wxString errBuf; errBuf.Printf(_T("Could not find file: %s"),fileName); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } else { @@ -788,7 +784,7 @@ bool read_a_line(wxChar *buf) wxString informStr; informStr.Printf(_T("Processing: %s"),actualFile.c_str()); - OnInform((wxChar *)informStr.c_str()); + OnInform(informStr); CurrentInputIndex ++; Inputs[CurrentInputIndex] = wxFopen(actualFile, _T("r")); @@ -802,7 +798,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Could not open include file %s"), (const wxChar*) actualFile); CurrentInputIndex --; - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } bool succ = read_a_line(buf); @@ -835,7 +831,7 @@ bool read_a_line(wxChar *buf) LineNumbers[CurrentInputIndex], currentFileName.c_str()); } - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } } @@ -855,7 +851,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Curly braces do not match inside file %s\n%lu opens, %lu closes"), (const wxChar*) currentFileName.c_str(),leftCurly,rightCurly); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } @@ -953,7 +949,7 @@ void MacroError(wxChar *buffer) errBuf.Printf(_T("Could not find macro: %s at line %d, file %s"), macroBuf, (int)(LineNumbers[CurrentInputIndex]-1), FileNames[CurrentInputIndex]); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); if (wxStrcmp(macroBuf,_T("\\end{document}")) == 0) { @@ -1636,7 +1632,7 @@ int ParseMacroBody(const wxChar *WXUNUSED(macro_name), TexChunk *parent, tmpBuffer = tmpBuffer.Mid(0,tmpBuffer.length()-4); } errBuf.Printf(_T("Missing macro argument in the line:\n\t%s\n"),tmpBuffer.c_str()); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } @@ -1984,7 +1980,6 @@ void TexInitialize(int bufSize) #ifdef __UNIX__ TexPathList.AddEnvList(_T("TEXINPUTS")); #endif - TexPathList.Add(_T(".")); int i; for (i = 0; i < 15; i++) { @@ -3252,7 +3247,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) { wxString informBuf; informBuf.Printf(_T("Warning: unresolved reference '%s'"), refName); - OnInform((wxChar *)informBuf.c_str()); + OnInform(informBuf); } } else TexOutput(_T("??"), true); @@ -3406,7 +3401,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) { wxString informBuf; informBuf.Printf(_T("Warning: unresolved citation %s."), citeKey); - OnInform((wxChar *)informBuf.c_str()); + OnInform(informBuf); } } citeKey = ParseMultifieldString(citeKeys, &pos); @@ -3547,14 +3542,14 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) { wxString errBuf; errBuf.Printf(_T(".bib file %s not found or malformed"), (const wxChar*) actualFile); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } else { wxString errBuf; errBuf.Printf(_T(".bib file %s not found"), fileBuf); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } bibFile = ParseMultifieldString(allFiles, &pos); }