no error on missing init file
This commit is contained in:
parent
1b499974a0
commit
4ed9f0e731
12
app/Main.cc
12
app/Main.cc
|
|
@ -20,7 +20,6 @@
|
|||
#include <tcl.h>
|
||||
|
||||
#include "StaConfig.hh" // STA_VERSION
|
||||
#include "StringUtil.hh"
|
||||
#include "Sta.hh"
|
||||
|
||||
|
||||
|
|
@ -28,15 +27,16 @@ namespace sta {
|
|||
extern const char *tcl_inits[];
|
||||
}
|
||||
|
||||
using std::string;
|
||||
using sta::stringEq;
|
||||
using sta::findCmdLineFlag;
|
||||
using sta::Sta;
|
||||
using sta::initSta;
|
||||
using sta::evalTclInit;
|
||||
using sta::stringPrintTmp;
|
||||
using sta::sourceTclFile;
|
||||
using sta::parseThreadsArg;
|
||||
using sta::tcl_inits;
|
||||
using sta::is_regular_file;
|
||||
|
||||
// Swig uses C linkage for init functions.
|
||||
extern "C" {
|
||||
|
|
@ -116,9 +116,11 @@ staTclAppInit(int argc,
|
|||
Tcl_Eval(interp, "sta::show_splash");
|
||||
|
||||
if (!findCmdLineFlag(argc, argv, "-no_init")) {
|
||||
char *init_path = stringPrintTmp("[file join $env(HOME) %s]",
|
||||
init_filename);
|
||||
sourceTclFile(init_path, true, true, interp);
|
||||
string init_path = getenv("HOME");
|
||||
init_path += "/";
|
||||
init_path += init_filename;
|
||||
if (is_regular_file(init_path.c_str()))
|
||||
sourceTclFile(init_path.c_str(), true, true, interp);
|
||||
}
|
||||
|
||||
bool exit_after_cmd_file = findCmdLineFlag(argc, argv, "-exit");
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <tcl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "StringUtil.hh"
|
||||
#include "Vector.hh"
|
||||
|
|
@ -139,4 +140,12 @@ unencode(const char *inits[])
|
|||
return unencoded;
|
||||
}
|
||||
|
||||
// Hack until c++17 filesystem is better supported.
|
||||
bool
|
||||
is_regular_file(const char *filename)
|
||||
{
|
||||
struct stat sb;
|
||||
return stat(filename, &sb) == 0 && S_ISREG(sb.st_mode);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -62,5 +62,7 @@ sourceTclFile(const char *filename,
|
|||
bool echo,
|
||||
bool verbose,
|
||||
Tcl_Interp *interp);
|
||||
bool
|
||||
is_regular_file(const char *filename);
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
Loading…
Reference in New Issue