mirror of https://github.com/YosysHQ/yosys.git
fix: save history file on windows
This commit is contained in:
parent
820232eaca
commit
dd5dc06863
|
@ -245,15 +245,23 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
#if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE)
|
#if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE)
|
||||||
std::string state_dir;
|
std::string state_dir;
|
||||||
|
#if defined(_WIN32)
|
||||||
|
if (getenv("HOMEDRIVE") != NULL && getenv("HOMEPATH") != NULL) {
|
||||||
|
state_dir = stringf("%s%s/.local/state", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
|
||||||
|
} else {
|
||||||
|
log("$HOMEDRIVE and/or $HOMEPATH is empty. No history file will be created.");
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (getenv("XDG_STATE_HOME") == NULL || getenv("XDG_STATE_HOME")[0] == '\0') {
|
if (getenv("XDG_STATE_HOME") == NULL || getenv("XDG_STATE_HOME")[0] == '\0') {
|
||||||
if (getenv("HOME") != NULL) {
|
if (getenv("HOME") != NULL) {
|
||||||
state_dir = stringf("%s/.local/state", getenv("HOME"));
|
state_dir = stringf("%s/.local/state", getenv("HOME"));
|
||||||
}else {
|
} else {
|
||||||
log("$HOME is empty. No history file will be created.");
|
log("$HOME is empty. No history file will be created.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
state_dir = stringf("%s", getenv("XDG_STATE_HOME"));
|
state_dir = stringf("%s", getenv("XDG_STATE_HOME"));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!state_dir.empty()) {
|
if (!state_dir.empty()) {
|
||||||
std::string yosys_dir = state_dir + "/yosys";
|
std::string yosys_dir = state_dir + "/yosys";
|
||||||
|
@ -262,7 +270,7 @@ int main(int argc, char **argv)
|
||||||
yosys_history_file = yosys_dir + "/history";
|
yosys_history_file = yosys_dir + "/history";
|
||||||
read_history(yosys_history_file.c_str());
|
read_history(yosys_history_file.c_str());
|
||||||
yosys_history_offset = where_history();
|
yosys_history_offset = where_history();
|
||||||
}else {
|
} else {
|
||||||
log("state_dir is empty. No history file will be created.");
|
log("state_dir is empty. No history file will be created.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue