mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-22 19:01:45 +08:00
Fix hard-coded decimal separator in builtin math
This commit is contained in:
parent
c0028a0ec9
commit
80c02400eb
|
@ -191,7 +191,8 @@ fn format_double(mut v: f64, opts: &Options) -> WString {
|
||||||
if ret.chars().any(|c| !c.is_ascii_digit()) {
|
if ret.chars().any(|c| !c.is_ascii_digit()) {
|
||||||
let trailing_zeroes = ret.chars().rev().take_while(|&c| c == '0').count();
|
let trailing_zeroes = ret.chars().rev().take_while(|&c| c == '0').count();
|
||||||
let mut to_keep = ret.len() - trailing_zeroes;
|
let mut to_keep = ret.len() - trailing_zeroes;
|
||||||
if ret.as_char_slice()[to_keep - 1] == '.' {
|
// Check for the decimal separator (we don't know what character it is)
|
||||||
|
if !ret.as_char_slice()[to_keep - 1].is_ascii_digit() {
|
||||||
to_keep -= 1;
|
to_keep -= 1;
|
||||||
}
|
}
|
||||||
ret.truncate(to_keep);
|
ret.truncate(to_keep);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user