Commit Graph

4 Commits

Author SHA1 Message Date
Peter Ammon
974ad882fa
Clean up fish-printf in preparation for publishing
Make fish-printf no longer depend on the widestring crate, as other clients
won't use it; instead this is an optional feature.

Make format strings a generic type, so that both narrow and wide strings can
serve. This removes a lot of the complexity around converting from narrow to
wide.

Add a README.md to this crate.
2024-09-21 17:52:11 -07:00
Mahmoud Al-Qudsi
f1ae170155 printf: Ignore some floating point tests under i586
A few specific tests fail under i586 due to its inherent floating point
inaccuracy issues (rust-lang/rust#114479), so ignore these tests if certain
are met.

We have specific integration tests elsewhere in fish to check that even under
i586 we get mostly sane results, so this is OK. I tried to modify the assert
macros to check for a loose string match (up to one character difference) or an
f64 abs diff of less than epsilon, but it was a lot of code with little value
and increased the friction to contributing to the tests. Also, let's just
acknowledge the fact that all of i686, let alone i586 specifically, is a dead
end and not worth investing such time and effort into so long as it more or less
"works".

Closes #10474.
2024-06-23 16:14:02 -05:00
Fabian Boehm
7850142bef printf/tests: Use c_char instead of i8
Breaks on arm again
2024-05-27 12:47:51 +02:00
ridiculousfish
7002571cf8 Add printf crate to workspace
This adds a crate containing a new implementation of printf, ported from musl.

This has some advantages:

- locale support is direct instead of being "applied after".
- No dependencies on libc printf. No unsafe code at all.
- No more WideWrite - just uses std::fmt::Write.
- Rounding is handled directly in all cases, instead of relying on Rust and/or
  libc.
- No essential dependency on WString.
- Supports %n.
- Implementation is more likely to be correct since it's based on a widely used
  printf, instead of a low-traffic Rust crate.
- Significantly faster.
2024-05-26 16:07:27 -04:00