Skip to content

Commit

Permalink
Fix the check for Gnuplot-Cairo on Windows.
Browse files Browse the repository at this point in the history
(Command-line Gnuplot (gnuplot.exe) is necessary, it
does not work with wgnuplot.exe (if preferred).
  • Loading branch information
daute committed Jan 11, 2025
1 parent c957270 commit 83630fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fix compiling with clang++.
- CopyAsMathML: encode "<" and ">" as "&lt;" and "&gt;" (valid XML).
- CopyAsMathML: improvements (operators and identifiers)
- Fix the check for Gnuplot-Cairo on Windows.

# 24.11.0

Expand Down
16 changes: 13 additions & 3 deletions src/wxMaxima.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3627,12 +3627,15 @@ void wxMaxima::GnuplotCommandName(wxString gnuplot) {
#ifdef __WXMSW__
if (m_gnuplotcommand.IsEmpty())
m_gnuplotcommand = pathlist.FindAbsoluteValidPath(gnuplot);
m_gnuplotcommand_commandline = pathlist.FindAbsoluteValidPath(wxS("gnuplot.exe"));

if(m_configuration.UseWGnuplot())
{
// If not successful, Find executable "wgnuplot.exe" in our list of paths
if (m_gnuplotcommand.IsEmpty())
if (m_gnuplotcommand.IsEmpty()) {
m_gnuplotcommand = pathlist.FindAbsoluteValidPath(wxS("wgnuplot.exe"));
m_gnuplotcommand_commandline = pathlist.FindAbsoluteValidPath(wxS("gnuplot.exe"));
}
}
// If not successful, Find executable "gnuplot.exe" in our list of paths
if (m_gnuplotcommand.IsEmpty())
Expand Down Expand Up @@ -3660,6 +3663,9 @@ void wxMaxima::GnuplotCommandName(wxString gnuplot) {
}
} else {
wxLogMessage(_("Gnuplot found at: %s"), m_gnuplotcommand.mb_str());
#ifdef __WINDOWS__
wxLogMessage(_("Gnuplot (command line) found at: %s"), m_gnuplotcommand_commandline.mb_str());
#endif
}
}
if (m_gnuplotcommand.Contains(" ") && (!m_gnuplotcommand.StartsWith("\"")) &&
Expand Down Expand Up @@ -3701,8 +3707,12 @@ void wxMaxima::VariableActionGnuplotCommand(const wxString &value) {
}
#endif
wxArrayString gnuplot_output, gnuplot_errors;
const wxString gnuplot_terminal_command = gnuplotcommand + " -e \"print GPVAL_TERMINALS\"";
if (wxExecute(gnuplot_terminal_command, gnuplot_output, gnuplot_errors, wxEXEC_SYNC | wxEXEC_HIDE_CONSOLE | wxEXEC_MAKE_GROUP_LEADER, NULL) < 0)
#ifdef __WINDOWS__
wxString gnuplot_query=m_gnuplotcommand_commandline + " -e \"print GPVAL_TERMINALS\"";
#else
wxString gnuplot_query=m_gnuplotcommand + " -e \"print GPVAL_TERMINALS\"";
#endif
if (wxExecute(gnuplot_query, gnuplot_output, gnuplot_errors, wxEXEC_SYNC | wxEXEC_HIDE_CONSOLE | wxEXEC_MAKE_GROUP_LEADER, NULL) < 0)
wxLogMessage(_("Cannot start gnuplot"));
else {
wxString gnuplot_terminals = wxJoin(gnuplot_errors, ' ', 0); // REMARK: In the documentation of wxJoin, NULL is suggested as 3rd argument ("If the escape character is non-NULL, ..."), but NULL causes an warning. (warning: passing NULL to non-pointer argument 3). Therefore I use 0 here.
Expand Down
6 changes: 6 additions & 0 deletions src/wxMaxima.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,13 @@ class wxMaxima : public wxMaximaFrame
static int m_exitCode;
//! Maxima's idea about gnuplot's location
wxString m_gnuplotcommand;
#ifdef __WINDOWS__
// For Windows, store "gnuplot.exe", even if wgnuplot.exe is preferred.
// We query the terminals using: gnuplot -e "print GPVAL_TERMINALS"
// and that does only work with gnuplot, not wgnuplot.
//! The Char the current command starts at in the current WorkingGroup
wxString m_gnuplotcommand_commandline;
#endif
long m_commandIndex = -1;
FindReplacePane::FindReplaceData m_findData;
static wxRegEx m_funRegEx;
Expand Down

0 comments on commit 83630fb

Please sign in to comment.