2
0
Fork 0
mirror of https://github.com/fish-shell/fish-shell synced 2025-02-13 12:43:43 +00:00

math: Wcharify the error message

Dunno, this seems to work, but then this is the sort of thing
that *seems* to work.
This commit is contained in:
Fabian Homborg 2020-12-14 23:02:54 +01:00
parent e94f86e6d2
commit 3af07e6c6e

View file

@ -230,16 +230,16 @@ static int evaluate_expression(const wchar_t *cmd, const parser_t &parser, io_st
// TODO: Really, this should be done in tinyexpr
// (e.g. infinite is the result of "x / 0"),
// but that's much more work.
const char *error_message = nullptr;
const wchar_t *error_message = nullptr;
if (std::isinf(v)) {
error_message = "Result is infinite";
error_message = L"Result is infinite";
} else if (std::isnan(v)) {
error_message = "Result is not a number";
error_message = L"Result is not a number";
} else if (std::abs(v) >= kMaximumContiguousInteger) {
error_message = "Result magnitude is too large";
error_message = L"Result magnitude is too large";
}
if (error_message) {
streams.err.append_format(L"%ls: Error: %s\n", cmd, error_message);
streams.err.append_format(L"%ls: Error: %ls\n", cmd, error_message);
streams.err.append_format(L"'%ls'\n", expression.c_str());
retval = STATUS_CMD_ERROR;
} else {