mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
[math] Keep LC_NUMERIC=C for output as well
Otherwise, we'd have issues with people putting math's output back into math because of "," vs ".".
This commit is contained in:
parent
f20b6a1e8f
commit
84043e425d
1 changed files with 1 additions and 2 deletions
|
@ -143,7 +143,6 @@ static int evaluate_expression(const wchar_t *cmd, parser_t &parser, io_streams_
|
|||
char *saved_locale = strdup(setlocale(LC_NUMERIC, NULL));
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
double v = te_interp(narrow_str, &error);
|
||||
setlocale(LC_NUMERIC, saved_locale);
|
||||
|
||||
if (error.position == 0) {
|
||||
if (opts.scale == 0) {
|
||||
|
@ -152,13 +151,13 @@ static int evaluate_expression(const wchar_t *cmd, parser_t &parser, io_streams_
|
|||
streams.out.append_format(L"%.*lf\n", opts.scale, v);
|
||||
}
|
||||
} else {
|
||||
// TODO: Better error reporting!
|
||||
streams.err.append_format(L"%ls: Error: %ls\n", cmd, math_describe_error(error).c_str());
|
||||
streams.err.append_format(L"'%ls'\n", expression.c_str());
|
||||
streams.err.append_format(L"%*lc^\n", error.position - 1, L' ');
|
||||
retval = STATUS_CMD_ERROR;
|
||||
}
|
||||
free(narrow_str);
|
||||
setlocale(LC_NUMERIC, saved_locale);
|
||||
free(saved_locale);
|
||||
return retval;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue