simplify more code with std::string and fmtlib

This commit is contained in:
Axel Kohlmeyer
2020-06-25 23:13:28 -04:00
parent e4a3a518f7
commit 84ec2cc39b
3 changed files with 22 additions and 35 deletions

View File

@ -1243,10 +1243,10 @@ void Input::quit()
char *shell_failed_message(const char* cmd, int errnum)
{
const char *errmsg = strerror(errnum);
int len = strlen(cmd)+strlen(errmsg)+64;
char *msg = new char[len];
snprintf(msg, len, "Shell command '%s' failed with error '%s'", cmd, errmsg);
std::string errmsg = fmt::format("Shell command '{}' failed with error '{}'",
cmd, strerror(errnum));
char *msg = new char[errmsg.size()+1];
strcpy(msg, errmsg.c_str());
return msg;
}