ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@multitask.com.au
Subject Re: NetRexxC-diff [Viruschecked]
Date Sat, 30 Mar 2002 14:09:31 GMT
Ok, how about this:

"Patric Bechtel" <bechtel@ipcon.de> wrote on 31/03/2002 12:51:09 AM:

> On Sat, 30 Mar 2002 20:46:35 +1100, dion@multitask.com.au 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;
replace above with:
                StringBuffer lb = new StringBuffer(out.toString());

> +            BufferedReader in=new BufferedReader(new 
> StringReader(out.toString()));
Remove above line.

> +            log("replacing destdir '"+ddir+"' through sourcedir 
> '"+sdir+"'", Project.MSG_VERBOSE);
> +            while ((l=in.readLine())!=null) {
> +               lb=new StringBuffer(l);
Remove above 2 lines, as there's no need to 'chunk' lines - do the whole 
stringbuffer in one hit.

> +                int idx;
> +                while ((idx=lb.indexOf(ddir))!=-1) { // path is 
> mentioned in the message
> +                    lb.replace(idx,idx+dlen,sdir);
>              }
remove above line.

> -            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
--
dIon Gillard, Multitask Consulting
Work:      http://www.multitask.com.au
Developers: http://adslgateway.multitask.com.au/developers


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message