From 50fad5fe599a32cc0fa11632b9220b4fcc39b881 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 17 Oct 2002 14:00:25 +0000 Subject: [PATCH] reformat. --- core/org.eclipse.cdt.core/ChangeLog | 22 ++++- .../cdt/utils/spawner/SpawnerInputStream.java | 93 ++++++++++--------- .../utils/spawner/SpawnerOutputStream.java | 88 +++++++++--------- 3 files changed, 114 insertions(+), 89 deletions(-) diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index f056e05e5f2..2a24efd385d 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -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 @@ -42,4 +62,4 @@ builder will build increamentaly build projects when they change. Handle "clean" target as special so the build state is cleared allowing the next increamental build to come in as a full build. - \ No newline at end of file + diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java index 98153871123..102eb9063bc 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java @@ -9,69 +9,72 @@ import java.io.InputStream; import java.io.IOException; class SpawnerInputStream extends InputStream { - private int fd; + private int fd; - /** - * Fome a Unix valid file descriptor set a Reader. - * @param desc file descriptor. - */ - public SpawnerInputStream (int fd) { - this.fd = fd; - } + /** + * Fome a Unix valid file descriptor set a Reader. + * @param desc file descriptor. + */ + public SpawnerInputStream(int fd) { + this.fd = fd; + } - /** - * Implementation of read for the InputStream. - * - * @exception IOException on error. - */ - public int read () throws IOException { - byte b[] = new byte[1]; - if(1 != read(b, 0, 1)) - return -1; - return (int)b[0]; - } + /** + * Implementation of read for the InputStream. + * + * @exception IOException on error. + */ + public int read() throws IOException { + byte b[] = new byte[1]; + if (1 != read(b, 0, 1)) + return -1; + return (int) b[0]; + } /** * @see InputStream#read(byte[], int, int) */ 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)) { - throw new IndexOutOfBoundsException(); + throw new NullPointerException(); + } 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; + 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 { + if (fd == -1) + return; + int status = close0(fd); + if (status == -1) + throw new IOException("close error"); + fd = -1; + } - /** - * Close the Reader - * @exception IOException on error. - */ - public void close () throws IOException { - if (fd == -1) - return; - int status = close0 (fd); - if (status == -1) - throw new IOException ("close error"); - fd = -1; - } + private native int read0(int fd, byte[] buf, int len) throws IOException; + private native int close0(int fd) throws IOException; - private native int read0 (int fd, byte[] buf, int len) throws IOException; - native int close0 (int fd); - - static { - System.loadLibrary ("spawner"); - } + static { + System.loadLibrary("spawner"); + } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java index 70f45344b47..b279df57d8f 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java @@ -8,64 +8,66 @@ package org.eclipse.cdt.utils.spawner; import java.io.OutputStream; import java.io.IOException; -public class SpawnerOutputStream extends OutputStream -{ - private int fd; +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) { - this.fd = fd; - } + /** + * Fome a Unix valid file descriptor set a Reader. + * @param desc file descriptor. + */ + public SpawnerOutputStream(int fd) { + this.fd = fd; + } /** * @see OutputStream#write(byte[], int, int) */ 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)) { - throw new IndexOutOfBoundsException(); + throw new NullPointerException(); + } else if ( + (off < 0) + || (off > b.length) + || (len < 0) + || ((off + len) > b.length) + || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); } else if (len == 0) { - return; - } + return; + } byte[] tmpBuf = new byte[len]; System.arraycopy(b, off, tmpBuf, off, len); write0(fd, tmpBuf, len); } - /** - * Implementation of read for the InputStream. - * - * @exception IOException on error. - */ - public void write (int b) throws IOException { - byte[] buf = new byte[1]; - buf[0] = (byte)b; + /** + * Implementation of read for the InputStream. + * + * @exception IOException on error. + */ + public void write(int b) throws IOException { + byte[] buf = new byte[1]; + buf[0] = (byte) b; write(buf, 0, 1); - } + } - /** - * Close the Reader - * @exception IOException on error. - */ - public void close () throws IOException { - if (fd == -1) - return; - int status = close0 (fd); - if (status == -1) - throw new IOException ("close error"); - fd = -1; - } + /** + * Close the Reader + * @exception IOException on error. + */ + public void close() throws IOException { + if (fd == -1) + return; + int status = close0(fd); + if (status == -1) + 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$ + } }