0023852: OSD_Path interprets unc paths incorrectly
authorika <ika@opencascade.com>
Fri, 29 Mar 2013 08:15:13 +0000 (12:15 +0400)
committerbugmaster <bugmaster@opencascade.com>
Mon, 1 Apr 2013 07:38:42 +0000 (11:38 +0400)
checking for unc path on Windows was added
change deprecated macro WNT to _WIN32
Adding test case for this fix

src/OSD/OSD_Path.cxx
tests/bugs/fclasses/bug23852 [new file with mode: 0755]

index 889173e..98842cb 100755 (executable)
@@ -1582,10 +1582,14 @@ static void __fastcall _remove_dup ( TCollection_AsciiString& str ) {
 
 static Standard_Integer RemoveExtraSeparator(TCollection_AsciiString& aString) {
 
-  Standard_Integer i, j, len ;
+  Standard_Integer i, j, len,start = 1 ;
 
   len = aString.Length() ;
-  for (i = j = 1 ; j <= len ; i++,j++) {
+#ifdef _WIN32
+  if (len > 1 && aString.Value(1) == '/' && aString.Value(2) == '/')
+    start = 2;
+#endif  
+  for (i = j = start ; j <= len ; i++,j++) {
       Standard_Character c = aString.Value(j) ;
       aString.SetValue(i,c) ;
       if (c == '/')
diff --git a/tests/bugs/fclasses/bug23852 b/tests/bugs/fclasses/bug23852
new file mode 100755 (executable)
index 0000000..e01538d
--- /dev/null
@@ -0,0 +1,74 @@
+puts "============"
+puts "OCC23852"
+puts "============"
+puts ""
+#######################################################################
+# OSD_Path interprets unc paths incorrectly
+#######################################################################
+
+pload DCAF
+
+set BugNumber OCC23852
+
+set OS_platform $tcl_platform(platform)
+puts "OS = ${OS_platform}"
+
+if { [string compare ${OS_platform} "windows"] == 0 } {
+
+   # Windows, #1
+   set OSD_Path "\\\\Server\\Shared\\Folder\\File.Extension"
+   puts "OSD_Path = ${OSD_Path}"
+
+   set Log [OSDPath ${OSD_Path}]
+   #
+   if { [regexp "Trek +: +\\|\\|Server\\|Shared\\|Folder" ${Log}] != 1 } {
+      puts "${BugNumber}, Trek, #1: Error"
+   }
+   #
+   if { [regexp "Name +: +File" ${Log}] != 1 } {
+      puts "${BugNumber}, Name, #1: Error"
+   }
+   #
+   if { [regexp "Extension +: +.Extension" ${Log}] != 1 } {
+      puts "${BugNumber}, Extension, #1: Error"
+   }
+
+   # Windows, #2
+   set OSD_Path "//Server/Shared/Folder/File.Extension"
+   puts "OSD_Path = ${OSD_Path}"
+
+   set Log [OSDPath ${OSD_Path}]
+   #
+   if { [regexp "Trek +: +||Server|Shared|Folder" ${Log}] != 1 } {
+      puts "${BugNumber}, Trek, #2: Error"
+   }
+   #
+   if { [regexp "Name +: +File" ${Log}] != 1 } {
+      puts "${BugNumber}, Name, #2: Error"
+   }
+   #
+   if { [regexp "Extension +: +.Extension" ${Log}] != 1 } {
+      puts "${BugNumber}, Extension, #2: Error"
+   }
+
+}
+
+if { [string compare ${OS_platform} "unix"] == 0 } {
+   # Linux
+   set OSD_Path "//Server/Shared/Folder/File.Extension"
+   puts "OSD_Path = ${OSD_Path}"
+
+   set Log [OSDPath ${OSD_Path}]
+   #
+   if { [regexp "Trek +: +||Server|Shared|Folder" ${Log}] != 1 } {
+      puts "${BugNumber}, Trek: Error"
+   }
+   #
+   if { [regexp "Name +: +File" ${Log}] != 1 } {
+      puts "${BugNumber}, Name: Error"
+   }
+   #
+   if { [regexp "Extension +: +.Extension" ${Log}] != 1 } {
+      puts "${BugNumber}, Extension: Error"
+   }
+}