On Sat, 30 Mar 2002 20:46:35 +1100, [EMAIL PROTECTED] wrote:
Hm. Did your Stringbuffer and logging on IOException. The reader is still there,
I like it as it eats all kinds of linefeeds and breaks it up. Could also use a
tokenizer with all kinds of lineendings, but isn't really platform compatible,
as I don't remember linefeed on OS/390, VM and OS/400 right now... :-)
here it is again, I tested it and it behaves right.
-----------------------------------------------------
--- NetRexxC.java Sat Mar 30 13:45:55 2002
+++ \NetRexxC.java Sat Mar 30 13:43:08 2002
@@ -57,6 +57,8 @@
import java.io.IOException;
import java.io.StringWriter;
import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.BufferedReader;
import java.util.Vector;
import java.util.Hashtable;
@@ -567,24 +569,34 @@
StringWriter out = new StringWriter();
int rc = COM.ibm.netrexx.process.NetRexxC.
main(new Rexx(compileArgs), new PrintWriter(out));
-
- if (rc > 1) { // 1 is warnings from real NetRexxC
- log(out.toString(), Project.MSG_ERR);
- String msg = "Compile failed, messages should have been
provided.";
- throw new BuildException(msg);
+ String sdir=srcDir.getAbsolutePath();
+ String ddir=destDir.getAbsolutePath();
+ int dlen=ddir.length();
+ String l;
+ StringBuffer lb;
+ BufferedReader in=new BufferedReader(new
StringReader(out.toString()));
+ log("replacing destdir '"+ddir+"' through sourcedir '"+sdir+"'",
Project.MSG_VERBOSE);
+ while ((l=in.readLine())!=null) {
+ lb=new StringBuffer(l);
+ int idx;
+ while ((idx=lb.indexOf(ddir))!=-1) { // path is mentioned in
the message
+ lb.replace(idx,idx+dlen,sdir);
}
- else if (rc == 1) {
- log(out.toString(), Project.MSG_WARN);
+ log(lb.toString(), Project.MSG_ERR);
}
- else {
- log(out.toString(), Project.MSG_INFO);
+ if (rc>1) {
+ throw new BuildException("Compile failed, messages should have
been provided.");
}
+ } catch (IOException ioe) {
+ ioe.printStackTrace(); // we would like to know WHY this happened.
Should never!
+ throw new BuildException("Unexpected IOException while playing
with Strings: "+ioe.toString());
} finally {
// need to reset java.class.path property
// since the NetRexx compiler has no option for the classpath
currentProperties = System.getProperties();
currentProperties.put("java.class.path", currentClassPath);
}
+
}
/**
------------------------------------------------------
tia
Patric
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>