From: abv Date: Fri, 7 Dec 2012 09:50:06 +0000 (+0400) Subject: 0023561: stepwrite and brepiges dont work with big path (over 150 simbols) of writing... X-Git-Tag: V6_6_0_beta~185 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=2857a8acd88410ba655dfd00ccf5701c2810b6ed 0023561: stepwrite and brepiges dont work with big path (over 150 simbols) of writing file 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 --- diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index 947ef99a77..abfd74bdaa 100755 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -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 aMap; aMap.Bind(anExtString, 0); diff --git a/src/XSDRAWIGES/XSDRAWIGES.cxx b/src/XSDRAWIGES/XSDRAWIGES.cxx index 4da5a13cfe..56a29a8c46 100755 --- a/src/XSDRAWIGES/XSDRAWIGES.cxx +++ b/src/XSDRAWIGES/XSDRAWIGES.cxx @@ -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<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) :"<> 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(); diff --git a/src/XSDRAWSTEP/XSDRAWSTEP.cxx b/src/XSDRAWSTEP/XSDRAWSTEP.cxx index 682a97316c..7999b98cf5 100755 --- a/src/XSDRAWSTEP/XSDRAWSTEP.cxx +++ b/src/XSDRAWSTEP/XSDRAWSTEP.cxx @@ -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 : "<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) :"<> 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 "<EndScope(); diff --git a/tests/bugs/iges/buc60591_1 b/tests/bugs/iges/buc60591_1 index 9fe2524f88..47f52dfed8 100644 --- a/tests/bugs/iges/buc60591_1 +++ b/tests/bugs/iges/buc60591_1 @@ -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" diff --git a/tests/bugs/iges/buc60591_2 b/tests/bugs/iges/buc60591_2 index fafb47d07c..05aedb168d 100644 --- a/tests/bugs/iges/buc60591_2 +++ b/tests/bugs/iges/buc60591_2 @@ -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" diff --git a/tests/bugs/iges/buc60591_3 b/tests/bugs/iges/buc60591_3 index 3ad633515a..5afef3b6f8 100644 --- a/tests/bugs/iges/buc60591_3 +++ b/tests/bugs/iges/buc60591_3 @@ -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" diff --git a/tests/bugs/iges/buc60591_4 b/tests/bugs/iges/buc60591_4 index c9f0af8a76..6860b88a7f 100644 --- a/tests/bugs/iges/buc60591_4 +++ b/tests/bugs/iges/buc60591_4 @@ -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 "" diff --git a/tests/bugs/step/buc60948 b/tests/bugs/step/buc60948 index 3292aa9580..cb02f493ad 100644 --- a/tests/bugs/step/buc60948 +++ b/tests/bugs/step/buc60948 @@ -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" diff --git a/tests/bugs/step/bug23379 b/tests/bugs/step/bug23379 index 84eb7e8c82..96ed4c7ea6 100755 --- a/tests/bugs/step/bug23379 +++ b/tests/bugs/step/bug23379 @@ -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" diff --git a/tests/bugs/step/bug46 b/tests/bugs/step/bug46 index 33fbbaaf16..d1cb81b42b 100755 --- a/tests/bugs/step/bug46 +++ b/tests/bugs/step/bug46 @@ -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" diff --git a/tests/bugs/step/bug51 b/tests/bugs/step/bug51 index da7671709e..00f75eacaa 100755 --- a/tests/bugs/step/bug51 +++ b/tests/bugs/step/bug51 @@ -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" diff --git a/tests/bugs/xde/bug184 b/tests/bugs/xde/bug184 index f4bc056579..15e1226415 100755 --- a/tests/bugs/xde/bug184 +++ b/tests/bugs/xde/bug184 @@ -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 index 0000000000..72af506c93 --- /dev/null +++ b/tests/bugs/xde/bug23561 @@ -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" diff --git a/tests/bugs/xde/bug314 b/tests/bugs/xde/bug314 index 8c20629965..055bd9fa0b 100755 --- a/tests/bugs/xde/bug314 +++ b/tests/bugs/xde/bug314 @@ -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" diff --git a/tests/bugs/xde/bug321 b/tests/bugs/xde/bug321 index d91080ac1e..1c2c204c03 100755 --- a/tests/bugs/xde/bug321 +++ b/tests/bugs/xde/bug321 @@ -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"