Commit d132ee85 authored by Bill Lorensen's avatar Bill Lorensen Committed by Code Review
Browse files

Merge topic 'ExpectEOFsIn3DS' into master

631d795b Reads past EOF are expected
parents 8497b42d 631d795b
...@@ -52,14 +52,14 @@ viewer.SetColorWindow(255) ...@@ -52,14 +52,14 @@ viewer.SetColorWindow(255)
viewer.SetColorLevel(127.5) viewer.SetColorLevel(127.5)
viewer.Render() viewer.Render()
# on several opengl X window unix implementations ## on several opengl X window unix implementations
# multiple context deletes cause errors ## multiple context deletes cause errors
# so we leak the renWin in this test for unix ## so we leak the renWin in this test for unix
if renWin1.IsA('vtkXOpenGLRenderWindow'): #if renWin1.IsA('vtkXOpenGLRenderWindow'):
renWin1.Register(ren1) # renWin1.Register(ren1)
dl = vtk.vtkDebugLeaks() # dl = vtk.vtkDebugLeaks()
dl.SetExitError(0) # dl.SetExitError(0)
del dl # del dl
# iren.Initialize() # iren.Initialize()
# iren.Start() # iren.Start()
...@@ -52,14 +52,14 @@ viewer.SetColorWindow(255) ...@@ -52,14 +52,14 @@ viewer.SetColorWindow(255)
viewer.SetColorLevel(127.5) viewer.SetColorLevel(127.5)
viewer.Render() viewer.Render()
# on several opengl X window unix implementations ## on several opengl X window unix implementations
# multiple context deletes cause errors ## multiple context deletes cause errors
# so we leak the renWin1 in this test for unix ## so we leak the renWin1 in this test for unix
if renWin1.IsA('vtkXOpenGLRenderWindow'): #if renWin1.IsA('vtkXOpenGLRenderWindow'):
renWin1.Register(ren1) # renWin1.Register(ren1)
dl = vtk.vtkDebugLeaks() # dl = vtk.vtkDebugLeaks()
dl.SetExitError(0) # dl.SetExitError(0)
del dl # del dl
# iren.Initialize() # iren.Initialize()
# iren.Start() # iren.Start()
...@@ -49,12 +49,12 @@ vtkImageViewer viewer ...@@ -49,12 +49,12 @@ vtkImageViewer viewer
viewer SetColorLevel 127.5 viewer SetColorLevel 127.5
viewer Render viewer Render
# on several opengl X window unix implementations ## on several opengl X window unix implementations
# multiple context deletes cause errors ## multiple context deletes cause errors
# so we leak the renWin1 in this test for unix ## so we leak the renWin1 in this test for unix
if { $tcl_platform(platform) == "unix" } { #if { $tcl_platform(platform) == "unix" } {
renWin1 Register ren1 # renWin1 Register ren1
vtkDebugLeaks dl # vtkDebugLeaks dl
dl SetExitError 0 # dl SetExitError 0
dl Delete # dl Delete
} #}
...@@ -49,12 +49,12 @@ vtkImageViewer viewer ...@@ -49,12 +49,12 @@ vtkImageViewer viewer
viewer SetColorLevel 127.5 viewer SetColorLevel 127.5
viewer Render viewer Render
# on several opengl X window unix implementations ## on several opengl X window unix implementations
# multiple context deletes cause errors ## multiple context deletes cause errors
# so we leak the renWin1 in this test for unix ## so we leak the renWin1 in this test for unix
if { $tcl_platform(platform) == "unix" } { #if { $tcl_platform(platform) == "unix" } {
renWin1 Register ren1 # renWin1 Register ren1
vtkDebugLeaks dl # vtkDebugLeaks dl
dl SetExitError 0 # dl SetExitError 0
dl Delete # dl Delete
} #}
...@@ -96,7 +96,8 @@ static void start_chunk (vtk3DSImporter *importer, vtk3DSChunk *chunk); ...@@ -96,7 +96,8 @@ static void start_chunk (vtk3DSImporter *importer, vtk3DSChunk *chunk);
static void end_chunk (vtk3DSImporter *importer, vtk3DSChunk *chunk); static void end_chunk (vtk3DSImporter *importer, vtk3DSChunk *chunk);
static byte read_byte (vtk3DSImporter *importer); static byte read_byte (vtk3DSImporter *importer);
static word read_word (vtk3DSImporter *importer); static word read_word (vtk3DSImporter *importer);
static dword read_dword (vtk3DSImporter *importer); static word peek_word (vtk3DSImporter *importer);
static dword peek_dword (vtk3DSImporter *importer);
static float read_float (vtk3DSImporter *importer); static float read_float (vtk3DSImporter *importer);
static void read_point (vtk3DSImporter *importer, vtk3DSVector v); static void read_point (vtk3DSImporter *importer, vtk3DSVector v);
static char *read_string (vtk3DSImporter *importer); static char *read_string (vtk3DSImporter *importer);
...@@ -1043,8 +1044,8 @@ static float parse_float_percentage(vtk3DSImporter *importer) ...@@ -1043,8 +1044,8 @@ static float parse_float_percentage(vtk3DSImporter *importer)
static void start_chunk (vtk3DSImporter *importer, vtk3DSChunk *chunk) static void start_chunk (vtk3DSImporter *importer, vtk3DSChunk *chunk)
{ {
chunk->start = ftell(importer->GetFileFD()); chunk->start = ftell(importer->GetFileFD());
chunk->tag = read_word(importer); chunk->tag = peek_word(importer);
chunk->length = read_dword(importer); chunk->length = peek_dword(importer);
if (chunk->length == 0) if (chunk->length == 0)
{ {
chunk->length = 1; chunk->length = 1;
...@@ -1083,14 +1084,24 @@ static word read_word(vtk3DSImporter *importer) ...@@ -1083,14 +1084,24 @@ static word read_word(vtk3DSImporter *importer)
return data; return data;
} }
static dword read_dword(vtk3DSImporter *importer) static word peek_word(vtk3DSImporter *importer)
{
word data;
if (fread (&data, 2, 1, importer->GetFileFD()) != 1)
{
data = 0;
}
vtkByteSwap::Swap2LE ((short *) &data);
return data;
}
static dword peek_dword(vtk3DSImporter *importer)
{ {
dword data; dword data;
if (fread (&data, 4, 1, importer->GetFileFD()) != 1) if (fread (&data, 4, 1, importer->GetFileFD()) != 1)
{ {
vtkErrorWithObjectMacro(
importer, "Pre-mature end of file in read_dword\n");
data = 0; data = 0;
} }
...@@ -1098,7 +1109,6 @@ static dword read_dword(vtk3DSImporter *importer) ...@@ -1098,7 +1109,6 @@ static dword read_dword(vtk3DSImporter *importer)
return data; return data;
} }
static float read_float(vtk3DSImporter *importer) static float read_float(vtk3DSImporter *importer)
{ {
float data; float data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment