Skip to content

Commit

Permalink
don't trim spaces from numeric fields
Browse files Browse the repository at this point in the history
We were accidentally trimming spaces characters from the end of numeric
fields.

See #89

Thanks @y-baba-isb
  • Loading branch information
jcupitt committed Sep 10, 2024
1 parent fc6b865 commit eed6e48
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 eed6e48

Please sign in to comment.