Skip to content

Commit 303fa85

Browse files
authored
Merge pull request #90 from ImagingDataCommons/fix-trim
don't trim spaces from numeric fields
2 parents fc6b865 + eed6e48 commit 303fa85

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* fix build with uthash \< 2.3.0 [bgilbert]
44
* explicitly fail if macOS universal build is attempted [bgilbert]
55
* better handling of implicit mode in dcm-dump [jcupitt]
6+
* better handling of trailing spaces in string values [y-baba-isb]
67

78
## 1.1.0, 28/3/24
89

src/dicom-parse.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,12 @@ static bool parse_element_body(DcmParseState *state,
616616
}
617617
value[length] = '\0';
618618

619-
if (length > 0) {
620-
if (vr != DCM_VR_UI) {
621-
if (isspace(value[length - 1])) {
622-
value[length - 1] = '\0';
623-
}
624-
}
619+
if (length > 0 &&
620+
(vr_class == DCM_VR_CLASS_STRING_SINGLE ||
621+
vr_class == DCM_VR_CLASS_STRING_MULTI) &&
622+
vr != DCM_VR_UI &&
623+
isspace(value[length - 1])) {
624+
value[length - 1] = '\0';
625625
}
626626

627627
if (size > 0 && state->big_endian) {

0 commit comments

Comments
 (0)