Skip to content

Commit

Permalink
Merge pull request #90 from ImagingDataCommons/fix-trim
Browse files Browse the repository at this point in the history
don't trim spaces from numeric fields
  • Loading branch information
jcupitt authored Sep 12, 2024
2 parents fc6b865 + eed6e48 commit 303fa85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* fix build with uthash \< 2.3.0 [bgilbert]
* explicitly fail if macOS universal build is attempted [bgilbert]
* better handling of implicit mode in dcm-dump [jcupitt]
* better handling of trailing spaces in string values [y-baba-isb]

## 1.1.0, 28/3/24

Expand Down
12 changes: 6 additions & 6 deletions src/dicom-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,12 @@ static bool parse_element_body(DcmParseState *state,
}
value[length] = '\0';

if (length > 0) {
if (vr != DCM_VR_UI) {
if (isspace(value[length - 1])) {
value[length - 1] = '\0';
}
}
if (length > 0 &&
(vr_class == DCM_VR_CLASS_STRING_SINGLE ||
vr_class == DCM_VR_CLASS_STRING_MULTI) &&
vr != DCM_VR_UI &&
isspace(value[length - 1])) {
value[length - 1] = '\0';
}

if (size > 0 && state->big_endian) {
Expand Down

0 comments on commit 303fa85

Please sign in to comment.