]> Creatis software - gdcm.git/blobdiff - src/gdcmUtil.cxx
* DicomDir : clean code, add methods, set variables in protected or private
[gdcm.git] / src / gdcmUtil.cxx
index 40143310270811fa753301afa7bf6ac6663befc2..fb1f87fb248565e7647eb571759083d65cd66a4e 100644 (file)
@@ -52,9 +52,9 @@ void gdcmDebug::Exit(int a) {
 }
 
 //-----------------------------------------------------------------------------
-gdcmVR      * gdcmGlobal::VR    = (gdcmVR*)0;
-gdcmTS      * gdcmGlobal::TS    = (gdcmTS*)0;
-gdcmDictSet * gdcmGlobal::Dicts = (gdcmDictSet*)0;
+gdcmVR      *gdcmGlobal::VR    = (gdcmVR *)0;
+gdcmTS      *gdcmGlobal::TS    = (gdcmTS *)0;
+gdcmDictSet *gdcmGlobal::Dicts = (gdcmDictSet *)0;
 gdcmGlobal gdcmGlob;
 
 gdcmGlobal::gdcmGlobal(void) {
@@ -71,15 +71,15 @@ gdcmGlobal::~gdcmGlobal() {
    delete Dicts;
 }
 
-gdcmVR * gdcmGlobal::GetVR(void) {
+gdcmVR *gdcmGlobal::GetVR(void) {
    return VR;
 }
 
-gdcmTS * gdcmGlobal::GetTS(void) {
+gdcmTS *gdcmGlobal::GetTS(void) {
    return TS;
 }
 
-gdcmDictSet * gdcmGlobal::GetDicts(void) {
+gdcmDictSet *gdcmGlobal::GetDicts(void) {
    return Dicts;
 }
 
@@ -113,16 +113,16 @@ void Tokenize (const std::string& str,
 
 ///////////////////////////////////////////////////////////////////////////
 // to prevent a flashing screen when non-printable character
-char * _cleanString(char *v) {
+char *_cleanString(char *v) {
    char *d;
    int i, l;
    l = strlen(v);
    for (i=0,d=v; 
-        i<l ; 
-        i++,d++) {
-      if (!isprint(*d))
+      i<l ; 
+      i++,d++) {
+         if (!isprint(*d))
          *d = '.';
-      }        
+   }   
    return v;
 }
 
@@ -130,13 +130,19 @@ char * _cleanString(char *v) {
 ///////////////////////////////////////////////////////////////////////////
 // to prevent a flashing screen when non-printable character
 std::string _CreateCleanString(std::string s) {
-  std::string str=s;
-  for(int i=0;i<str.size();i++)
-  {
-    if(!isprint(str[i]))
-      str[i]='.';
-  }
-
-  return(str);
-}
+   std::string str=s;
+
+   for(int i=0;i<str.size();i++)
+   {
+      if(!isprint(str[i]))
+         str[i]='.';
+   }
 
+
+   if(str.size()>0)
+      if(!isprint(s[str.size()-1]))
+         if(s[str.size()-1]==0)
+            str[str.size()-1]=' ';
+
+   return(str);
+}