mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Catch exception in replaceEnvironmentPath
This exception in the regex constructor is only theoretical (our regex are hardcoded), but this is creating coverity noise. Additionally, revert the following commits that are not needed anymore:6b6fa94c
: Catch exceptions to please coverityc2ed75fd
: Fixup6b6fa94c
: coverity says there are more possible exceptions. This commit is better viewed with 'git show -b'.
This commit is contained in:
parent
08afacc239
commit
32f37250d5
58
src/LyX.cpp
58
src/LyX.cpp
@ -471,45 +471,39 @@ void LyX::earlyExit(int status)
|
|||||||
|
|
||||||
int LyX::init(int & argc, char * argv[])
|
int LyX::init(int & argc, char * argv[])
|
||||||
{
|
{
|
||||||
try {
|
// check for any spurious extra arguments
|
||||||
// check for any spurious extra arguments
|
// other than documents
|
||||||
// other than documents
|
for (int argi = 1; argi < argc ; ++argi) {
|
||||||
for (int argi = 1; argi < argc ; ++argi) {
|
if (argv[argi][0] == '-') {
|
||||||
if (argv[argi][0] == '-') {
|
lyxerr << to_utf8(
|
||||||
lyxerr << to_utf8(
|
bformat(_("Wrong command line option `%1$s'. Exiting."),
|
||||||
bformat(_("Wrong command line option `%1$s'. Exiting."),
|
from_utf8(os::utf8_argv(argi)))) << endl;
|
||||||
from_utf8(os::utf8_argv(argi)))) << endl;
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialization of LyX (reads lyxrc and more)
|
|
||||||
LYXERR(Debug::INIT, "Initializing LyX::init...");
|
|
||||||
bool success = init();
|
|
||||||
LYXERR(Debug::INIT, "Initializing LyX::init...done");
|
|
||||||
if (!success)
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
// Remaining arguments are assumed to be files to load.
|
|
||||||
for (int argi = 1; argi < argc; ++argi)
|
|
||||||
pimpl_->files_to_load_.push_back(os::utf8_argv(argi));
|
|
||||||
|
|
||||||
if (!use_gui && pimpl_->files_to_load_.empty()) {
|
|
||||||
lyxerr << to_utf8(_("Missing filename for this operation.")) << endl;
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (first_start) {
|
// Initialization of LyX (reads lyxrc and more)
|
||||||
pimpl_->files_to_load_.push_back(
|
LYXERR(Debug::INIT, "Initializing LyX::init...");
|
||||||
i18nLibFileSearch("examples", "splash.lyx").absFileName());
|
bool success = init();
|
||||||
}
|
LYXERR(Debug::INIT, "Initializing LyX::init...done");
|
||||||
|
if (!success)
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
// Remaining arguments are assumed to be files to load.
|
||||||
|
for (int argi = 1; argi < argc; ++argi)
|
||||||
|
pimpl_->files_to_load_.push_back(os::utf8_argv(argi));
|
||||||
|
|
||||||
} catch (exception const &e) {
|
if (!use_gui && pimpl_->files_to_load_.empty()) {
|
||||||
// This can happen _in_theory_ in replaceEnvironmentPath
|
lyxerr << to_utf8(_("Missing filename for this operation.")) << endl;
|
||||||
lyxerr << "Caught exception `" << e.what() << "'." << endl;
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (first_start) {
|
||||||
|
pimpl_->files_to_load_.push_back(
|
||||||
|
i18nLibFileSearch("examples", "splash.lyx").absFileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1067,10 +1067,7 @@ Server::~Server()
|
|||||||
string message;
|
string message;
|
||||||
for (int i = 0; i != numclients_; ++i) {
|
for (int i = 0; i != numclients_; ++i) {
|
||||||
message = "LYXSRV:" + clients_[i] + ":bye\n";
|
message = "LYXSRV:" + clients_[i] + ":bye\n";
|
||||||
// ignore exceptions, we are quitting anyway
|
pipes_.send(message);
|
||||||
try {
|
|
||||||
pipes_.send(message);
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,19 +686,27 @@ string const replaceEnvironmentPath(string const & path)
|
|||||||
// $[A-Za-z_][A-Za-z_0-9]*
|
// $[A-Za-z_][A-Za-z_0-9]*
|
||||||
static string const envvar = "[$]([A-Za-z_][A-Za-z_0-9]*)";
|
static string const envvar = "[$]([A-Za-z_][A-Za-z_0-9]*)";
|
||||||
|
|
||||||
static regex const envvar_br_re("(.*)" + envvar_br + "(.*)");
|
// Coverity thinks that the regex constructor can return an
|
||||||
static regex const envvar_re("(.*)" + envvar + "(.*)");
|
// exception. We know that it is not true since our regex are
|
||||||
string result = path;
|
// hardcoded, but we have to protect against that nevertheless.
|
||||||
while (1) {
|
try {
|
||||||
smatch what;
|
static regex const envvar_br_re("(.*)" + envvar_br + "(.*)");
|
||||||
if (!regex_match(result, what, envvar_br_re)) {
|
static regex const envvar_re("(.*)" + envvar + "(.*)");
|
||||||
if (!regex_match(result, what, envvar_re))
|
string result = path;
|
||||||
break;
|
while (1) {
|
||||||
|
smatch what;
|
||||||
|
if (!regex_match(result, what, envvar_br_re)) {
|
||||||
|
if (!regex_match(result, what, envvar_re))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
string env_var = getEnv(what.str(2));
|
||||||
|
result = what.str(1) + env_var + what.str(3);
|
||||||
}
|
}
|
||||||
string env_var = getEnv(what.str(2));
|
return result;
|
||||||
result = what.str(1) + env_var + what.str(3);
|
} catch (exception const & e) {
|
||||||
|
LYXERR0("Something is very wrong: " << e.what());
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user