0027054: Upgrade procedure corrupts files with DOS line endings
authorabv <abv@opencascade.com>
Fri, 1 Jan 2016 15:43:02 +0000 (18:43 +0300)
committerabv <abv@opencascade.com>
Fri, 1 Jan 2016 15:43:48 +0000 (18:43 +0300)
Treatment of files in DOS encoding corrected to avoid duplication of CR symbols

adm/upgrade.tcl

index 6193e64..7703071 100644 (file)
@@ -1160,24 +1160,16 @@ proc ReadFileToList {theFilePath theFileContent theFileEOL} {
   set aFileContent [read $aFile]
   close $aFile
 
-  set aFileEOL "\r"
-  if [regexp "\r\n" $aFileContent] {
+  # detect DOS end-of-lines
+  if { [regexp "\r\n" $aFileContent] } {
     set aFileEOL "\r\n"
-  } elseif [regexp "\n" $aFileContent] {
+    set aList [split [regsub -all "\r\n" $aFileContent "\n"] "\r\n"]
+  } else {
+    # standard UNIX end-of-lines
     set aFileEOL "\n"
+    set aList [split $aFileContent "\n"]
   }
 
-  # convert to unix eol
-  if {"$aFileEOL" != "\n"} {
-    regsub -all {$aFileEOL} $aFileContent "\n" aFileContent
-  }
-
-  set aList [split $aFileContent "\n"]
-#  set aList {}
-#  foreach aLine [split $aFileContent "\n"] {
-#    lappend aList [string trimright $aLine]
-#  }
-
   return $aList
 }