mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-04-29 09:05:55 +01:00
more default options when trying to localise gnuplot
This commit is contained in:
parent
9f98ed42c3
commit
caeb78b143
@ -580,22 +580,23 @@ Plot & Plot::operator<<(PlotModifier &&modifier)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find gnuplot ////////////////////////////////////////////////////////////////
|
// find gnuplot ////////////////////////////////////////////////////////////////
|
||||||
|
#define SEARCH_DIR(dir) \
|
||||||
|
sprintf(buf, "%s/%s", dir, gnuplotBin_.c_str());\
|
||||||
|
if (access(buf, X_OK) == 0)\
|
||||||
|
{\
|
||||||
|
sprintf(buf,".");\
|
||||||
|
gnuplotPath_ = buf;\
|
||||||
|
\
|
||||||
|
return gnuplotPath_;\
|
||||||
|
}
|
||||||
|
|
||||||
std::string Plot::getProgramPath(void)
|
std::string Plot::getProgramPath(void)
|
||||||
{
|
{
|
||||||
int i, j, lg;
|
int i, j, lg;
|
||||||
char *path;
|
char *path;
|
||||||
static char buf[MAX_PATH_LENGTH];
|
static char buf[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
// trivial case: try in CWD
|
|
||||||
sprintf(buf,"./%s", gnuplotBin_.c_str()) ;
|
|
||||||
if (access(buf, X_OK) == 0)
|
|
||||||
{
|
|
||||||
sprintf(buf,".");
|
|
||||||
gnuplotPath_ = buf;
|
|
||||||
}
|
|
||||||
// try out in all paths given in the PATH variable
|
// try out in all paths given in the PATH variable
|
||||||
else
|
|
||||||
{
|
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
path = getenv("PATH") ;
|
path = getenv("PATH") ;
|
||||||
if (path)
|
if (path)
|
||||||
@ -621,16 +622,9 @@ std::string Plot::getProgramPath(void)
|
|||||||
if (path[i] == ':') i++ ;
|
if (path[i] == ':') i++ ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
LATAN_ERROR(System, "PATH variable not set");
|
|
||||||
}
|
|
||||||
// if the buffer is still empty, the command was not found
|
// if the buffer is still empty, the command was not found
|
||||||
if (buf[0] == 0)
|
if (buf[0] != 0)
|
||||||
{
|
{
|
||||||
LATAN_ERROR(System, "cannot find gnuplot in $PATH");
|
|
||||||
}
|
|
||||||
// otherwise truncate the command name to yield path only
|
|
||||||
lg = (int)(strlen(buf) - 1);
|
lg = (int)(strlen(buf) - 1);
|
||||||
while (buf[lg]!='/')
|
while (buf[lg]!='/')
|
||||||
{
|
{
|
||||||
@ -639,11 +633,21 @@ std::string Plot::getProgramPath(void)
|
|||||||
}
|
}
|
||||||
buf[lg] = 0;
|
buf[lg] = 0;
|
||||||
gnuplotPath_ = buf;
|
gnuplotPath_ = buf;
|
||||||
}
|
|
||||||
|
|
||||||
return gnuplotPath_;
|
return gnuplotPath_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// try in CWD, /usr/bin & /usr/local/bin
|
||||||
|
SEARCH_DIR(".");
|
||||||
|
SEARCH_DIR("/usr/bin");
|
||||||
|
SEARCH_DIR("/usr/local/bin");
|
||||||
|
|
||||||
|
// if this code is reached nothing was found
|
||||||
|
LATAN_ERROR(System, "cannot find gnuplot");
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
// plot parsing and output /////////////////////////////////////////////////////
|
// plot parsing and output /////////////////////////////////////////////////////
|
||||||
void Plot::display(void)
|
void Plot::display(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user