]> OCCT Git - occt-copy.git/commitdiff
0023561: stepwrite and brepiges dont work with big path (over 150 simbols) of writing...
authorabv <abv@opencascade.com>
Fri, 7 Dec 2012 09:50:06 +0000 (13:50 +0400)
committerabv <abv@opencascade.com>
Fri, 7 Dec 2012 09:50:06 +0000 (13:50 +0400)
DRAW commands stepwrite and brepiges modified to never ask for interactive input of file name or write mode; the behavior is completely defined by input arguments. String buffers causing access violation due to overflow are eliminated.

Test case bugs xde bug23561 added for this issue; TODO 23651 in related test cases removed.

Compiler warning (unrelated) is fixed in QABugs_11.cxx

15 files changed:
src/QABugs/QABugs_11.cxx
src/XSDRAWIGES/XSDRAWIGES.cxx
src/XSDRAWSTEP/XSDRAWSTEP.cxx
tests/bugs/iges/buc60591_1
tests/bugs/iges/buc60591_2
tests/bugs/iges/buc60591_3
tests/bugs/iges/buc60591_4
tests/bugs/step/buc60948
tests/bugs/step/bug23379
tests/bugs/step/bug46
tests/bugs/step/bug51
tests/bugs/xde/bug184
tests/bugs/xde/bug23561 [new file with mode: 0755]
tests/bugs/xde/bug314
tests/bugs/xde/bug321

index 947ef99a77386efbca9a78096ab7c48aa3af9c75..abfd74bdaa149cb09e4cec63a056586ee9602847 100755 (executable)
@@ -5181,10 +5181,10 @@ Standard_Integer OCC22744 (Draw_Interpretor& di, Standard_Integer argc, const ch
   
   TCollection_ExtendedString anExtString;
   
-  Standard_ExtCharacter aNonAsciiChar = 0xff00;
+  Standard_ExtCharacter aNonAsciiChar = 0x0f00;
   anExtString.Insert(1, aNonAsciiChar);
 
-  di << "Is ASCII: " << ( anExtString.IsAscii() ? "true" : "false" ) << "\n";
+  di << "Is ASCII: " << ( anExtString.IsAscii() ? "true : Error" : "false : OK" ) << "\n";
   NCollection_DataMap<TCollection_ExtendedString, Standard_Integer> aMap;
   aMap.Bind(anExtString, 0);
   
index 4da5a13cfe1f579661dd2daf922ff2df1174674e..56a29a8c466b7e8d5e44a478fb00f7b80472156f 100755 (executable)
@@ -431,7 +431,7 @@ static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, cons
 
 //  Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic
 //   c a d tant qu il y a des + on ajoute ce qui suit
-  const char* ficnom = NULL;
+  const char* nomfic;
   Standard_Integer npris = 0;
 
   Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
@@ -442,7 +442,7 @@ static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, cons
   for ( Standard_Integer i = 1; i < n; i++) {
     const char* nomvar = a[i];
     if (a[i][0] == '+') nomvar = &(a[i])[1];
-    else if (i > 1)  {  ficnom = a[i];  break;  }
+    else if (i > 1)  {  nomfic = a[i];  break;  }
     TopoDS_Shape Shape = DBRep::Get(nomvar);
     if      (ICW.AddShape (Shape)) npris ++;
     else if (ICW.AddGeom (DrawTrSurf::GetCurve   (nomvar)) ) npris ++;
@@ -459,40 +459,16 @@ static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, cons
   progress->Show();
 
   di<<npris<<" Shapes written, giving "<<XSDRAW::Model()->NbEntities()<<" Entities"<<"\n";
-  di<<" Now, to write a file, command : writeall filename"<<"\n";
 
-  // creation du fichier de sortie
-
-  char nomfic[100] ;
-  Standard_Integer modepri = 0;
-  if (ficnom) {
-    modepri = 2;
-    strcpy (nomfic,ficnom);
-  }
-
-  if (!modepri) {
-    cout<<" Mode (0 End, 1 ->screen, 2 file) :"<<flush;
-    modepri = -1;
-    cin >> modepri; di << "Output mode " << modepri << "\n";
-  }
-
-  if (modepri == 0) return 0;
-  // Ecran
-  else if (modepri == 1) {
-    di << " Screen Output" << "\n";
-    //ICW.Write (cout);
-    Standard_SStream aSStream;
-    ICW.Write (aSStream);
-    di << aSStream;
+  if ( ! nomfic ) // delayed write
+  {
+    di<<" Now, to write a file, command : writeall filename"<<"\n";
+    return 0;
   }
 
-  //  ....                      WRITE (Fichier)                        ....
-  else if (modepri == 2) {
-    if (!ficnom)  { cout << " Output file name :" << flush;  cin  >> nomfic; }
-    di << " Output on file : " << nomfic << "\n";
-    if (ICW.Write(nomfic)) di<<" Write OK"<<"\n";
-    else                   di<<" Write KO"<<"\n";
-  }
+  // write file
+  if (! ICW.Write(nomfic)) di<<" Error: could not write file " << nomfic;
+  else                     di<<" File " << nomfic << " written";
 
   progress->EndScope();
   progress->Show();
index 682a97316cea5df14dee35193da289573b0bc64c..7999b98cf5139a9c860a6dba8a085f254af48e7d 100755 (executable)
@@ -435,7 +435,14 @@ static Standard_Integer stepwrite (Draw_Interpretor& di, Standard_Integer argc,
   sw.WS()->TransferWriter()->FinderProcess()->SetProgress(progress);
 
   Standard_Integer stat = sw.Transfer (shape,mode);
-  di<<"execution status : "<<stat<<"\n";
+  if (stat == IFSelect_RetDone)
+  {
+    di << "Translation: OK\n";
+  } 
+  else 
+  {
+    di << "Error: translation failed, status = " << stat << "\n";
+  }
 
   sw.WS()->TransferWriter()->FinderProcess()->SetProgress(0);
   progress->EndScope();
@@ -450,28 +457,18 @@ static Standard_Integer stepwrite (Draw_Interpretor& di, Standard_Integer argc,
   if (nbapres <= nbavant) di<<"Beware : No data produced by this transfer"<<"\n";
   if (nbapres == 0) { di<<"No data to write"<<"\n"; return 0; }
 
-  char nomfic[150] ;
-  Standard_Integer modepri = 1;
-
   if (argc <= 3) {
-    cout<<" Mode (0 end, 1 file) :"<<flush;
-    cin >> modepri; di << "Output mode " << modepri << "\n";
-  }
-  else modepri = 2;
-
-  if      (modepri == 0) return 0;
-  else if (modepri == 1) {
-    cout << " Output file name :" << flush;  cin  >> nomfic;
+    di<<" Now, to write a file, command : writeall filename"<<"\n";
+    return 0;
   }
-  else if (modepri == 2) strcpy (nomfic,argv[3]);
 
-  di << " Output on file : " << nomfic << "\n";
+  const char *nomfic = argv[3];
   stat = sw.Write(nomfic);
   switch (stat) {
-    case IFSelect_RetVoid : di<<"No file written"<<"\n"; break;
+  case IFSelect_RetVoid : di<<"Error: No file written"<<"\n"; break;
     case IFSelect_RetDone : di<<"File "<<nomfic<<" written"<<"\n"; break;
     case IFSelect_RetStop : di<<"Error on writing file: no space on disk or destination is write protected"<<"\n"; break;
-    default : di<<"File "<<nomfic<<" written with fail messages"<<"\n"; break;
+    default : di<<"Error: File "<<nomfic<<" written with fail messages"<<"\n"; break;
   }
 
   progress->EndScope();
index 9fe2524f88652494d9792f15928bf0fca4c02b53..47f52dfed86004e8923daeede6f42fba7c65e351 100644 (file)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "=========="
 puts "BUC60591"
index fafb47d07c48b3b1b661cace8e0067c860ff9ed4..05aedb168d4d8d1bc87697c97fea4486e9a5bc22 100644 (file)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "=================================="
 puts "BUC60591"
index 3ad633515aa355d6680cdd4ef70c7ee09ca5e75f..5afef3b6f803c6b79cb037d7bfff3753fd1b6a10 100644 (file)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "=================================="
 puts "BUC60591"
index c9f0af8a763c7efd558d13bc2ead3ef35a486c4f..6860b88a7f9213c0e0d548495b798aceff14f180 100644 (file)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "BUC60591"
 puts ""
index 3292aa95801592e1407bc49f56503e3e1e23d901..cb02f493ad61fa6ae0779430ef703cab76a56854 100644 (file)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "========================"
 puts "BUC60948"
index 84eb7e8c82c0e1bcf9c4883943b6da46347cf062..96ed4c7ea650440719ed75a93c3b531acebb81a1 100755 (executable)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "================"
 puts "OCC23379"
index 33fbbaaf16f9432581b3c5c40dab43423274449f..d1cb81b42bf28d376815032ae175f7fc275eb460 100755 (executable)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "================"
 puts "OCC46"
index da7671709e9edfee311bac619bd6648f90a20ef2..00f75eacaa642b685f1c18f34b35b4ebd08df85f 100755 (executable)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "================"
 puts "OCC51"
index f4bc0565796a10082c30a7946ab4f6d064f9bcef..15e122641527fadc077ff1110443fa7d340a11ad 100755 (executable)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "========"
 puts "OCC184"
diff --git a/tests/bugs/xde/bug23561 b/tests/bugs/xde/bug23561
new file mode 100755 (executable)
index 0000000..72af506
--- /dev/null
@@ -0,0 +1,18 @@
+# Test writing IGES or STEP file with long path
+
+puts "bug23561"
+
+pload MODELING
+
+# make path to log directory to be at least 200 symbols, 
+# by adding ../xde/ as many times as needed
+set path [file normalize $imagedir]
+set last [file tail $path]
+while { [string length $path] < 200 } {
+    set path "$path/../$last"
+}
+
+# write simple box
+box b 10 10 10
+brepiges b "$path/${casename}.igs"
+stepwrite a b "$path/${casename}.stp"
index 8c20629965a787e536054e3efacc757ec613252a..055bd9fa0ba9409205aaea756bf74ee4cbbadb14 100755 (executable)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "========"
 puts "OCC314"
index d91080ac1e0058d677d0a92706556d738fc22aea..1c2c204c03b5494637a53585892a45573aff9cea 100755 (executable)
@@ -1,12 +1,4 @@
 set os $env(os_type)
-if { [string compare $os "windows"] == 0 } {
-#     puts "TODO OCC23561 $os: child process exited abnormally"
-} else {
-    puts "TODO OCC23561 ALL: An exception was caught"
-    puts "TODO OCC23561 ALL: Tcl Exception:"
-    puts "TODO OCC23561 ALL: \\*\\* Exception \\*\\*.*"
-}
-puts "TODO OCC23561 ALL: TEST INCOMPLETE"
 
 puts "========"
 puts "OCC321"