diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 34d7639897c..a3bce0bc620 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,11 @@ +2005-07-05 Robert O'Callahan + + fix for bug# 102434 + + * model/org/eclipse/cdt/internal/model/CModelManager.java + * util/org/eclipse/cdt/utils/som/parser/SOMParser.java + * util/org/eclipse/cdt/utils/xcoff/parser/XCOFF32Parser.java + 2005-07-04 David Inglis fix for bug# 101647 diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java index bd35ad38af8..b97ed3b1a6e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java @@ -565,7 +565,14 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe if (hints > 0) { try { InputStream is = file.getContents(); - int count = is.read(bytes); + int count = 0; + // Make sure we read up to 'hints' bytes if we possibly can + while (count < hints) { + int bytesRead = is.read(bytes, count, hints - count); + if (bytesRead < 0) + break; + count += bytesRead; + } is.close(); if (count > 0 && count < bytes.length) { byte[] array = new byte[count]; @@ -584,9 +591,11 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe for (int i = 0; i < parsers.length; i++) { try { IBinaryParser parser = parsers[i].getBinaryParser(); - IBinaryFile binFile = parser.getBinary(bytes, location); - if (binFile != null) { - return binFile; + if (parser.isBinary(bytes, location)) { + IBinaryFile binFile = parser.getBinary(bytes, location); + if (binFile != null) { + return binFile; + } } } catch (IOException e) { } catch (CoreException e) { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMParser.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMParser.java index 222398645cd..3980101c3dd 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMParser.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMParser.java @@ -39,44 +39,42 @@ public class SOMParser extends AbstractCExtension implements IBinaryParser { } IBinaryFile binary = null; - if (isBinary(hints, path)) { - try { - SOM.Attribute attribute = null; - if (hints != null && hints.length > 0) { - try { - attribute = SOM.getAttributes(hints); - } catch (EOFException eof) { - // continue, the array was to small. - } + try { + SOM.Attribute attribute = null; + if (hints != null && hints.length > 0) { + try { + attribute = SOM.getAttributes(hints); + } catch (EOFException eof) { + // continue, the array was to small. } - - //Take a second run at it if the data array failed. - if(attribute == null) { - attribute = SOM.getAttributes(path.toOSString()); - } - - if (attribute != null) { - switch (attribute.getType()) { - case SOM.Attribute.SOM_TYPE_EXE : - binary = createBinaryExecutable(path); - break; - - case SOM.Attribute.SOM_TYPE_SHLIB : - binary = createBinaryShared(path); - break; - - case SOM.Attribute.SOM_TYPE_OBJ : - binary = createBinaryObject(path); - break; - - case SOM.Attribute.SOM_TYPE_CORE : - binary = createBinaryCore(path); - break; - } - } - } catch (IOException e) { - binary = createBinaryArchive(path); } + + //Take a second run at it if the data array failed. + if(attribute == null) { + attribute = SOM.getAttributes(path.toOSString()); + } + + if (attribute != null) { + switch (attribute.getType()) { + case SOM.Attribute.SOM_TYPE_EXE : + binary = createBinaryExecutable(path); + break; + + case SOM.Attribute.SOM_TYPE_SHLIB : + binary = createBinaryShared(path); + break; + + case SOM.Attribute.SOM_TYPE_OBJ : + binary = createBinaryObject(path); + break; + + case SOM.Attribute.SOM_TYPE_CORE : + binary = createBinaryCore(path); + break; + } + } + } catch (IOException e) { + binary = createBinaryArchive(path); } return binary; } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFF32Parser.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFF32Parser.java index aac992069e6..19cdcabd0a8 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFF32Parser.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFF32Parser.java @@ -43,44 +43,42 @@ public class XCOFF32Parser extends AbstractCExtension implements IBinaryParser { } IBinaryFile binary = null; - if (isBinary(hints, path)) { - try { - XCoff32.Attribute attribute = null; - if (hints != null && hints.length > 0) { - try { - attribute = XCoff32.getAttributes(hints); - } catch (EOFException eof) { - // continue, the array was to small. - } + try { + XCoff32.Attribute attribute = null; + if (hints != null && hints.length > 0) { + try { + attribute = XCoff32.getAttributes(hints); + } catch (EOFException eof) { + // continue, the array was to small. } - - //Take a second run at it if the data array failed. - if (attribute == null) { - attribute = XCoff32.getAttributes(path.toOSString()); - } - - if (attribute != null) { - switch (attribute.getType()) { - case XCoff32.Attribute.XCOFF_TYPE_EXE : - binary = createBinaryExecutable(path); - break; - - case XCoff32.Attribute.XCOFF_TYPE_SHLIB : - binary = createBinaryShared(path); - break; - - case XCoff32.Attribute.XCOFF_TYPE_OBJ : - binary = createBinaryObject(path); - break; - - case XCoff32.Attribute.XCOFF_TYPE_CORE : - binary = createBinaryCore(path); - break; - } - } - } catch (IOException e) { - binary = createBinaryArchive(path); } + + //Take a second run at it if the data array failed. + if (attribute == null) { + attribute = XCoff32.getAttributes(path.toOSString()); + } + + if (attribute != null) { + switch (attribute.getType()) { + case XCoff32.Attribute.XCOFF_TYPE_EXE : + binary = createBinaryExecutable(path); + break; + + case XCoff32.Attribute.XCOFF_TYPE_SHLIB : + binary = createBinaryShared(path); + break; + + case XCoff32.Attribute.XCOFF_TYPE_OBJ : + binary = createBinaryObject(path); + break; + + case XCoff32.Attribute.XCOFF_TYPE_CORE : + binary = createBinaryCore(path); + break; + } + } + } catch (IOException e) { + binary = createBinaryArchive(path); } return binary; }