mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 06:55:23 +02:00
reformat.
This commit is contained in:
parent
e38c670d27
commit
50fad5fe59
3 changed files with 114 additions and 89 deletions
|
@ -1,3 +1,23 @@
|
|||
2002-10-16 Alain Magloire
|
||||
|
||||
Some of the native functions were throwing exceptions
|
||||
particularly on the windows platform and it was not
|
||||
clearly advertise. Eclipse uses a tool to externalize strings,
|
||||
to prevent this, strings need a comment "//$NON-NLS-1$".
|
||||
|
||||
* utils/../utils/pty/PTYInputStream.java (close0):
|
||||
Advertise that we can throw an IOException.
|
||||
* utils/../utils/pty/PTYOutputStream.java (close): Put
|
||||
the "$NON-NLS-1$" magic.
|
||||
(write0): Advertise we can throw IOException.
|
||||
(close0): Advertise we can throw IOException.
|
||||
* utils/../utils/spawner/ProcessFactory.java: Reformat.
|
||||
* utils/../utils/spawner/Spawner.java (Reaper):
|
||||
The run method when calling exec0 did not catch the exception.
|
||||
And the waitFor() should not be done on a pid == -1;
|
||||
* utils/../utils/spawner/SpawnerInputStream.java: Reformat.
|
||||
* utils/../utils/spawner/SpawnerOutputStream.java: Reformat.
|
||||
|
||||
2002-10-15 Alain Magloire
|
||||
|
||||
By making the native methods package scope, the
|
||||
|
|
|
@ -15,7 +15,7 @@ class SpawnerInputStream extends InputStream {
|
|||
* Fome a Unix valid file descriptor set a Reader.
|
||||
* @param desc file descriptor.
|
||||
*/
|
||||
public SpawnerInputStream (int fd) {
|
||||
public SpawnerInputStream(int fd) {
|
||||
this.fd = fd;
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,11 @@ class SpawnerInputStream extends InputStream {
|
|||
*
|
||||
* @exception IOException on error.
|
||||
*/
|
||||
public int read () throws IOException {
|
||||
public int read() throws IOException {
|
||||
byte b[] = new byte[1];
|
||||
if(1 != read(b, 0, 1))
|
||||
if (1 != read(b, 0, 1))
|
||||
return -1;
|
||||
return (int)b[0];
|
||||
return (int) b[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,41 +37,44 @@ class SpawnerInputStream extends InputStream {
|
|||
public int read(byte[] buf, int off, int len) throws IOException {
|
||||
if (buf == null) {
|
||||
throw new NullPointerException();
|
||||
} else if ((off < 0) || (off > buf.length) || (len < 0) ||
|
||||
((off + len) > buf.length) || ((off + len) < 0)) {
|
||||
} else if (
|
||||
(off < 0)
|
||||
|| (off > buf.length)
|
||||
|| (len < 0)
|
||||
|| ((off + len) > buf.length)
|
||||
|| ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
byte[] tmpBuf = new byte[len];
|
||||
|
||||
len = read0( fd, tmpBuf, len );
|
||||
if( len <= 0 )
|
||||
len = read0(fd, tmpBuf, len);
|
||||
if (len <= 0)
|
||||
return -1;
|
||||
|
||||
System.arraycopy(tmpBuf, 0, buf, off, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the Reader
|
||||
* @exception IOException on error.
|
||||
*/
|
||||
public void close () throws IOException {
|
||||
public void close() throws IOException {
|
||||
if (fd == -1)
|
||||
return;
|
||||
int status = close0 (fd);
|
||||
int status = close0(fd);
|
||||
if (status == -1)
|
||||
throw new IOException ("close error");
|
||||
throw new IOException("close error");
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
private native int read0 (int fd, byte[] buf, int len) throws IOException;
|
||||
native int close0 (int fd);
|
||||
private native int read0(int fd, byte[] buf, int len) throws IOException;
|
||||
private native int close0(int fd) throws IOException;
|
||||
|
||||
static {
|
||||
System.loadLibrary ("spawner");
|
||||
System.loadLibrary("spawner");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,15 +8,14 @@ package org.eclipse.cdt.utils.spawner;
|
|||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SpawnerOutputStream extends OutputStream
|
||||
{
|
||||
public class SpawnerOutputStream extends OutputStream {
|
||||
private int fd;
|
||||
|
||||
/**
|
||||
* Fome a Unix valid file descriptor set a Reader.
|
||||
* @param desc file descriptor.
|
||||
*/
|
||||
public SpawnerOutputStream (int fd) {
|
||||
public SpawnerOutputStream(int fd) {
|
||||
this.fd = fd;
|
||||
}
|
||||
|
||||
|
@ -26,8 +25,12 @@ public class SpawnerOutputStream extends OutputStream
|
|||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
} else if ((off < 0) || (off > b.length) || (len < 0) ||
|
||||
((off + len) > b.length) || ((off + len) < 0)) {
|
||||
} else if (
|
||||
(off < 0)
|
||||
|| (off > b.length)
|
||||
|| (len < 0)
|
||||
|| ((off + len) > b.length)
|
||||
|| ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return;
|
||||
|
@ -41,9 +44,9 @@ public class SpawnerOutputStream extends OutputStream
|
|||
*
|
||||
* @exception IOException on error.
|
||||
*/
|
||||
public void write (int b) throws IOException {
|
||||
public void write(int b) throws IOException {
|
||||
byte[] buf = new byte[1];
|
||||
buf[0] = (byte)b;
|
||||
buf[0] = (byte) b;
|
||||
write(buf, 0, 1);
|
||||
}
|
||||
|
||||
|
@ -51,21 +54,20 @@ public class SpawnerOutputStream extends OutputStream
|
|||
* Close the Reader
|
||||
* @exception IOException on error.
|
||||
*/
|
||||
public void close () throws IOException {
|
||||
public void close() throws IOException {
|
||||
if (fd == -1)
|
||||
return;
|
||||
int status = close0 (fd);
|
||||
int status = close0(fd);
|
||||
if (status == -1)
|
||||
throw new IOException ("close error");
|
||||
throw new IOException("close error"); //$NON-NLS-1$
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
private native int write0 (int fd, byte[] b, int len);
|
||||
private native int close0 (int fd);
|
||||
private native int write0(int fd, byte[] b, int len) throws IOException;
|
||||
private native int close0(int fd);
|
||||
|
||||
static
|
||||
{
|
||||
System.loadLibrary ("spawner");
|
||||
static {
|
||||
System.loadLibrary("spawner"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue