Skip to content

Commit 754af0f

Browse files
committed
BUG: Locale-independent itk::StringToDouble/Float; remove NumericLocale
itk::StringToDouble and itk::StringToFloat followed the ambient LC_NUMERIC, so every migrated IO call site parsed "0.878906" as 0 under a decimal-comma locale. They parse with strtod_l/strtof_l against a cached "C" locale, keeping the itk::ExceptionObject contract; only overflow throws, as ERANGE underflow is a valid subnormal or zero. A platform lacking newlocale and _configthreadlocale fails to compile. NumericLocale is removed: uselocale() cannot bind the non-_l std::strtod on macOS 13 libc, and it shipped only in the v6.0b02 beta, so no deprecation shim is required.
1 parent 22026f6 commit 754af0f

10 files changed

Lines changed: 142 additions & 420 deletions

File tree

Modules/Core/Common/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ try_compile(
158158
${CMAKE_CURRENT_SOURCE_DIR}/CMake/itkCheckHasSchedGetAffinity.cxx
159159
)
160160

161-
# Check for thread-local locale functions for NumericLocale
161+
# Check for thread-safe locale functions (locale-independent parsing in itkStringConvert)
162162
try_compile(
163163
ITK_HAS_NEWLOCALE
164164
${ITK_BINARY_DIR}

Modules/Core/Common/include/itkNumericLocale.h

Lines changed: 0 additions & 84 deletions
This file was deleted.

Modules/Core/Common/include/itkStringConvert.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ namespace itk
4343
* `context` describing what was being parsed (e.g.
4444
* ``"NRRD header field 'sizes'"``) plus the offending input string.
4545
*
46+
* The floating-point helpers parse with an explicit "C" locale, so `.` is the
47+
* decimal separator regardless of the ambient `LC_NUMERIC` locale. Underflow to
48+
* a subnormal or zero is a valid value; only overflow throws.
49+
*
4650
* **Fixed-width integer return types** are used (`int32_t`, `int64_t`,
4751
* `uint32_t`, `uint64_t`) rather than the platform-dependent C++
4852
* spellings (`int`, `long`, `unsigned long`). The C++ Standard only

Modules/Core/Common/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ set(
106106
itkMultipleLogOutput.cxx
107107
itkMultiThreaderBase.cxx
108108
itkNumberToString.cxx
109-
itkNumericLocale.cxx
110109
itkNumericTraits.cxx
111110
itkNumericTraitsCovariantVectorPixel.cxx
112111
itkNumericTraitsDiffusionTensor3DPixel.cxx

Modules/Core/Common/src/itkNumericLocale.cxx

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)