File: af20bb4928ca8497107cb3595fa06fe02b7ba527.patch

package info (click to toggle)
vtk-dicom 0.8.17-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,176 kB
  • sloc: cpp: 113,811; python: 2,041; makefile: 43; tcl: 10
file content (46 lines) | stat: -rw-r--r-- 1,941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From af20bb4928ca8497107cb3595fa06fe02b7ba527 Mon Sep 17 00:00:00 2001
From: David Gobbi <david.gobbi@gmail.com>
Date: Tue, 28 Oct 2025 07:24:57 -0600
Subject: [PATCH] Fix bug in parsing multi-value SpecificCharacterSet

The first value of SpecificCharacterSet could be ignored in some
circumstances where it is needed.
---
 Source/vtkDICOMCharacterSet.cxx | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/Source/vtkDICOMCharacterSet.cxx b/Source/vtkDICOMCharacterSet.cxx
index 625a7d90..f731a449 100644
--- a/Source/vtkDICOMCharacterSet.cxx
+++ b/Source/vtkDICOMCharacterSet.cxx
@@ -3317,19 +3317,26 @@ unsigned char vtkDICOMCharacterSet::KeyFromString(const char *name, size_t nl)
           }
           else if (beginsWithBackslash)
           {
-            if ((i & DICOM_JP_BITS) == i)
+            if (((key | i) & DICOM_JP_BITS) == (key | i))
             {
               // combine key with 2nd, 3rd value of SpecificCharacterSet
               // (specific to ISO_2022_IR_87 and ISO_2022_IR_159, which
               // combine with ISO_2022_IR_13 and with each other)
-              key = (key & DICOM_JP_BITS) | i;
+              key |= i;
             }
-            else
+            else if (key == ISO_IR_6 || (key == ISO_2022_IR_6 &&
+                     (i & ISO_2022_MAX) == (i | ISO_2022_MIN)))
             {
-              // set key from 2nd value of SpecificCharacterSet
+              // replace previous values with the current value
               // (specific to ISO_2022_IR_58 and ISO_2022_IR_149)
               key = i;
             }
+            else if (((key | i) & ISO_2022_MAX) == ((key | i) | ISO_2022_MIN))
+            {
+              // if all values encountered so far can be used with ISO 2022,
+              // then enable ISO 2022 and use first value as default
+              key |= ISO_2022_MIN;
+            }
           }
           break;
         }