1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 13:25:45 +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,10 +591,12 @@ 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();
if (parser.isBinary(bytes, location)) {
IBinaryFile binFile = parser.getBinary(bytes, location); IBinaryFile binFile = parser.getBinary(bytes, location);
if (binFile != null) { if (binFile != null) {
return binFile; return binFile;
} }
}
} catch (IOException e) { } catch (IOException e) {
} catch (CoreException e) { } catch (CoreException e) {
} }

View file

@ -39,7 +39,6 @@ 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) {
@ -77,7 +76,6 @@ public class SOMParser extends AbstractCExtension implements IBinaryParser {
} catch (IOException e) { } catch (IOException e) {
binary = createBinaryArchive(path); binary = createBinaryArchive(path);
} }
}
return binary; return binary;
} }

View file

@ -43,7 +43,6 @@ 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) {
@ -81,7 +80,6 @@ public class XCOFF32Parser extends AbstractCExtension implements IBinaryParser {
} catch (IOException e) { } catch (IOException e) {
binary = createBinaryArchive(path); binary = createBinaryArchive(path);
} }
}
return binary; return binary;
} }