[libc] Fix strfromf handling inf/nan. (#225805)

The root cause of #217708 is primarily in
libc/src/stdlib/str_from_util.h, which splits the utilities into
1. `parse_from_format()` which takes in a floating point and returns a
`FormatSection`, and
2. `strfromfloat_convert()`, which takes in the `FormatSection` and not
the floating point value.

`parse_from_format()` [does special case
handling](https://github.com/llvm/llvm-project/blob/35fe7e14ecb4e50182fe93123e1876824d14bb94/libc/src/stdlib/str_from_util.h#L41-L49)
for `float`: it must place a `double` into `FormatSection::conv_val_raw`
when working with `%a` or `%A`. `strfromfloat_convert()` extracts the
bits from `conv_val_raw` to create `fputil::FPBits<T>`, but it [always
uses the template
type](https://github.com/llvm/llvm-project/blob/35fe7e14ecb4e50182fe93123e1876824d14bb94/libc/src/stdlib/str_from_util.h#L115),
effectively creating type confusion when those bits are passed to
`convert_float_hex_exp()`.

An additional challenge in strfrom* functions is that the format string
naturally does not need or support a length modifier as in printf
functions. This is mostly a non-issue as `strfromfloat_convert()` is
templated on floating point type, and calls the "typed" conversion
functions. However, there are no templated / typed versions of
`convert_float_hex_exp()` or `convert_inf_nan()`. These two functions
currently depend on the value of `FormatSection::length_modifier` to
extract the correct type out of `FormatSection::conv_val_raw`:
[`convert_float_hex_exp()`](https://github.com/llvm/llvm-project/blob/35fe7e14ecb4e50182fe93123e1876824d14bb94/libc/src/__support/printf_core/float_hex_converter.h#L70-L86)
and
[`convert_inf_nan()`](https://github.com/llvm/llvm-project/blob/35fe7e14ecb4e50182fe93123e1876824d14bb94/libc/src/__support/printf_core/float_inf_nan_converter.h#L46-L60).
This coupling interacts with the type confusion created in
`strfromfloat_convert()`, and forces the implementation of `strfroml()`
to [manually set the
`length_modifier`](https://github.com/llvm/llvm-project/blob/35fe7e14ecb4e50182fe93123e1876824d14bb94/libc/src/stdlib/strfroml.cpp#L26-L28).

The fix in this PR:
1. Merges the two str_from_float.h utility functions to remove the type
confusion.
2. Lifts the dependency on `FormatSection::length_modifier` and
`conv_val_raw` out of `convert_float_hex_exp()` and `convert_inf_nan()`;
similarly to how the "typed" conversion functions currently work, but
without templating on float point.
3. Updates some conversion function names to mark which ones only handle
finite floating point values.

This allows `strfroml()` to not manually set the length modifier. It
also enables `strfromf128()` to be added in a straightforward
implementation, because it will not need to depend on the existence of
`LengthModifier::Q`, controlled in part by
`LIBC_COPT_PRINTF_NO_CONVERT_FLOAT128‎`. In the future, it may be good
to separate `conv_val_raw` out of `FormatSection` to be its own argument
to non-typed functions.

Fixes #217708.

GitOrigin-RevId: b4bccce2099984c74e5b29d767b586cb7b6e8dd6
9 files changed