]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/tex2rtf/src/tex2rtf.cpp
'-version' parameter for tex2rtf.
[wxWidgets.git] / utils / tex2rtf / src / tex2rtf.cpp
index be29cfc54a6ab3365fed1f9ff4ba896b8098d7ef..cba00d3753924c62274d802ffc58a3f8f3475e09 100644 (file)
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -137,6 +133,7 @@ int BufSize = 500;
 
 bool Go(void);
 void ShowOptions(void);
+void ShowVersion(void);
 
 wxChar wxTex2RTFBuffer[1500];
 
@@ -186,6 +183,8 @@ bool MyApp::OnInit()
       }
   }
 
+  TexPathList.Add(::wxGetCwd());
+
 #ifdef NO_GUI
   if (InputFile.empty() || OutputFile.empty())
   {
@@ -295,6 +294,11 @@ bool MyApp::OnInit()
       i ++;
       checkSyntax = true;
     }
+    else if (wxStrcmp(argv[i], _T("-version")) == 0)
+    {
+      i ++;
+      ShowVersion();
+    }
     else
     {
       wxString buf;
@@ -406,7 +410,7 @@ bool MyApp::OnInit()
 
     wxString path = TexPathList.FindValidPath(MacroFile);
     if (!path.empty())
-      ReadCustomMacros((wxChar *)path.c_str());
+        ReadCustomMacros(path);
 
 #if wxUSE_STATUSBAR
     wxString inStr(_T("In "));
@@ -448,15 +452,15 @@ bool MyApp::OnInit()
 
     wxString path = TexPathList.FindValidPath(MacroFile);
     if (!path.empty())
-        ReadCustomMacros((wxChar*)path.c_str());
+        ReadCustomMacros(path);
 
-    Go();
-    if (runTwice)
+    bool rc = Go();
+    if ( rc && runTwice )
     {
-        Go();
+        rc = Go();
     }
 #ifdef NO_GUI
-    return true;
+    return rc;
 #else
     OnExit(); // Do cleanup since OnExit won't be called now
     return false;
@@ -597,11 +601,17 @@ int MyApp::OnExit()
   return 0;
 }
 #endif
-void ShowOptions(void)
+
+void ShowVersion(void)
 {
     wxChar buf[100];
     wxSnprintf(buf, sizeof(buf), _T("Tex2RTF version %.2f"), versionNo);
     OnInform(buf);
+}
+
+void ShowOptions(void)
+{
+    ShowVersion();
     OnInform(_T("Usage: tex2rtf [input] [output] [switches]\n"));
     OnInform(_T("where valid switches are"));
 #ifndef NO_GUI
@@ -762,7 +772,7 @@ void MyFrame::OnLoadMacros(wxCommandEvent& WXUNUSED(event))
     if (!s.empty() && wxFileExists(s))
     {
         MacroFile = copystring(s);
-        ReadCustomMacros((wxChar *)s.c_str());
+        ReadCustomMacros(s);
         ShowCustomMacros();
     }
 #endif // wxUSE_FILEDLG
@@ -959,7 +969,7 @@ bool Go(void)
     frame->SetTitle(buf);
   }
 
-  wxStartTimer();
+  wxLongLong localTime = wxGetLocalTimeMillis();
 #endif
 
   // Find extension-less filename
@@ -1061,8 +1071,8 @@ bool Go(void)
 
     wxString buf;
 #ifndef NO_GUI
-    long tim = wxGetElapsedTime();
-    buf.Printf(_T("Finished PASS #%d in %ld seconds.\n"), passNumber, (long)(tim/1000.0));
+    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());
 
     if (errorCount)