mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
H5Z__format_double_canonical() previously found the shortest round-tripping %.*g precision by brute-force search, verified with an strtod() readback. On HDFGroup/hdf5#6153 we agreed a well-tested library was the safer choice for a conversion that lands in the on-disk format, and settled on Ryu. Vendors the double-to-shortest-decimal subset of Ryu (src/ryu), following the same pattern as the existing tomlc17 vendoring: pristine upstream sources pinned to a commit, per-file SHA-256s, an HDF5-authored h5_ryu_prefix.h renaming its globals via force-include, and matching CMake treatment for symbol visibility and warnings. Ryu emits unconditional scientific notation with no padding (3.0 -> "3E0"), so H5Z__format_double_canonical() takes its digit string and decimal exponent apart and lays them out %g-style -- fixed-point in the human-scale range, scientific outside it -- which keeps the canonical form unchanged (rate = 3.5, not rate = 3.5E0) and needs no strtod() round-trip check: the re-layout only moves the decimal point. Ryu also writes ASCII digits directly rather than through locale-sensitive snprintf(), so the localeconv() decimal-separator fixup the old implementation needed is gone. Updated the get_config plugin contract, the h5repack/h5tools rationale comments, and tooling (clang-format, codespell, format_source) that exempted src/tomlc17 to exempt src/ryu the same way. Verified with a 2M-sample bit-pattern sweep plus all 2098 powers of two round-tripping bit-exact through the new formatter, and the full tfilter2 canonicalization suite passing unchanged.
41 lines
1.3 KiB
Bash
Executable File
41 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Recursively format all C & C++ sources and header files, except those in the
|
|
# 'config' directory and generated files, such as H5LTanalyze.c, etc.
|
|
#
|
|
# Note that any files or directories that are excluded here should also be
|
|
# added to the 'exclude' list in .github/workflows/clang-format-check.yml
|
|
|
|
COMMAND="clang-format"
|
|
|
|
if [ $# -eq 1 ]; then
|
|
COMMAND="$COMMAND-$1"
|
|
fi
|
|
|
|
echo ""
|
|
echo "bin/format_source <version>"
|
|
echo ""
|
|
echo "Format the HDF5 C source using clang-format. The <version>"
|
|
echo "parameter is optional and can be used to force a specific"
|
|
echo "installed version of clang-format to be used."
|
|
echo ""
|
|
|
|
find . \( -type d \( -path ./config -o -path ./src/tomlc17 -o -path ./src/ryu \) -prune \) \
|
|
-or \( \( \! \( \
|
|
-name H5LTanalyze.c \
|
|
-or -name H5LTparse.c \
|
|
-or -name H5LTparse.h \
|
|
-or -name H5Edefin.h \
|
|
-or -name H5Einit.h \
|
|
-or -name H5Emajdef.h \
|
|
-or -name H5Emindef.h \
|
|
-or -name H5Epubgen.h \
|
|
-or -name H5Eterm.h \
|
|
-or -name H5version.h \
|
|
-or -name H5overflow.h \
|
|
\) \) \
|
|
-and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp -or -iname *.java \) \) \
|
|
| xargs -P0 -n1 ${COMMAND} -style=file -i -fallback-style=none
|
|
|
|
exit 0
|