1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-02 05:45:58 +02:00

patch from Robert O'Callahan <robert@ocallahan.org> to fix bug# 102434

This commit is contained in:
David Inglis 2005-07-05 19:52:21 +00:00
parent e91a9f5de5
commit 6c71187540
4 changed files with 89 additions and 76 deletions

View file

@ -1,3 +1,11 @@
2005-07-05 Robert O'Callahan <robert@ocallahan.org>
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 2005-07-04 David Inglis
fix for bug# 101647 fix for bug# 101647

View file

@ -565,7 +565,14 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
if (hints > 0) { if (hints > 0) {
try { try {
InputStream is = file.getContents(); 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(); is.close();
if (count > 0 && count < bytes.length) { if (count > 0 && count < bytes.length) {
byte[] array = new byte[count]; byte[] array = new byte[count];
@ -584,9 +591,11 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
for (int i = 0; i < parsers.length; i++) { for (int i = 0; i < parsers.length; i++) {
try { try {
IBinaryParser parser = parsers[i].getBinaryParser(); IBinaryParser parser = parsers[i].getBinaryParser();
IBinaryFile binFile = parser.getBinary(bytes, location); if (parser.isBinary(bytes, location)) {
if (binFile != null) { IBinaryFile binFile = parser.getBinary(bytes, location);
return binFile; if (binFile != null) {
return binFile;
}
} }
} catch (IOException e) { } catch (IOException e) {
} catch (CoreException e) { } catch (CoreException e) {

View file

@ -39,44 +39,42 @@ public class SOMParser extends AbstractCExtension implements IBinaryParser {
} }
IBinaryFile binary = null; IBinaryFile binary = null;
if (isBinary(hints, path)) { try {
try { SOM.Attribute attribute = null;
SOM.Attribute attribute = null; if (hints != null && hints.length > 0) {
if (hints != null && hints.length > 0) { try {
try { attribute = SOM.getAttributes(hints);
attribute = SOM.getAttributes(hints); } catch (EOFException eof) {
} catch (EOFException eof) { // continue, the array was to small.
// 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; return binary;
} }

View file

@ -43,44 +43,42 @@ public class XCOFF32Parser extends AbstractCExtension implements IBinaryParser {
} }
IBinaryFile binary = null; IBinaryFile binary = null;
if (isBinary(hints, path)) { try {
try { XCoff32.Attribute attribute = null;
XCoff32.Attribute attribute = null; if (hints != null && hints.length > 0) {
if (hints != null && hints.length > 0) { try {
try { attribute = XCoff32.getAttributes(hints);
attribute = XCoff32.getAttributes(hints); } catch (EOFException eof) {
} catch (EOFException eof) { // continue, the array was to small.
// 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; return binary;
} }