X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ccf6c43b3dbfcf891920db72b832b63ca88c3941..3be926e348e2d0a3a2c278b9f2cff7843971e0c9:/utils/tex2rtf/src/tex2rtf.cpp diff --git a/utils/tex2rtf/src/tex2rtf.cpp b/utils/tex2rtf/src/tex2rtf.cpp index cba00d3753..55e7af99d8 100644 --- a/utils/tex2rtf/src/tex2rtf.cpp +++ b/utils/tex2rtf/src/tex2rtf.cpp @@ -66,10 +66,8 @@ #include "tex2rtf.xpm" #endif -#if !WXWIN_COMPATIBILITY_2_4 static inline wxChar* copystring(const wxChar* s) { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); } -#endif const float versionNo = float(TEX2RTF_VERSION_NUMBER); @@ -185,22 +183,6 @@ bool MyApp::OnInit() TexPathList.Add(::wxGetCwd()); -#ifdef NO_GUI - if (InputFile.empty() || OutputFile.empty()) - { - wxSTD cout << "Tex2RTF: input or output file is missing.\n"; - ShowOptions(); - exit(1); - } -#endif - - if (!InputFile.empty()) - { - TexPathList.EnsureFileAccessible(InputFile); - } - if (InputFile.empty() || OutputFile.empty()) - isInteractive = true; - int i; for (i = n; i < argc;) { @@ -298,12 +280,17 @@ bool MyApp::OnInit() { i ++; ShowVersion(); +#ifdef NO_GUI + exit(1); +#else + return false; +#endif } else { wxString buf; buf.Printf(_T("Invalid switch %s.\n"), argv[i]); - OnError((wxChar *)buf.c_str()); + OnError(buf); #ifdef NO_GUI ShowOptions(); exit(1); @@ -313,6 +300,22 @@ bool MyApp::OnInit() } } +#ifdef NO_GUI + if (InputFile.empty() || OutputFile.empty()) + { + wxSTD cout << "Tex2RTF: input or output file is missing.\n"; + ShowOptions(); + exit(1); + } +#endif + + if (!InputFile.empty()) + { + TexPathList.EnsureFileAccessible(InputFile); + } + if (InputFile.empty() || OutputFile.empty()) + isInteractive = true; + #if defined(__WXMSW__) && !defined(NO_GUI) wxDDEInitialize(); Tex2RTFLastStatus[0] = 0; // DDE connection return value @@ -623,6 +626,7 @@ void ShowOptions(void) OnInform(_T(" -sync")); OnInform(_T(" -checkcurlybraces")); OnInform(_T(" -checksyntax")); + OnInform(_T(" -version")); OnInform(_T(" -macros ")); OnInform(_T(" -winhelp")); OnInform(_T(" -rtf")); @@ -697,7 +701,7 @@ void MyFrame::OnGo(wxCommandEvent& WXUNUSED(event)) #endif // wxUSE_STATUSBAR wxString errBuf; errBuf.Printf(_T("\nErrors encountered during this pass: %lu\n"), errorCount); - OnInform((wxChar *)errBuf.c_str()); + OnInform(errBuf); } @@ -894,7 +898,7 @@ void ChooseInputFile(bool force) wxString str = wxFileNameFromPath(InputFile); wxString buf; buf.Printf(_T("Tex2RTF [%s]"), str.c_str()); - frame->SetTitle((wxChar *)buf.c_str()); + frame->SetTitle(buf); OutputFile = wxEmptyString; } } @@ -1023,7 +1027,7 @@ bool Go(void) { wxString buf; buf.Printf(_T("Working, pass %d...Click CLOSE to abort"), passNumber); - frame->SetStatusText((wxChar *)buf.c_str()); + frame->SetStatusText(buf); } #endif OkToClose = false; @@ -1073,28 +1077,28 @@ bool Go(void) #ifndef NO_GUI wxLongLong elapsed = wxGetLocalTimeMillis() - localTime; buf.Printf(_T("Finished PASS #%d in %ld seconds.\n"), passNumber, (long)(elapsed.GetLo()/1000.0)); - OnInform((wxChar *)buf.c_str()); + OnInform(buf); if (errorCount) { buf.Printf(_T("Errors encountered during this pass: %lu\n"), errorCount); - OnInform((wxChar *)buf.c_str()); + OnInform(buf); } #if wxUSE_STATUSBAR if (isInteractive) { buf.Printf(_T("Done, %d %s."), passNumber, (passNumber > 1) ? _T("passes") : _T("pass")); - frame->SetStatusText((wxChar *)buf.c_str()); + frame->SetStatusText(buf); } #endif // wxUSE_STATUSBAR #else buf.Printf(_T("Done, %d %s."), passNumber, (passNumber > 1) ? _T("passes") : _T("pass")); - OnInform((wxChar *)buf.c_str()); + OnInform(buf); if (errorCount) { buf.Printf(_T("Errors encountered during this pass: %lu\n"), errorCount); - OnInform((wxChar *)buf.c_str()); + OnInform(buf.c_str()); } #endif passNumber ++; @@ -1115,13 +1119,12 @@ bool Go(void) return false; } -void OnError(const wxChar *msg) +void OnError(const wxString& msg) { - wxString msg_string = msg; errorCount++; #ifdef NO_GUI - wxSTD cerr << "Error: " << msg_string.mb_str() << "\n"; + wxSTD cerr << "Error: " << msg.mb_str() << "\n"; wxSTD cerr.flush(); #else if (isInteractive && frame) @@ -1131,7 +1134,7 @@ void OnError(const wxChar *msg) else { #if defined(__UNIX__) - wxSTD cerr << "Error: " << msg_string.mb_str() << "\n"; + wxSTD cerr << "Error: " << msg.mb_str() << "\n"; wxSTD cerr.flush(); #elif defined(__WXMSW__) wxLogError(msg); @@ -1142,11 +1145,10 @@ void OnError(const wxChar *msg) #endif // NO_GUI } -void OnInform(const wxChar *msg) +void OnInform(const wxString& msg) { - wxString msg_string = msg; #ifdef NO_GUI - wxSTD cout << msg_string.mb_str() << "\n"; + wxSTD cout << msg.mb_str() << "\n"; wxSTD cout.flush(); #else if (isInteractive && frame) @@ -1156,7 +1158,7 @@ void OnInform(const wxChar *msg) else { #if defined(__UNIX__) - wxSTD cout << msg_string.mb_str() << "\n"; + wxSTD cout << msg.mb_str() << "\n"; wxSTD cout.flush(); #elif defined(__WXMSW__) wxLogInfo(msg);