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
Date Sat, 30 Mar 2002 09:46:35 GMT
This looks ok to me, but could do with some changes. A few comments 
inline.

"Patric Bechtel" <bechtel@ipcon.de> wrote on 30/03/2002 09:53:21 AM:

> Sorry for the first diff, it's against the 1.4.1 version, so rather 
> useless for you.
> Here's the same thing against the current CVS version, also as diff 
-ruawN:
> 
-----------------------------------------------------------------------------------------------------------
> --- NetRexxC.java   Fri Mar 29 22:50:44 2002
> +++ \NetRexxC.java   Fri Mar 29 22:48:58 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,37 @@
>              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;
I'd make this a string buffer.

> +            BufferedReader in=new BufferedReader(new 
> StringReader(out.toString()));
Ok, why use a reader here, rather than a string buffer? The code would be 
simpler to write as well, as StringBuffer has a replace method.

> +            log("replacing destdir '"+ddir+"' through sourcedir 
> '"+sdir+"'", Project.MSG_VERBOSE);
> +            while ((l=in.readLine())!=null) {
> +                String left,right;
I'd declare these outside the while loop.
> +                int idx;
> +                if ((idx=l.indexOf(ddir))!=-1) { // path is 
> mentioned in the message
> +                    left=l.substring(0,idx);
> +                    if (idx+dlen<l.length()) {
> +                        right=l.substring(idx+dlen);
> +                    } else {
> +                        right="";
>              }
> -            else if (rc == 1) {
> -                log(out.toString(), Project.MSG_WARN);
> +                    l=left+sdir+right;
I'd make this an append for the string buffer, rather than string 
concatenation, in any case.

>              }
> -            else {
> -                log(out.toString(), Project.MSG_INFO);
> +                log(l, Project.MSG_ERR);
>              } 
> +            if (rc>1) {
> +                throw new BuildException("Compile failed, messages 
> should have been provided.");
> +            }
> +        } catch (IOException ioe) { // we do not expect this, really?
This really should log here as well.

>          } 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);
>          }
> +
>      }
> 
>      /**
> 
-----------------------------------------------------------------------------------------------------
> 
> Hope that's of more use for you... :-)
> 
> 
> 
> sincerely,
> 
> Patric Bechtel
> IPCON Informationssysteme

--
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